Fix two neutron service defects 13/2713/3
authorRyan Moats <rmoats@us.ibm.com>
Wed, 13 Nov 2013 16:55:04 +0000 (10:55 -0600)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 14 Nov 2013 13:46:47 +0000 (13:46 +0000)
Ensure that singleton neutron network objects are properly
initialized on create.  Add case insensitive check to port
MAC address on create.

Change-Id: I6b929302cba775e4ccd1f8c8c0f297a2154c2624
Signed-off-by: Ryan Moats <rmoats@us.ibm.com>
opendaylight/northbound/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronNetworksNorthbound.java
opendaylight/northbound/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronPortsNorthbound.java

index e8690aa889aee1d449601a3156757d298de9dd72..c08ee80e24c44f3551d949e0ff607c7264be9167 100644 (file)
@@ -12,6 +12,7 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
+
 import javax.ws.rs.Consumes;
 import javax.ws.rs.DELETE;
 import javax.ws.rs.GET;
@@ -67,8 +68,8 @@ public class NeutronNetworksNorthbound {
     @Produces({ MediaType.APPLICATION_JSON })
     //@TypeHint(OpenStackNetworks.class)
     @StatusCodes({
-            @ResponseCode(code = 200, condition = "Operation successful"),
-            @ResponseCode(code = 401, condition = "Unauthorized") })
+        @ResponseCode(code = 200, condition = "Operation successful"),
+        @ResponseCode(code = 401, condition = "Unauthorized") })
     public Response listNetworks(
             // return fields
             @QueryParam("fields") List<String> fields,
@@ -88,7 +89,7 @@ public class NeutronNetworksNorthbound {
             @QueryParam("marker") String marker,
             @QueryParam("page_reverse") String pageReverse
             // sorting not supported
-        ) {
+            ) {
         INeutronNetworkCRUD networkInterface = NeutronCRUDInterfaces.getINeutronNetworkCRUD( this);
         if (networkInterface == null) {
             throw new ServiceUnavailableException("Network CRUD Interface "
@@ -103,12 +104,15 @@ public class NeutronNetworksNorthbound {
             Boolean bAdminStateUp = null;
             Boolean bShared = null;
             Boolean bRouterExternal = null;
-            if (queryAdminStateUp != null)
+            if (queryAdminStateUp != null) {
                 bAdminStateUp = Boolean.valueOf(queryAdminStateUp);
-            if (queryShared != null)
+            }
+            if (queryShared != null) {
                 bShared = Boolean.valueOf(queryShared);
-            if (queryRouterExternal != null)
+            }
+            if (queryRouterExternal != null) {
                 bRouterExternal = Boolean.valueOf(queryRouterExternal);
+            }
             if ((queryID == null || queryID.equals(oSN.getID())) &&
                     (queryName == null || queryName.equals(oSN.getNetworkName())) &&
                     (bAdminStateUp == null || bAdminStateUp.booleanValue() == oSN.isAdminStateUp()) &&
@@ -116,10 +120,11 @@ public class NeutronNetworksNorthbound {
                     (bShared == null || bShared.booleanValue() == oSN.isShared()) &&
                     (bRouterExternal == null || bRouterExternal.booleanValue() == oSN.isRouterExternal()) &&
                     (queryTenantID == null || queryTenantID.equals(oSN.getTenantID()))) {
-                if (fields.size() > 0)
+                if (fields.size() > 0) {
                     ans.add(extractFields(oSN,fields));
-                else
+                } else {
                     ans.add(oSN);
+                }
             }
         }
         //TODO: apply pagination to results
@@ -135,9 +140,9 @@ public class NeutronNetworksNorthbound {
     @Produces({ MediaType.APPLICATION_JSON })
     //@TypeHint(OpenStackNetworks.class)
     @StatusCodes({
-            @ResponseCode(code = 200, condition = "Operation successful"),
-            @ResponseCode(code = 401, condition = "Unauthorized"),
-            @ResponseCode(code = 404, condition = "Not Found") })
+        @ResponseCode(code = 200, condition = "Operation successful"),
+        @ResponseCode(code = 401, condition = "Unauthorized"),
+        @ResponseCode(code = 404, condition = "Not Found") })
     public Response showNetwork(
             @PathParam("netUUID") String netUUID,
             // return fields
@@ -148,15 +153,17 @@ public class NeutronNetworksNorthbound {
             throw new ServiceUnavailableException("Network CRUD Interface "
                     + RestMessages.SERVICEUNAVAILABLE.toString());
         }
-        if (!networkInterface.networkExists(netUUID))
+        if (!networkInterface.networkExists(netUUID)) {
             return Response.status(404).build();
+        }
         if (fields.size() > 0) {
             NeutronNetwork ans = networkInterface.getNetwork(netUUID);
             return Response.status(200).entity(
                     new NeutronNetworkRequest(extractFields(ans, fields))).build();
-        } else
+        } else {
             return Response.status(200).entity(
                     new NeutronNetworkRequest(networkInterface.getNetwork(netUUID))).build();
+        }
     }
 
     /**
@@ -166,9 +173,9 @@ public class NeutronNetworksNorthbound {
     @Consumes({ MediaType.APPLICATION_JSON })
     @TypeHint(NeutronNetwork.class)
     @StatusCodes({
-            @ResponseCode(code = 201, condition = "Created"),
-            @ResponseCode(code = 400, condition = "Bad Request"),
-            @ResponseCode(code = 401, condition = "Unauthorized") })
+        @ResponseCode(code = 201, condition = "Created"),
+        @ResponseCode(code = 400, condition = "Bad Request"),
+        @ResponseCode(code = 401, condition = "Unauthorized") })
     public Response createNetworks(final NeutronNetworkRequest input) {
         INeutronNetworkCRUD networkInterface = NeutronCRUDInterfaces.getINeutronNetworkCRUD( this);
         if (networkInterface == null) {
@@ -181,20 +188,23 @@ public class NeutronNetworksNorthbound {
             /*
              * network ID can't already exist
              */
-            if (networkInterface.networkExists(singleton.getID()))
+            if (networkInterface.networkExists(singleton.getID())) {
                 return Response.status(400).build();
+            }
 
             Object[] instances = ServiceHelper.getGlobalInstances(INeutronNetworkAware.class, this, null);
             if (instances != null) {
                 for (Object instance : instances) {
                     INeutronNetworkAware service = (INeutronNetworkAware) instance;
                     int status = service.canCreateNetwork(singleton);
-                    if (status < 200 || status > 299)
+                    if (status < 200 || status > 299) {
                         return Response.status(status).build();
+                    }
                 }
             }
 
             // add network to cache
+            singleton.initDefaults();
             networkInterface.addNetwork(singleton);
             if (instances != null) {
                 for (Object instance : instances) {
@@ -215,16 +225,19 @@ public class NeutronNetworksNorthbound {
                  * network ID can't already exist, nor can there be an entry for this UUID
                  * already in this bulk request
                  */
-                if (networkInterface.networkExists(test.getID()))
+                if (networkInterface.networkExists(test.getID())) {
                     return Response.status(400).build();
-                if (testMap.containsKey(test.getID()))
+                }
+                if (testMap.containsKey(test.getID())) {
                     return Response.status(400).build();
+                }
                 if (instances != null) {
                     for (Object instance: instances) {
                         INeutronNetworkAware service = (INeutronNetworkAware) instance;
                         int status = service.canCreateNetwork(test);
-                        if (status < 200 || status > 299)
+                        if (status < 200 || status > 299) {
                             return Response.status(status).build();
+                        }
                     }
                 }
                 testMap.put(test.getID(),test);
@@ -255,10 +268,10 @@ public class NeutronNetworksNorthbound {
     @Consumes({ MediaType.APPLICATION_JSON })
     //@TypeHint(OpenStackNetworks.class)
     @StatusCodes({
-            @ResponseCode(code = 200, condition = "Operation successful"),
-            @ResponseCode(code = 400, condition = "Bad Request"),
-            @ResponseCode(code = 403, condition = "Forbidden"),
-            @ResponseCode(code = 404, condition = "Not Found"), })
+        @ResponseCode(code = 200, condition = "Operation successful"),
+        @ResponseCode(code = 400, condition = "Bad Request"),
+        @ResponseCode(code = 403, condition = "Forbidden"),
+        @ResponseCode(code = 404, condition = "Not Found"), })
     public Response updateNetwork(
             @PathParam("netUUID") String netUUID, final NeutronNetworkRequest input
             ) {
@@ -271,18 +284,21 @@ public class NeutronNetworksNorthbound {
         /*
          * network has to exist and only a single delta is supported
          */
-        if (!networkInterface.networkExists(netUUID))
+        if (!networkInterface.networkExists(netUUID)) {
             return Response.status(404).build();
-        if (!input.isSingleton())
+        }
+        if (!input.isSingleton()) {
             return Response.status(400).build();
+        }
         NeutronNetwork delta = input.getSingleton();
 
         /*
          * transitions forbidden by Neutron
          */
         if (delta.getID() != null || delta.getTenantID() != null ||
-                delta.getStatus() != null)
+                delta.getStatus() != null) {
             return Response.status(400).build();
+        }
 
         Object[] instances = ServiceHelper.getGlobalInstances(INeutronNetworkAware.class, this, null);
         if (instances != null) {
@@ -290,22 +306,23 @@ public class NeutronNetworksNorthbound {
                 INeutronNetworkAware service = (INeutronNetworkAware) instance;
                 NeutronNetwork original = networkInterface.getNetwork(netUUID);
                 int status = service.canUpdateNetwork(delta, original);
-                if (status < 200 || status > 299)
+                if (status < 200 || status > 299) {
                     return Response.status(status).build();
+                }
             }
         }
 
         // update network object and return the modified object
-        networkInterface.updateNetwork(netUUID, delta);
-        NeutronNetwork updatedSingleton = networkInterface.getNetwork(netUUID);
-        if (instances != null) {
-            for (Object instance : instances) {
-                INeutronNetworkAware service = (INeutronNetworkAware) instance;
-                service.neutronNetworkUpdated(updatedSingleton);
-            }
-        }
-        return Response.status(200).entity(
-                new NeutronNetworkRequest(networkInterface.getNetwork(netUUID))).build();
+                networkInterface.updateNetwork(netUUID, delta);
+                NeutronNetwork updatedSingleton = networkInterface.getNetwork(netUUID);
+                if (instances != null) {
+                    for (Object instance : instances) {
+                        INeutronNetworkAware service = (INeutronNetworkAware) instance;
+                        service.neutronNetworkUpdated(updatedSingleton);
+                    }
+                }
+                return Response.status(200).entity(
+                        new NeutronNetworkRequest(networkInterface.getNetwork(netUUID))).build();
     }
 
     /**
@@ -314,10 +331,10 @@ public class NeutronNetworksNorthbound {
     @Path("{netUUID}")
     @DELETE
     @StatusCodes({
-            @ResponseCode(code = 204, condition = "No Content"),
-            @ResponseCode(code = 401, condition = "Unauthorized"),
-            @ResponseCode(code = 404, condition = "Not Found"),
-            @ResponseCode(code = 409, condition = "Network In Use") })
+        @ResponseCode(code = 204, condition = "No Content"),
+        @ResponseCode(code = 401, condition = "Unauthorized"),
+        @ResponseCode(code = 404, condition = "Not Found"),
+        @ResponseCode(code = 409, condition = "Network In Use") })
     public Response deleteNetwork(
             @PathParam("netUUID") String netUUID) {
         INeutronNetworkCRUD networkInterface = NeutronCRUDInterfaces.getINeutronNetworkCRUD( this);
@@ -329,10 +346,12 @@ public class NeutronNetworksNorthbound {
         /*
          * network has to exist and not be in use before it can be removed
          */
-        if (!networkInterface.networkExists(netUUID))
+        if (!networkInterface.networkExists(netUUID)) {
             return Response.status(404).build();
-        if (networkInterface.networkInUse(netUUID))
+        }
+        if (networkInterface.networkInUse(netUUID)) {
             return Response.status(409).build();
+        }
 
         NeutronNetwork singleton = networkInterface.getNetwork(netUUID);
         Object[] instances = ServiceHelper.getGlobalInstances(INeutronNetworkAware.class, this, null);
@@ -340,8 +359,9 @@ public class NeutronNetworksNorthbound {
             for (Object instance : instances) {
                 INeutronNetworkAware service = (INeutronNetworkAware) instance;
                 int status = service.canDeleteNetwork(singleton);
-                if (status < 200 || status > 299)
+                if (status < 200 || status > 299) {
                     return Response.status(status).build();
+                }
             }
         }
         networkInterface.removeNetwork(netUUID);
index 08e5dfbb364d6cf7c82b2c677cff3359f533a13b..d3c262f222f7f62bd612193944b0b0d919a50271 100644 (file)
@@ -12,6 +12,7 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
+
 import javax.ws.rs.Consumes;
 import javax.ws.rs.DELETE;
 import javax.ws.rs.GET;
@@ -71,9 +72,9 @@ public class NeutronPortsNorthbound {
     @Produces({ MediaType.APPLICATION_JSON })
     //@TypeHint(OpenStackPorts.class)
     @StatusCodes({
-            @ResponseCode(code = 200, condition = "Operation successful"),
-            @ResponseCode(code = 401, condition = "Unauthorized"),
-            @ResponseCode(code = 501, condition = "Not Implemented") })
+        @ResponseCode(code = 200, condition = "Operation successful"),
+        @ResponseCode(code = 401, condition = "Unauthorized"),
+        @ResponseCode(code = 501, condition = "Not Implemented") })
     public Response listPorts(
             // return fields
             @QueryParam("fields") List<String> fields,
@@ -112,10 +113,11 @@ public class NeutronPortsNorthbound {
                     (queryDeviceID == null || queryDeviceID.equals(oSS.getDeviceID())) &&
                     (queryDeviceOwner == null || queryDeviceOwner.equals(oSS.getDeviceOwner())) &&
                     (queryTenantID == null || queryTenantID.equals(oSS.getTenantID()))) {
-                if (fields.size() > 0)
+                if (fields.size() > 0) {
                     ans.add(extractFields(oSS,fields));
-                else
+                } else {
                     ans.add(oSS);
+                }
             }
         }
         //TODO: apply pagination to results
@@ -131,10 +133,10 @@ public class NeutronPortsNorthbound {
     @Produces({ MediaType.APPLICATION_JSON })
     //@TypeHint(OpenStackPorts.class)
     @StatusCodes({
-            @ResponseCode(code = 200, condition = "Operation successful"),
-            @ResponseCode(code = 401, condition = "Unauthorized"),
-            @ResponseCode(code = 404, condition = "Not Found"),
-            @ResponseCode(code = 501, condition = "Not Implemented") })
+        @ResponseCode(code = 200, condition = "Operation successful"),
+        @ResponseCode(code = 401, condition = "Unauthorized"),
+        @ResponseCode(code = 404, condition = "Not Found"),
+        @ResponseCode(code = 501, condition = "Not Implemented") })
     public Response showPort(
             @PathParam("portUUID") String portUUID,
             // return fields
@@ -144,15 +146,17 @@ public class NeutronPortsNorthbound {
             throw new ServiceUnavailableException("Port CRUD Interface "
                     + RestMessages.SERVICEUNAVAILABLE.toString());
         }
-        if (!portInterface.portExists(portUUID))
+        if (!portInterface.portExists(portUUID)) {
             return Response.status(404).build();
+        }
         if (fields.size() > 0) {
             NeutronPort ans = portInterface.getPort(portUUID);
             return Response.status(200).entity(
                     new NeutronPortRequest(extractFields(ans, fields))).build();
-        } else
+        } else {
             return Response.status(200).entity(
                     new NeutronPortRequest(portInterface.getPort(portUUID))).build();
+        }
     }
 
     /**
@@ -163,14 +167,14 @@ public class NeutronPortsNorthbound {
     @Consumes({ MediaType.APPLICATION_JSON })
     //@TypeHint(OpenStackPorts.class)
     @StatusCodes({
-            @ResponseCode(code = 201, condition = "Created"),
-            @ResponseCode(code = 400, condition = "Bad Request"),
-            @ResponseCode(code = 401, condition = "Unauthorized"),
-            @ResponseCode(code = 403, condition = "Forbidden"),
-            @ResponseCode(code = 404, condition = "Not Found"),
-            @ResponseCode(code = 409, condition = "Conflict"),
-            @ResponseCode(code = 501, condition = "Not Implemented"),
-            @ResponseCode(code = 503, condition = "MAC generation failure") })
+        @ResponseCode(code = 201, condition = "Created"),
+        @ResponseCode(code = 400, condition = "Bad Request"),
+        @ResponseCode(code = 401, condition = "Unauthorized"),
+        @ResponseCode(code = 403, condition = "Forbidden"),
+        @ResponseCode(code = 404, condition = "Not Found"),
+        @ResponseCode(code = 409, condition = "Conflict"),
+        @ResponseCode(code = 501, condition = "Not Implemented"),
+        @ResponseCode(code = 503, condition = "MAC generation failure") })
     public Response createPorts(final NeutronPortRequest input) {
         INeutronPortCRUD portInterface = NeutronCRUDInterfaces.getINeutronPortCRUD(this);
         if (portInterface == null) {
@@ -194,24 +198,30 @@ public class NeutronPortsNorthbound {
              * the port must be part of an existing network, must not already exist,
              * have a valid MAC and the MAC not be in use
              */
-            if (singleton.getNetworkUUID() == null)
+            if (singleton.getNetworkUUID() == null) {
                 return Response.status(400).build();
-            if (portInterface.portExists(singleton.getID()))
+            }
+            if (portInterface.portExists(singleton.getID())) {
                 return Response.status(400).build();
-            if (!networkInterface.networkExists(singleton.getNetworkUUID()))
+            }
+            if (!networkInterface.networkExists(singleton.getNetworkUUID())) {
                 return Response.status(404).build();
+            }
             if (singleton.getMacAddress() == null ||
-                    !singleton.getMacAddress().matches("^([0-9A-F]{2}[:-]){5}([0-9A-F]{2})$"))
+                    !singleton.getMacAddress().matches("^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$")) {
                 return Response.status(400).build();
-            if (portInterface.macInUse(singleton.getMacAddress()))
+            }
+            if (portInterface.macInUse(singleton.getMacAddress())) {
                 return Response.status(409).build();
+            }
             Object[] instances = ServiceHelper.getGlobalInstances(INeutronPortAware.class, this, null);
             if (instances != null) {
                 for (Object instance : instances) {
                     INeutronPortAware service = (INeutronPortAware) instance;
                     int status = service.canCreatePort(singleton);
-                    if (status < 200 || status > 299)
+                    if (status < 200 || status > 299) {
                         return Response.status(status).build();
+                    }
                 }
             }
             /*
@@ -225,18 +235,23 @@ public class NeutronPortsNorthbound {
                 Iterator<Neutron_IPs> fixedIPIterator = fixedIPs.iterator();
                 while (fixedIPIterator.hasNext()) {
                     Neutron_IPs ip = fixedIPIterator.next();
-                    if (ip.getSubnetUUID() == null)
+                    if (ip.getSubnetUUID() == null) {
                         return Response.status(400).build();
-                    if (!subnetInterface.subnetExists(ip.getSubnetUUID()))
+                    }
+                    if (!subnetInterface.subnetExists(ip.getSubnetUUID())) {
                         return Response.status(400).build();
+                    }
                     NeutronSubnet subnet = subnetInterface.getSubnet(ip.getSubnetUUID());
-                    if (!singleton.getNetworkUUID().equalsIgnoreCase(subnet.getNetworkUUID()))
+                    if (!singleton.getNetworkUUID().equalsIgnoreCase(subnet.getNetworkUUID())) {
                         return Response.status(400).build();
+                    }
                     if (ip.getIpAddress() != null) {
-                        if (!subnet.isValidIP(ip.getIpAddress()))
+                        if (!subnet.isValidIP(ip.getIpAddress())) {
                             return Response.status(400).build();
-                        if (subnet.isIPInUse(ip.getIpAddress()))
+                        }
+                        if (subnet.isIPInUse(ip.getIpAddress())) {
                             return Response.status(409).build();
+                        }
                     }
                 }
             }
@@ -262,33 +277,41 @@ public class NeutronPortsNorthbound {
                  * have a valid MAC and the MAC not be in use.  Further the bulk request
                  * can't already contain a new port with the same UUID
                  */
-                if (portInterface.portExists(test.getID()))
+                if (portInterface.portExists(test.getID())) {
                     return Response.status(400).build();
-                if (testMap.containsKey(test.getID()))
+                }
+                if (testMap.containsKey(test.getID())) {
                     return Response.status(400).build();
+                }
                 for (NeutronPort check : testMap.values()) {
-                    if (test.getMacAddress().equalsIgnoreCase(check.getMacAddress()))
+                    if (test.getMacAddress().equalsIgnoreCase(check.getMacAddress())) {
                         return Response.status(409).build();
+                    }
                     for (Neutron_IPs test_fixedIP : test.getFixedIPs()) {
                         for (Neutron_IPs check_fixedIP : check.getFixedIPs()) {
-                            if (test_fixedIP.getIpAddress().equals(check_fixedIP.getIpAddress()))
+                            if (test_fixedIP.getIpAddress().equals(check_fixedIP.getIpAddress())) {
                                 return Response.status(409).build();
+                            }
                         }
                     }
                 }
                 testMap.put(test.getID(), test);
-                if (!networkInterface.networkExists(test.getNetworkUUID()))
+                if (!networkInterface.networkExists(test.getNetworkUUID())) {
                     return Response.status(404).build();
-                if (!test.getMacAddress().matches("^([0-9A-F]{2}[:-]){5}([0-9A-F]{2})$"))
+                }
+                if (!test.getMacAddress().matches("^([0-9A-F]{2}[:-]){5}([0-9A-F]{2})$")) {
                     return Response.status(400).build();
-                if (portInterface.macInUse(test.getMacAddress()))
+                }
+                if (portInterface.macInUse(test.getMacAddress())) {
                     return Response.status(409).build();
+                }
                 if (instances != null) {
                     for (Object instance : instances) {
                         INeutronPortAware service = (INeutronPortAware) instance;
                         int status = service.canCreatePort(test);
-                        if (status < 200 || status > 299)
+                        if (status < 200 || status > 299) {
                             return Response.status(status).build();
+                        }
                     }
                 }
                 /*
@@ -302,20 +325,25 @@ public class NeutronPortsNorthbound {
                     Iterator<Neutron_IPs> fixedIPIterator = fixedIPs.iterator();
                     while (fixedIPIterator.hasNext()) {
                         Neutron_IPs ip = fixedIPIterator.next();
-                        if (ip.getSubnetUUID() == null)
+                        if (ip.getSubnetUUID() == null) {
                             return Response.status(400).build();
-                        if (!subnetInterface.subnetExists(ip.getSubnetUUID()))
+                        }
+                        if (!subnetInterface.subnetExists(ip.getSubnetUUID())) {
                             return Response.status(400).build();
+                        }
                         NeutronSubnet subnet = subnetInterface.getSubnet(ip.getSubnetUUID());
-                        if (!test.getNetworkUUID().equalsIgnoreCase(subnet.getNetworkUUID()))
+                        if (!test.getNetworkUUID().equalsIgnoreCase(subnet.getNetworkUUID())) {
                             return Response.status(400).build();
+                        }
                         if (ip.getIpAddress() != null) {
-                            if (!subnet.isValidIP(ip.getIpAddress()))
+                            if (!subnet.isValidIP(ip.getIpAddress())) {
                                 return Response.status(400).build();
+                            }
                             //TODO: need to add consideration for a fixed IP being assigned the same address as a allocated IP in the
                             //same bulk create
-                            if (subnet.isIPInUse(ip.getIpAddress()))
+                            if (subnet.isIPInUse(ip.getIpAddress())) {
                                 return Response.status(409).build();
+                            }
                         }
                     }
                 }
@@ -346,13 +374,13 @@ public class NeutronPortsNorthbound {
     @Consumes({ MediaType.APPLICATION_JSON })
     //@TypeHint(OpenStackPorts.class)
     @StatusCodes({
-            @ResponseCode(code = 200, condition = "Operation successful"),
-            @ResponseCode(code = 400, condition = "Bad Request"),
-            @ResponseCode(code = 401, condition = "Unauthorized"),
-            @ResponseCode(code = 403, condition = "Forbidden"),
-            @ResponseCode(code = 404, condition = "Not Found"),
-            @ResponseCode(code = 409, condition = "Conflict"),
-            @ResponseCode(code = 501, condition = "Not Implemented") })
+        @ResponseCode(code = 200, condition = "Operation successful"),
+        @ResponseCode(code = 400, condition = "Bad Request"),
+        @ResponseCode(code = 401, condition = "Unauthorized"),
+        @ResponseCode(code = 403, condition = "Forbidden"),
+        @ResponseCode(code = 404, condition = "Not Found"),
+        @ResponseCode(code = 409, condition = "Conflict"),
+        @ResponseCode(code = 501, condition = "Not Implemented") })
     public Response updatePort(
             @PathParam("portUUID") String portUUID,
             NeutronPortRequest input
@@ -369,26 +397,30 @@ public class NeutronPortsNorthbound {
         }
 
         // port has to exist and only a single delta is supported
-        if (!portInterface.portExists(portUUID))
+        if (!portInterface.portExists(portUUID)) {
             return Response.status(404).build();
+        }
         NeutronPort target = portInterface.getPort(portUUID);
-        if (!input.isSingleton())
+        if (!input.isSingleton()) {
             return Response.status(400).build();
+        }
         NeutronPort singleton = input.getSingleton();
         NeutronPort original = portInterface.getPort(portUUID);
 
         // deltas restricted by Neutron
         if (singleton.getID() != null || singleton.getTenantID() != null ||
-                singleton.getStatus() != null)
+                singleton.getStatus() != null) {
             return Response.status(400).build();
+        }
 
         Object[] instances = ServiceHelper.getGlobalInstances(INeutronPortAware.class, this, null);
         if (instances != null) {
             for (Object instance : instances) {
                 INeutronPortAware service = (INeutronPortAware) instance;
                 int status = service.canUpdatePort(singleton, original);
-                if (status < 200 || status > 299)
+                if (status < 200 || status > 299) {
                     return Response.status(status).build();
+                }
             }
         }
 
@@ -398,25 +430,30 @@ public class NeutronPortsNorthbound {
             Iterator<Neutron_IPs> fixedIPIterator = fixedIPs.iterator();
             while (fixedIPIterator.hasNext()) {
                 Neutron_IPs ip = fixedIPIterator.next();
-                if (ip.getSubnetUUID() == null)
+                if (ip.getSubnetUUID() == null) {
                     return Response.status(400).build();
-                if (!subnetInterface.subnetExists(ip.getSubnetUUID()))
+                }
+                if (!subnetInterface.subnetExists(ip.getSubnetUUID())) {
                     return Response.status(400).build();
+                }
                 NeutronSubnet subnet = subnetInterface.getSubnet(ip.getSubnetUUID());
-                if (!target.getNetworkUUID().equalsIgnoreCase(subnet.getNetworkUUID()))
+                if (!target.getNetworkUUID().equalsIgnoreCase(subnet.getNetworkUUID())) {
                     return Response.status(400).build();
+                }
                 if (ip.getIpAddress() != null) {
-                    if (!subnet.isValidIP(ip.getIpAddress()))
+                    if (!subnet.isValidIP(ip.getIpAddress())) {
                         return Response.status(400).build();
-                    if (subnet.isIPInUse(ip.getIpAddress()))
+                    }
+                    if (subnet.isIPInUse(ip.getIpAddress())) {
                         return Response.status(409).build();
+                    }
                 }
             }
         }
 
-//        TODO: Support change of security groups
+        //        TODO: Support change of security groups
         // update the port and return the modified object
-        portInterface.updatePort(portUUID, singleton);
+                portInterface.updatePort(portUUID, singleton);
         NeutronPort updatedPort = portInterface.getPort(portUUID);
         if (instances != null) {
             for (Object instance : instances) {
@@ -449,20 +486,23 @@ public class NeutronPortsNorthbound {
         }
 
         // port has to exist and not be owned by anyone.  then it can be removed from the cache
-        if (!portInterface.portExists(portUUID))
+        if (!portInterface.portExists(portUUID)) {
             return Response.status(404).build();
+        }
         NeutronPort port = portInterface.getPort(portUUID);
         if (port.getDeviceID() != null ||
-                port.getDeviceOwner() != null)
+                port.getDeviceOwner() != null) {
             Response.status(403).build();
+        }
         NeutronPort singleton = portInterface.getPort(portUUID);
         Object[] instances = ServiceHelper.getGlobalInstances(INeutronPortAware.class, this, null);
         if (instances != null) {
             for (Object instance : instances) {
                 INeutronPortAware service = (INeutronPortAware) instance;
                 int status = service.canDeletePort(singleton);
-                if (status < 200 || status > 299)
+                if (status < 200 || status > 299) {
                     return Response.status(status).build();
+                }
             }
         }
         portInterface.removePort(portUUID);