From: Ryan Moats Date: Mon, 7 Oct 2013 18:20:06 +0000 (-0500) Subject: Add missing test methods to IRouterAware and clean up unused imports. X-Git-Tag: jenkins-controller-bulk-release-prepare-only-2-1~660 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=615e66d04d9237548ff0cff722f95a36c3b45921 Add missing test methods to IRouterAware and clean up unused imports. Realized that initial Neutron IRouterAware was missing test methods for interface attach and detach operation. In addition, removed unused imports from other classes. Change-Id: I8547ad7e7437d7215151f843744b56b2e0d93197 Signed-off-by: Ryan Moats --- diff --git a/opendaylight/networkconfiguration/neutron/implementation/src/main/java/org/opendaylight/controller/networkconfig/neutron/implementation/NeutronNetworkInterface.java b/opendaylight/networkconfiguration/neutron/implementation/src/main/java/org/opendaylight/controller/networkconfig/neutron/implementation/NeutronNetworkInterface.java index 035e6dc4a8..a2454217a6 100644 --- a/opendaylight/networkconfiguration/neutron/implementation/src/main/java/org/opendaylight/controller/networkconfig/neutron/implementation/NeutronNetworkInterface.java +++ b/opendaylight/networkconfiguration/neutron/implementation/src/main/java/org/opendaylight/controller/networkconfig/neutron/implementation/NeutronNetworkInterface.java @@ -13,7 +13,6 @@ import java.util.ArrayList; import java.util.Dictionary; import java.util.EnumSet; import java.util.HashSet; -import java.util.Iterator; import java.util.List; import java.util.Set; import java.util.Map.Entry; diff --git a/opendaylight/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/INeutronRouterAware.java b/opendaylight/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/INeutronRouterAware.java index 16a9aec239..040bdd87c4 100644 --- a/opendaylight/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/INeutronRouterAware.java +++ b/opendaylight/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/INeutronRouterAware.java @@ -81,6 +81,20 @@ public interface INeutronRouterAware { */ public void neutronRouterDeleted(NeutronRouter router); + /** + * Services provide this interface method to indicate if the specified interface can be attached to the specified route + * + * @param router + * instance of the base Neutron Router object + * @param routerInterface + * instance of the NeutronRouter_Interface to be attached to the router + * @return integer + * the return value is understood to be a HTTP status code. A return value outside of 200 through 299 + * results in the attach operation being interrupted and the returned status value reflected in the + * HTTP response. + */ + public int canAttachInterface(NeutronRouter router, NeutronRouter_Interface routerInterface); + /** * Services provide this interface method for taking action after an interface has been added to a router * @@ -92,6 +106,20 @@ public interface INeutronRouterAware { */ public void neutronRouterInterfaceAttached(NeutronRouter router, NeutronRouter_Interface routerInterface); + /** + * Services provide this interface method to indicate if the specified interface can be detached from the specified router + * + * @param router + * instance of the base Neutron Router object + * @param routerInterface + * instance of the NeutronRouter_Interface to be detached to the router + * @return integer + * the return value is understood to be a HTTP status code. A return value outside of 200 through 299 + * results in the detach operation being interrupted and the returned status value reflected in the + * HTTP response. + */ + public int canDetachInterface(NeutronRouter router, NeutronRouter_Interface routerInterface); + /** * Services provide this interface method for taking action after an interface has been removed from a router * diff --git a/opendaylight/northbound/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronFloatingIPsNorthbound.java b/opendaylight/northbound/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronFloatingIPsNorthbound.java index 14eaedd63d..6f3ed13c36 100644 --- a/opendaylight/northbound/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronFloatingIPsNorthbound.java +++ b/opendaylight/northbound/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronFloatingIPsNorthbound.java @@ -28,7 +28,6 @@ import org.codehaus.enunciate.jaxrs.StatusCodes; import org.opendaylight.controller.networkconfig.neutron.INeutronFloatingIPAware; import org.opendaylight.controller.networkconfig.neutron.INeutronFloatingIPCRUD; import org.opendaylight.controller.networkconfig.neutron.INeutronNetworkCRUD; -import org.opendaylight.controller.networkconfig.neutron.INeutronPortAware; import org.opendaylight.controller.networkconfig.neutron.INeutronPortCRUD; import org.opendaylight.controller.networkconfig.neutron.INeutronSubnetCRUD; import org.opendaylight.controller.networkconfig.neutron.NeutronFloatingIP; diff --git a/opendaylight/northbound/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronRoutersNorthbound.java b/opendaylight/northbound/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronRoutersNorthbound.java index 0ffb085488..e83d1fe51b 100644 --- a/opendaylight/northbound/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronRoutersNorthbound.java +++ b/opendaylight/northbound/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronRoutersNorthbound.java @@ -26,7 +26,6 @@ import javax.ws.rs.core.Response; import org.codehaus.enunciate.jaxrs.ResponseCode; import org.codehaus.enunciate.jaxrs.StatusCodes; import org.opendaylight.controller.networkconfig.neutron.INeutronNetworkCRUD; -import org.opendaylight.controller.networkconfig.neutron.INeutronPortAware; import org.opendaylight.controller.networkconfig.neutron.INeutronPortCRUD; import org.opendaylight.controller.networkconfig.neutron.INeutronRouterAware; import org.opendaylight.controller.networkconfig.neutron.INeutronRouterCRUD; @@ -36,7 +35,6 @@ import org.opendaylight.controller.networkconfig.neutron.NeutronPort; import org.opendaylight.controller.networkconfig.neutron.NeutronRouter; import org.opendaylight.controller.networkconfig.neutron.NeutronRouter_Interface; import org.opendaylight.controller.networkconfig.neutron.NeutronSubnet; -import org.opendaylight.controller.networkconfig.neutron.Neutron_IPs; import org.opendaylight.controller.northbound.commons.RestMessages; import org.opendaylight.controller.northbound.commons.exception.ServiceUnavailableException; import org.opendaylight.controller.sal.utils.ServiceHelper; @@ -416,12 +414,19 @@ public class NeutronRoutersNorthbound { targetPort.getDeviceOwner() != null) return Response.status(409).build(); + Object[] instances = ServiceHelper.getGlobalInstances(INeutronRouterAware.class, this, null); + if (instances != null) { + for (Object instance : instances) { + INeutronRouterAware service = (INeutronRouterAware) instance; + service.canAttachInterface(target, input); + } + } + //mark the port device id and device owner fields targetPort.setDeviceOwner("network:router_interface"); targetPort.setDeviceID(routerUUID); target.addInterface(input.getPortUUID(), input); - Object[] instances = ServiceHelper.getGlobalInstances(INeutronRouterAware.class, this, null); if (instances != null) { for (Object instance : instances) { INeutronRouterAware service = (INeutronRouterAware) instance; @@ -485,12 +490,19 @@ public class NeutronRoutersNorthbound { input.setID(target.getID()); input.setTenantID(target.getTenantID()); + Object[] instances = ServiceHelper.getGlobalInstances(INeutronRouterAware.class, this, null); + if (instances != null) { + for (Object instance : instances) { + INeutronRouterAware service = (INeutronRouterAware) instance; + service.canDetachInterface(target, input); + } + } + // reset the port ownership port.setDeviceID(null); port.setDeviceOwner(null); target.removeInterface(input.getPortUUID()); - Object[] instances = ServiceHelper.getGlobalInstances(INeutronRouterAware.class, this, null); if (instances != null) { for (Object instance : instances) { INeutronRouterAware service = (INeutronRouterAware) instance; @@ -535,10 +547,16 @@ public class NeutronRoutersNorthbound { return Response.status(409).build(); input.setID(target.getID()); input.setTenantID(target.getTenantID()); + Object[] instances = ServiceHelper.getGlobalInstances(INeutronRouterAware.class, this, null); + if (instances != null) { + for (Object instance : instances) { + INeutronRouterAware service = (INeutronRouterAware) instance; + service.canDetachInterface(target, input); + } + } port.setDeviceID(null); port.setDeviceOwner(null); target.removeInterface(input.getPortUUID()); - Object[] instances = ServiceHelper.getGlobalInstances(INeutronRouterAware.class, this, null); for (Object instance : instances) { INeutronRouterAware service = (INeutronRouterAware) instance; service.neutronRouterInterfaceDetached(target, input); diff --git a/opendaylight/northbound/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronSubnetsNorthbound.java b/opendaylight/northbound/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronSubnetsNorthbound.java index 1aaee93cea..e73afb8a99 100644 --- a/opendaylight/northbound/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronSubnetsNorthbound.java +++ b/opendaylight/northbound/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronSubnetsNorthbound.java @@ -27,11 +27,9 @@ import javax.ws.rs.core.Response; import org.codehaus.enunciate.jaxrs.ResponseCode; import org.codehaus.enunciate.jaxrs.StatusCodes; -import org.opendaylight.controller.networkconfig.neutron.INeutronNetworkAware; import org.opendaylight.controller.networkconfig.neutron.INeutronNetworkCRUD; import org.opendaylight.controller.networkconfig.neutron.INeutronSubnetAware; import org.opendaylight.controller.networkconfig.neutron.INeutronSubnetCRUD; -import org.opendaylight.controller.networkconfig.neutron.NeutronNetwork; import org.opendaylight.controller.networkconfig.neutron.NeutronSubnet; import org.opendaylight.controller.northbound.commons.RestMessages; import org.opendaylight.controller.northbound.commons.exception.ServiceUnavailableException;