From a1a278f0895ae295f6c3a84240f7a8b7cfe452eb Mon Sep 17 00:00:00 2001 From: Ryan Moats Date: Wed, 22 Jul 2015 20:54:21 -0500 Subject: [PATCH] Make NN more transparent, part I This is the first patch in a series to make NN more transparent. Invoking DRY, this patch removes all checks that Neutron performs. Change-Id: If2493267dfbeaf278420cc443d6ae7d29384b743 Signed-off-by: Ryan Moats --- .../api/NeutronFirewallNorthbound.java | 64 +------- .../api/NeutronFirewallPolicyNorthbound.java | 65 +------- .../api/NeutronFirewallRulesNorthbound.java | 70 +------- .../api/NeutronFloatingIPsNorthbound.java | 153 +----------------- ...onLoadBalancerHealthMonitorNorthbound.java | 64 +------- ...NeutronLoadBalancerListenerNorthbound.java | 61 +------ .../api/NeutronLoadBalancerNorthbound.java | 58 +------ ...tronLoadBalancerPoolMembersNorthbound.java | 47 +----- .../NeutronLoadBalancerPoolNorthbound.java | 60 +------ .../NeutronMeteringLabelRulesNorthbound.java | 12 -- .../api/NeutronMeteringLabelsNorthbound.java | 12 -- .../api/NeutronNetworksNorthbound.java | 48 +----- .../api/NeutronPortsNorthbound.java | 147 +---------------- .../api/NeutronRoutersNorthbound.java | 98 ----------- .../api/NeutronSecurityGroupsNorthbound.java | 49 +----- .../api/NeutronSecurityRulesNorthbound.java | 64 +------- .../api/NeutronSubnetsNorthbound.java | 77 +-------- .../api/NeutronVPNIKEPoliciesNorthbound.java | 28 ---- .../NeutronVPNIPSECPoliciesNorthbound.java | 28 ---- ...tronVPNIPSECSiteConnectionsNorthbound.java | 32 ---- .../api/NeutronVPNServicesNorthbound.java | 54 +------ 21 files changed, 37 insertions(+), 1254 deletions(-) diff --git a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronFirewallNorthbound.java b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronFirewallNorthbound.java index a4c483797..8c9d73c02 100644 --- a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronFirewallNorthbound.java +++ b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronFirewallNorthbound.java @@ -103,11 +103,8 @@ public class NeutronFirewallNorthbound { // sorting not supported ) { INeutronFirewallCRUD firewallInterface = getNeutronInterfaces().getFirewallInterface(); - List allFirewalls = firewallInterface.getAllNeutronFirewalls(); List ans = new ArrayList(); - Iterator i = allFirewalls.iterator(); - while (i.hasNext()) { - NeutronFirewall nsg = i.next(); + for (NeutronFirewall nsg : firewallInterface.getAllNeutronFirewalls()) { if ((queryFirewallUUID == null || queryFirewallUUID.equals(nsg.getFirewallUUID())) && (queryFirewallTenantID == null || @@ -184,13 +181,6 @@ public class NeutronFirewallNorthbound { if (input.isSingleton()) { NeutronFirewall singleton = input.getSingleton(); - /* - * Verify that the Firewall doesn't already exist. - */ - if (firewallInterface.neutronFirewallExists(singleton.getFirewallUUID())) { - throw new BadRequestException("Firewall UUID already exists"); - } - firewallInterface.addNeutronFirewall(singleton); Object[] instances = NeutronUtil.getInstances(INeutronFirewallAware.class, this); if (instances != null) { if (instances.length > 0) { @@ -215,22 +205,8 @@ public class NeutronFirewallNorthbound { } } } else { - List bulk = input.getBulk(); - Iterator i = bulk.iterator(); - Map testMap = new HashMap(); Object[] instances = NeutronUtil.getInstances(INeutronFirewallAware.class, this); - while (i.hasNext()) { - NeutronFirewall test = i.next(); - - /* - * Verify that the secruity group doesn't already exist - */ - if (firewallInterface.neutronFirewallExists(test.getFirewallUUID())) { - throw new BadRequestException("Firewall UUID already is already created"); - } - if (testMap.containsKey(test.getFirewallUUID())) { - throw new BadRequestException("Firewall UUID already exists"); - } + for (NeutronFirewall test : input.getBulk()) { if (instances != null) { if (instances.length > 0) { for (Object instance : instances) { @@ -251,9 +227,7 @@ public class NeutronFirewallNorthbound { /* * now, each element of the bulk request can be added to the cache */ - i = bulk.iterator(); - while (i.hasNext()) { - NeutronFirewall test = i.next(); + for (NeutronFirewall test : input.getBulk()) { firewallInterface.addNeutronFirewall(test); if (instances != null) { for (Object instance : instances) { @@ -285,32 +259,9 @@ public class NeutronFirewallNorthbound { @PathParam("firewallUUID") String firewallUUID, final NeutronFirewallRequest input) { INeutronFirewallCRUD firewallInterface = getNeutronInterfaces().getFirewallInterface(); - /* - * verify the Firewall exists and there is only one delta provided - */ - if (!firewallInterface.neutronFirewallExists(firewallUUID)) { - throw new ResourceNotFoundException(UUID_NO_EXIST); - } - if (!input.isSingleton()) { - throw new BadRequestException("Only singleton edit supported"); - } NeutronFirewall delta = input.getSingleton(); NeutronFirewall original = firewallInterface.getNeutronFirewall(firewallUUID); - /* - * updates restricted by Neutron - */ - if (delta.getFirewallUUID() != null || - delta.getFirewallTenantID() != null || - delta.getFirewallName() != null || - delta.getFirewallDescription() != null || - delta.getFirewallAdminStateIsUp() != null || - delta.getFirewallStatus() != null || - delta.getFirewallIsShared() != null || - delta.getFirewallPolicyID() != null) { - throw new BadRequestException("Attribute edit blocked by Neutron"); - } - Object[] instances = NeutronUtil.getInstances(INeutronFirewallAware.class, this); if (instances != null) { if (instances.length > 0) { @@ -358,15 +309,6 @@ public class NeutronFirewallNorthbound { @PathParam("firewallUUID") String firewallUUID) { INeutronFirewallCRUD firewallInterface = getNeutronInterfaces().getFirewallInterface(); - /* - * verify the Firewall exists and it isn't currently in use - */ - if (!firewallInterface.neutronFirewallExists(firewallUUID)) { - throw new ResourceNotFoundException(UUID_NO_EXIST); - } - if (firewallInterface.neutronFirewallInUse(firewallUUID)) { - return Response.status(HttpURLConnection.HTTP_CONFLICT).build(); - } NeutronFirewall singleton = firewallInterface.getNeutronFirewall(firewallUUID); Object[] instances = NeutronUtil.getInstances(INeutronFirewallAware.class, this); if (instances != null) { diff --git a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronFirewallPolicyNorthbound.java b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronFirewallPolicyNorthbound.java index 57d785c2f..7cec7ee39 100644 --- a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronFirewallPolicyNorthbound.java +++ b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronFirewallPolicyNorthbound.java @@ -103,11 +103,8 @@ public class NeutronFirewallPolicyNorthbound { // sorting not supported ) { INeutronFirewallPolicyCRUD firewallPolicyInterface = getNeutronInterfaces().getFirewallPolicyInterface(); - List allFirewallPolicies = firewallPolicyInterface.getAllNeutronFirewallPolicies(); List ans = new ArrayList(); - Iterator i = allFirewallPolicies.iterator(); - while (i.hasNext()) { - NeutronFirewallPolicy nsg = i.next(); + for (NeutronFirewallPolicy nsg : firewallPolicyInterface.getAllNeutronFirewallPolicies()) { if ((queryFirewallPolicyUUID == null || queryFirewallPolicyUUID.equals(nsg.getFirewallPolicyUUID())) && (queryFirewallPolicyTenantID == null || @@ -182,14 +179,6 @@ public class NeutronFirewallPolicyNorthbound { if (input.isSingleton()) { NeutronFirewallPolicy singleton = input.getSingleton(); - /* - * Verify that the Firewall Policy doesn't already exist. - */ - if (firewallPolicyInterface.neutronFirewallPolicyExists(singleton.getFirewallPolicyUUID())) { - throw new BadRequestException("Firewall Policy UUID already exists"); - } - firewallPolicyInterface.addNeutronFirewallPolicy(singleton); - Object[] instances = NeutronUtil.getInstances(INeutronFirewallPolicyAware.class, this); if (instances != null) { if (instances.length > 0) { @@ -214,23 +203,8 @@ public class NeutronFirewallPolicyNorthbound { } } } else { - List bulk = input.getBulk(); - Iterator i = bulk.iterator(); - Map testMap = new HashMap(); Object[] instances = NeutronUtil.getInstances(INeutronFirewallPolicyAware.class, this); - while (i.hasNext()) { - NeutronFirewallPolicy test = i.next(); - - /* - * Verify that the firewall policy doesn't already exist - */ - - if (firewallPolicyInterface.neutronFirewallPolicyExists(test.getFirewallPolicyUUID())) { - throw new BadRequestException("Firewall Policy UUID already is already created"); - } - if (testMap.containsKey(test.getFirewallPolicyUUID())) { - throw new BadRequestException("Firewall Policy UUID already exists"); - } + for (NeutronFirewallPolicy test : input.getBulk()) { if (instances != null) { if (instances.length > 0) { for (Object instance : instances) { @@ -250,9 +224,7 @@ public class NeutronFirewallPolicyNorthbound { /* * now, each element of the bulk request can be added to the cache */ - i = bulk.iterator(); - while (i.hasNext()) { - NeutronFirewallPolicy test = i.next(); + for (NeutronFirewallPolicy test : input.getBulk()) { firewallPolicyInterface.addNeutronFirewallPolicy(test); if (instances != null) { for (Object instance : instances) { @@ -285,31 +257,9 @@ public class NeutronFirewallPolicyNorthbound { @PathParam("firewallPolicyUUID") String firewallPolicyUUID, final NeutronFirewallPolicyRequest input) { INeutronFirewallPolicyCRUD firewallPolicyInterface = getNeutronInterfaces().getFirewallPolicyInterface(); - /* - * verify the Firewall Policy exists and there is only one delta provided - */ - if (!firewallPolicyInterface.neutronFirewallPolicyExists(firewallPolicyUUID)) { - throw new ResourceNotFoundException(UUID_NO_EXIST); - } - if (!input.isSingleton()) { - throw new BadRequestException("Only singleton edit supported"); - } NeutronFirewallPolicy delta = input.getSingleton(); NeutronFirewallPolicy original = firewallPolicyInterface.getNeutronFirewallPolicy(firewallPolicyUUID); - /* - * updates restricted by Neutron - */ - if (delta.getFirewallPolicyUUID() != null || - delta.getFirewallPolicyTenantID() != null || - delta.getFirewallPolicyName() != null || - delta.getFirewallPolicyDescription() != null || - delta.getFirewallPolicyIsShared() != null || - delta.getFirewallPolicyRules().size() > 0 || - delta.getFirewallPolicyIsAudited() != null) { - throw new BadRequestException("Attribute edit blocked by Neutron"); - } - Object[] instances = NeutronUtil.getInstances(INeutronFirewallPolicyAware.class, this); if (instances != null) { if (instances.length > 0) { @@ -357,15 +307,6 @@ public class NeutronFirewallPolicyNorthbound { @PathParam("firewallPolicyUUID") String firewallPolicyUUID) { INeutronFirewallPolicyCRUD firewallPolicyInterface = getNeutronInterfaces().getFirewallPolicyInterface(); - /* - * verify the Firewall Policy exists and it isn't currently in use - */ - if (!firewallPolicyInterface.neutronFirewallPolicyExists(firewallPolicyUUID)) { - throw new ResourceNotFoundException(UUID_NO_EXIST); - } - if (firewallPolicyInterface.neutronFirewallPolicyInUse(firewallPolicyUUID)) { - return Response.status(HttpURLConnection.HTTP_CONFLICT).build(); - } NeutronFirewallPolicy singleton = firewallPolicyInterface.getNeutronFirewallPolicy(firewallPolicyUUID); Object[] instances = NeutronUtil.getInstances(INeutronFirewallPolicyAware.class, this); if (instances != null) { diff --git a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronFirewallRulesNorthbound.java b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronFirewallRulesNorthbound.java index bc8695b5c..acb8289aa 100644 --- a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronFirewallRulesNorthbound.java +++ b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronFirewallRulesNorthbound.java @@ -113,11 +113,8 @@ public class NeutronFirewallRulesNorthbound { // sorting not supported ) { INeutronFirewallRuleCRUD firewallRuleInterface = getNeutronInterfaces().getFirewallRuleInterface(); - List allFirewallRules = firewallRuleInterface.getAllNeutronFirewallRules(); List ans = new ArrayList(); - Iterator i = allFirewallRules.iterator(); - while (i.hasNext()) { - NeutronFirewallRule nsr = i.next(); + for (NeutronFirewallRule nsr : firewallRuleInterface.getAllNeutronFirewallRules()) { if ((queryFirewallRuleUUID == null || queryFirewallRuleUUID.equals(nsr.getFirewallRuleUUID())) && (queryFirewallRuleTenantID == null || @@ -215,10 +212,6 @@ public class NeutronFirewallRulesNorthbound { if (input.isSingleton()) { NeutronFirewallRule singleton = input.getSingleton(); - if (firewallRuleInterface.neutronFirewallRuleExists(singleton.getFirewallRuleUUID())) { - throw new BadRequestException(UUID_EXISTS); - } - firewallRuleInterface.addNeutronFirewallRule(singleton); Object[] instances = NeutronUtil.getInstances(INeutronFirewallRuleAware.class, this); if (instances != null) { if (instances.length > 0) { @@ -245,23 +238,9 @@ public class NeutronFirewallRulesNorthbound { } } } else { - List bulk = input.getBulk(); - Iterator i = bulk.iterator(); Map testMap = new HashMap(); Object[] instances = NeutronUtil.getInstances(INeutronFirewallRuleAware.class, this); - while (i.hasNext()) { - NeutronFirewallRule test = i.next(); - - /* - * Verify that the Firewall rule doesn't already exist - */ - - if (firewallRuleInterface.neutronFirewallRuleExists(test.getFirewallRuleUUID())) { - throw new BadRequestException(UUID_EXISTS); - } - if (testMap.containsKey(test.getFirewallRuleUUID())) { - throw new BadRequestException(UUID_EXISTS); - } + for (NeutronFirewallRule test : input.getBulk()) { if (instances != null) { if (instances.length > 0) { for (Object instance : instances) { @@ -278,12 +257,7 @@ public class NeutronFirewallRulesNorthbound { throw new ServiceUnavailableException(NO_PROVIDER_LIST); } } - /* - * now, each element of the bulk request can be added to the cache - */ - i = bulk.iterator(); - while (i.hasNext()) { - NeutronFirewallRule test = i.next(); + for (NeutronFirewallRule test : input.getBulk()) { firewallRuleInterface.addNeutronFirewallRule(test); if (instances != null) { for (Object instance : instances) { @@ -314,41 +288,12 @@ public class NeutronFirewallRulesNorthbound { public Response updateFirewallRule( @PathParam("firewallRuleUUID") String firewallRuleUUID, final NeutronFirewallRuleRequest input) { INeutronFirewallRuleCRUD firewallRuleInterface = getNeutronInterfaces().getFirewallRuleInterface(); - /* - * verify the Firewall Rule exists - */ - if (!firewallRuleInterface.neutronFirewallRuleExists(firewallRuleUUID)) { - throw new ResourceNotFoundException(UUID_NO_EXIST); - } if (!input.isSingleton()) { throw new BadRequestException("Only singleton edit supported"); } NeutronFirewallRule delta = input.getSingleton(); NeutronFirewallRule original = firewallRuleInterface.getNeutronFirewallRule(firewallRuleUUID); - /* - * updates restricted by Neutron - * - */ - if (delta.getFirewallRuleUUID() != null || - delta.getFirewallRuleTenantID() != null || - delta.getFirewallRuleName() != null || - delta.getFirewallRuleDescription() != null || - delta.getFirewallRuleStatus() != null || - delta.getFirewallRuleIsShared() != null || - delta.getFirewallRulePolicyID() != null || - delta.getFirewallRuleProtocol() != null || - delta.getFirewallRuleIpVer() != null || - delta.getFirewallRuleSrcIpAddr() != null || - delta.getFirewallRuleDstIpAddr() != null || - delta.getFirewallRuleSrcPort() != null || - delta.getFirewallRuleDstPort() != null || - delta.getFirewallRulePosition() != null || - delta.getFirewallRuleAction() != null || - delta.getFirewallRuleIsEnabled() != null) { - throw new BadRequestException("Attribute edit blocked by Neutron"); - } - Object[] instances = NeutronUtil.getInstances(INeutronFirewallRuleAware.class, this); if (instances != null) { if (instances.length > 0) { @@ -399,15 +344,6 @@ public class NeutronFirewallRulesNorthbound { @PathParam("firewallRuleUUID") String firewallRuleUUID) { INeutronFirewallRuleCRUD firewallRuleInterface = getNeutronInterfaces().getFirewallRuleInterface(); - /* - * verify the Firewall Rule exists and it isn't currently in use - */ - if (!firewallRuleInterface.neutronFirewallRuleExists(firewallRuleUUID)) { - throw new ResourceNotFoundException(UUID_NO_EXIST); - } - if (firewallRuleInterface.neutronFirewallRuleInUse(firewallRuleUUID)) { - return Response.status(HttpURLConnection.HTTP_CONFLICT).build(); - } NeutronFirewallRule singleton = firewallRuleInterface.getNeutronFirewallRule(firewallRuleUUID); Object[] instances = NeutronUtil.getInstances(INeutronFirewallRuleAware.class, this); if (instances != null) { diff --git a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronFloatingIPsNorthbound.java b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronFloatingIPsNorthbound.java index b67a4c6ee..856376484 100644 --- a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronFloatingIPsNorthbound.java +++ b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronFloatingIPsNorthbound.java @@ -214,84 +214,12 @@ public class NeutronFloatingIPsNorthbound { INeutronSubnetCRUD subnetInterface = interfaces.getSubnetInterface(); INeutronPortCRUD portInterface = interfaces.getPortInterface(); if (input.isSingleton()) { - NeutronFloatingIP singleton = input.getSingleton(); - // check existence of id in cache and return badrequest if exists - if (floatingIPInterface.floatingIPExists(singleton.getID())) { - throw new BadRequestException("Floating IP UUID already exists."); - } - // check if the external network is specified, exists, and is an external network - String externalNetworkUUID = singleton.getFloatingNetworkUUID(); - if (externalNetworkUUID == null) { - throw new BadRequestException("external network UUID doesn't exist."); - } - if (!networkInterface.networkExists(externalNetworkUUID)) { - throw new BadRequestException("external network UUID doesn't exist."); - } - NeutronNetwork externNetwork = networkInterface.getNetwork(externalNetworkUUID); - if (!externNetwork.isRouterExternal()) { - throw new BadRequestException("external network isn't marked router:external"); - } - // if floating IP is specified, make sure it can come from the network - String floatingIP = singleton.getFloatingIPAddress(); - if (floatingIP != null) { - if (!isIpV4Network(externNetwork, subnetInterface)) { - throw new BadRequestException("external network doesn't have a ipv4 subnet"); - } - NeutronSubnet externSubnet = subnetInterface.getSubnet(externNetwork.getSubnets().get(0)); - if (!externSubnet.isValidIP(floatingIP)) { - throw new BadRequestException("external IP isn't valid for the specified subnet."); - } - if (externSubnet.getFloatingIpPortsInSubnet(floatingIP).isEmpty() && externSubnet.isIPInUse(floatingIP)) { - throw new ResourceConflictException("floating IP is in use."); - } - } - // if port_id is specified, then check that the port exists and has at least one IP - String port_id = singleton.getPortUUID(); - if (port_id != null) { - String fixedIP = null; - if (!portInterface.portExists(port_id)) { - throw new ResourceNotFoundException("Port UUID doesn't exist."); - } - NeutronPort port = portInterface.getPort(port_id); - if (port.getFixedIPs().size() < 1) { - throw new BadRequestException("port UUID doesn't have an IP address."); - } - // if there is more than one fixed IP then check for fixed_ip_address - // and that it is in the list of port addresses - if (port.getFixedIPs().size() > 1) { - fixedIP = singleton.getFixedIPAddress(); - if (fixedIP == null) { - throw new BadRequestException("fixed IP address doesn't exist."); - } - Iterator i = port.getFixedIPs().iterator(); - boolean validFixedIP = false; - while (i.hasNext() && !validFixedIP) { - Neutron_IPs ip = i.next(); - if (ip.getIpAddress().equals(fixedIP)) { - validFixedIP = true; - } - } - if (!validFixedIP) { - throw new BadRequestException("can't find a valid fixed IP address"); - } - } else { - fixedIP = port.getFixedIPs().get(0).getIpAddress(); - if (singleton.getFixedIPAddress() != null && !fixedIP.equalsIgnoreCase(singleton.getFixedIPAddress())) { - throw new BadRequestException("mismatched fixed IP address in request"); - } - } - //lastly check that this fixed IP address isn't already used - if (port.isBoundToFloatingIP(fixedIP)) { - throw new ResourceConflictException("fixed IP is in use."); - } - singleton.setFixedIPAddress(fixedIP); - } Object[] instances = NeutronUtil.getInstances(INeutronFloatingIPAware.class, this); if (instances != null) { if (instances.length > 0) { for (Object instance : instances) { INeutronFloatingIPAware service = (INeutronFloatingIPAware) instance; - int status = service.canCreateFloatingIP(singleton); + int status = service.canCreateFloatingIP(input.getSingleton()); if (status < HTTP_OK_BOTTOM || status > HTTP_OK_TOP) { return Response.status(status).build(); } @@ -302,11 +230,11 @@ public class NeutronFloatingIPsNorthbound { } else { throw new ServiceUnavailableException(NO_PROVIDER_LIST); } - floatingIPInterface.addFloatingIP(singleton); + floatingIPInterface.addFloatingIP(input.getSingleton()); if (instances != null) { for (Object instance : instances) { INeutronFloatingIPAware service = (INeutronFloatingIPAware) instance; - service.neutronFloatingIPCreated(singleton); + service.neutronFloatingIPCreated(input.getSingleton()); } } } else { @@ -339,79 +267,8 @@ public class NeutronFloatingIPsNorthbound { INeutronNetworkCRUD networkInterface = interfaces.getNetworkInterface(); INeutronSubnetCRUD subnetInterface = interfaces.getSubnetInterface(); INeutronPortCRUD portInterface = interfaces.getPortInterface(); - if (!floatingIPInterface.floatingIPExists(floatingipUUID)) { - throw new ResourceNotFoundException(UUID_NO_EXIST); - } - NeutronFloatingIP sourceFloatingIP = floatingIPInterface.getFloatingIP(floatingipUUID); - if (!input.isSingleton()) { - throw new BadRequestException("only singleton requests allowed."); - } NeutronFloatingIP singleton = input.getSingleton(); - if (singleton.getID() == null) { - throw new BadRequestException("singleton UUID doesn't exist."); - } - - NeutronNetwork externNetwork = networkInterface.getNetwork( - sourceFloatingIP.getFloatingNetworkUUID()); - - // if floating IP is specified, make sure it can come from the network - String floatingIP = singleton.getFloatingIPAddress(); - if (floatingIP != null) { - if (!isIpV4Network(externNetwork, subnetInterface)) { - throw new BadRequestException("external network doesn't have any ipv4 subnet."); - } - NeutronSubnet externSubnet = subnetInterface.getSubnet(externNetwork.getSubnets().get(0)); - if (!externSubnet.isValidIP(floatingIP)) { - throw new BadRequestException("floating IP not valid for external subnet"); - } - if (externSubnet.isIPInUse(floatingIP)) { - throw new ResourceConflictException("floating IP is in use."); - } - } - - // if port_id is specified, then check that the port exists and has at least one IP - String port_id = singleton.getPortUUID(); - if (port_id != null) { - String fixedIP = null; - if (!portInterface.portExists(port_id)) { - throw new ResourceNotFoundException("Port UUID doesn't exist."); - } - NeutronPort port = portInterface.getPort(port_id); - if (port.getFixedIPs().size() < 1) { - throw new BadRequestException("port ID doesn't have a fixed IP address."); - } - // if there is more than one fixed IP then check for fixed_ip_address - // and that it is in the list of port addresses - if (port.getFixedIPs().size() > 1) { - fixedIP = singleton.getFixedIPAddress(); - if (fixedIP == null) { - throw new BadRequestException("request doesn't have a fixed IP address"); - } - Iterator i = port.getFixedIPs().iterator(); - boolean validFixedIP = false; - while (i.hasNext() && !validFixedIP) { - Neutron_IPs ip = i.next(); - if (ip.getIpAddress().equals(fixedIP)) { - validFixedIP = true; - } - } - if (!validFixedIP) { - throw new BadRequestException("couldn't find a valid fixed IP address"); - } - } else { - fixedIP = port.getFixedIPs().get(0).getIpAddress(); - if (singleton.getFixedIPAddress() != null && - !fixedIP.equalsIgnoreCase(singleton.getFixedIPAddress())) { - throw new BadRequestException("mismatch in fixed IP addresses"); - } - } - //lastly check that this fixed IP address isn't already used - if (port.isBoundToFloatingIP(fixedIP)) { - throw new ResourceConflictException("fixed IP is in use."); - } - singleton.setFixedIPAddress(fixedIP); - } NeutronFloatingIP target = floatingIPInterface.getFloatingIP(floatingipUUID); Object[] instances = NeutronUtil.getInstances(INeutronFloatingIPAware.class, this); if (instances != null) { @@ -456,10 +313,6 @@ public class NeutronFloatingIPsNorthbound { public Response deleteFloatingIP( @PathParam("floatingipUUID") String floatingipUUID) { INeutronFloatingIPCRUD floatingIPInterface = getNeutronInterfaces(false).getFloatingIPInterface(); - if (!floatingIPInterface.floatingIPExists(floatingipUUID)) { - throw new ResourceNotFoundException(UUID_NO_EXIST); - } - // TODO: need to undo port association if it exists NeutronFloatingIP singleton = floatingIPInterface.getFloatingIP(floatingipUUID); Object[] instances = NeutronUtil.getInstances(INeutronFloatingIPAware.class, this); if (instances != null) { diff --git a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronLoadBalancerHealthMonitorNorthbound.java b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronLoadBalancerHealthMonitorNorthbound.java index 823bd5b0a..a8ebe5c72 100644 --- a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronLoadBalancerHealthMonitorNorthbound.java +++ b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronLoadBalancerHealthMonitorNorthbound.java @@ -201,13 +201,6 @@ public class NeutronLoadBalancerHealthMonitorNorthbound { if (input.isSingleton()) { NeutronLoadBalancerHealthMonitor singleton = input.getSingleton(); - /* - * Verify that the LoadBalancerHealthMonitor doesn't already exist. - */ - if (loadBalancerHealthMonitorInterface.neutronLoadBalancerHealthMonitorExists(singleton.getLoadBalancerHealthMonitorID())) { - throw new BadRequestException("LoadBalancerHealthMonitor UUID already exists"); - } - Object[] instances = NeutronUtil.getInstances(INeutronLoadBalancerHealthMonitorAware.class, this); if (instances != null) { if (instances.length > 0) { @@ -232,24 +225,8 @@ public class NeutronLoadBalancerHealthMonitorNorthbound { } } } else { - List bulk = input.getBulk(); - Iterator i = bulk.iterator(); - Map testMap = new HashMap(); Object[] instances = NeutronUtil.getInstances(INeutronLoadBalancerHealthMonitorAware.class, this); - while (i.hasNext()) { - NeutronLoadBalancerHealthMonitor test = i.next(); - - /* - * Verify that the firewall policy doesn't already exist - */ - - if (loadBalancerHealthMonitorInterface - .neutronLoadBalancerHealthMonitorExists(test.getLoadBalancerHealthMonitorID())) { - throw new BadRequestException("LoadBalancerHealthMonitor UUID already is already created"); - } - if (testMap.containsKey(test.getLoadBalancerHealthMonitorID())) { - throw new BadRequestException("LoadBalancerHealthMonitor UUID already exists"); - } + for (NeutronLoadBalancerHealthMonitor test : input.getBulk()) { if (instances != null) { if (instances.length > 0) { for (Object instance : instances) { @@ -269,9 +246,7 @@ public class NeutronLoadBalancerHealthMonitorNorthbound { /* * now, each element of the bulk request can be added to the cache */ - i = bulk.iterator(); - while (i.hasNext()) { - NeutronLoadBalancerHealthMonitor test = i.next(); + for (NeutronLoadBalancerHealthMonitor test : input.getBulk()) { loadBalancerHealthMonitorInterface.addNeutronLoadBalancerHealthMonitor(test); if (instances != null) { for (Object instance : instances) { @@ -304,35 +279,10 @@ public class NeutronLoadBalancerHealthMonitorNorthbound { final NeutronLoadBalancerHealthMonitorRequest input) { INeutronLoadBalancerHealthMonitorCRUD loadBalancerHealthMonitorInterface = getNeutronInterfaces().getLoadBalancerHealthMonitorInterface(); - /* - * verify the LoadBalancerHealthMonitor exists and there is only one delta provided - */ - if (!loadBalancerHealthMonitorInterface.neutronLoadBalancerHealthMonitorExists(loadBalancerHealthMonitorID)) { - throw new ResourceNotFoundException(UUID_NO_EXIST); - } - if (!input.isSingleton()) { - throw new BadRequestException("Only singleton edit supported"); - } NeutronLoadBalancerHealthMonitor delta = input.getSingleton(); NeutronLoadBalancerHealthMonitor original = loadBalancerHealthMonitorInterface .getNeutronLoadBalancerHealthMonitor(loadBalancerHealthMonitorID); - /* - * updates restricted by Neutron - */ - if (delta.getLoadBalancerHealthMonitorID() != null || - delta.getLoadBalancerHealthMonitorTenantID() != null || - delta.getLoadBalancerHealthMonitorType() != null || - delta.getLoadBalancerHealthMonitorDelay() != null || - delta.getLoadBalancerHealthMonitorTimeout() != null || - delta.getLoadBalancerHealthMonitorMaxRetries() != null || - delta.getLoadBalancerHealthMonitorHttpMethod() != null || - delta.getLoadBalancerHealthMonitorUrlPath() != null || - delta.getLoadBalancerHealthMonitorExpectedCodes() != null || - delta.getLoadBalancerHealthMonitorAdminStateIsUp() != null) { - throw new BadRequestException("Attribute edit blocked by Neutron"); - } - Object[] instances = NeutronUtil.getInstances(INeutronLoadBalancerHealthMonitorAware.class, this); if (instances != null) { if (instances.length > 0) { @@ -384,16 +334,8 @@ public class NeutronLoadBalancerHealthMonitorNorthbound { public Response deleteLoadBalancerHealthMonitor( @PathParam("loadBalancerHealthMonitorID") String loadBalancerHealthMonitorID) { INeutronLoadBalancerHealthMonitorCRUD loadBalancerHealthMonitorInterface = getNeutronInterfaces().getLoadBalancerHealthMonitorInterface(); - /* - * verify the LoadBalancerHealthMonitor exists and it isn't currently in use - */ - if (!loadBalancerHealthMonitorInterface.neutronLoadBalancerHealthMonitorExists(loadBalancerHealthMonitorID)) { - throw new ResourceNotFoundException(UUID_NO_EXIST); - } - if (loadBalancerHealthMonitorInterface.neutronLoadBalancerHealthMonitorInUse(loadBalancerHealthMonitorID)) { - return Response.status(HttpURLConnection.HTTP_CONFLICT).build(); - } NeutronLoadBalancerHealthMonitor singleton = loadBalancerHealthMonitorInterface.getNeutronLoadBalancerHealthMonitor(loadBalancerHealthMonitorID); + Object[] instances = NeutronUtil.getInstances(INeutronLoadBalancerHealthMonitorAware.class, this); if (instances != null) { if (instances.length > 0) { diff --git a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronLoadBalancerListenerNorthbound.java b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronLoadBalancerListenerNorthbound.java index 53f7501b7..42faa4002 100644 --- a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronLoadBalancerListenerNorthbound.java +++ b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronLoadBalancerListenerNorthbound.java @@ -185,14 +185,6 @@ public class NeutronLoadBalancerListenerNorthbound { if (input.isSingleton()) { NeutronLoadBalancerListener singleton = input.getSingleton(); - /* - * Verify that the LoadBalancerListener doesn't already exist. - */ - if (loadBalancerListenerInterface.neutronLoadBalancerListenerExists(singleton.getLoadBalancerListenerID())) { - throw new BadRequestException("LoadBalancerListener UUID already exists"); - } - loadBalancerListenerInterface.addNeutronLoadBalancerListener(singleton); - Object[] instances = NeutronUtil.getInstances(INeutronLoadBalancerListenerAware.class, this); if (instances != null) { if (instances.length > 0) { @@ -217,23 +209,8 @@ public class NeutronLoadBalancerListenerNorthbound { } } } else { - List bulk = input.getBulk(); - Iterator i = bulk.iterator(); - Map testMap = new HashMap(); Object[] instances = NeutronUtil.getInstances(INeutronLoadBalancerListenerAware.class, this); - while (i.hasNext()) { - NeutronLoadBalancerListener test = i.next(); - - /* - * Verify that the firewall policy doesn't already exist - */ - - if (loadBalancerListenerInterface.neutronLoadBalancerListenerExists(test.getLoadBalancerListenerID())) { - throw new BadRequestException("LoadBalancerListener UUID already is already created"); - } - if (testMap.containsKey(test.getLoadBalancerListenerID())) { - throw new BadRequestException("LoadBalancerListener UUID already exists"); - } + for (NeutronLoadBalancerListener test : input.getBulk()) { if (instances != null) { if (instances.length > 0) { for (Object instance : instances) { @@ -253,9 +230,7 @@ public class NeutronLoadBalancerListenerNorthbound { /* * now, each element of the bulk request can be added to the cache */ - i = bulk.iterator(); - while (i.hasNext()) { - NeutronLoadBalancerListener test = i.next(); + for (NeutronLoadBalancerListener test : input.getBulk()) { loadBalancerListenerInterface.addNeutronLoadBalancerListener(test); if (instances != null) { for (Object instance : instances) { @@ -287,32 +262,9 @@ public class NeutronLoadBalancerListenerNorthbound { @PathParam("loadBalancerListenerID") String loadBalancerListenerID, final NeutronLoadBalancerListenerRequest input) { INeutronLoadBalancerListenerCRUD loadBalancerListenerInterface = getNeutronInterfaces().getLoadBalancerListenerInterface(); - /* - * verify the LoadBalancerListener exists and there is only one delta provided - */ - if (!loadBalancerListenerInterface.neutronLoadBalancerListenerExists(loadBalancerListenerID)) { - throw new ResourceNotFoundException(UUID_NO_EXIST); - } - if (!input.isSingleton()) { - throw new BadRequestException("Only singleton edit supported"); - } NeutronLoadBalancerListener delta = input.getSingleton(); NeutronLoadBalancerListener original = loadBalancerListenerInterface.getNeutronLoadBalancerListener(loadBalancerListenerID); - /* - * updates restricted by Neutron - */ - if (delta.getLoadBalancerListenerID() != null || - delta.getNeutronLoadBalancerListenerDefaultPoolID() != null || - delta.getLoadBalancerListenerTenantID() != null || - delta.getLoadBalancerListenerName() != null || - delta.getLoadBalancerListenerDescription() != null || - delta.getNeutronLoadBalancerListenerProtocol() != null || - delta.getNeutronLoadBalancerListenerProtocolPort() != null || - delta.getLoadBalancerListenerAdminStateIsUp() != null) { - throw new BadRequestException("Attribute edit blocked by Neutron"); - } - Object[] instances = NeutronUtil.getInstances(INeutronLoadBalancerListenerAware.class, this); if (instances != null) { if (instances.length > 0) { @@ -360,15 +312,6 @@ public class NeutronLoadBalancerListenerNorthbound { @PathParam("loadBalancerListenerID") String loadBalancerListenerID) { INeutronLoadBalancerListenerCRUD loadBalancerListenerInterface = getNeutronInterfaces().getLoadBalancerListenerInterface(); - /* - * verify the LoadBalancerListener exists and it isn't currently in use - */ - if (!loadBalancerListenerInterface.neutronLoadBalancerListenerExists(loadBalancerListenerID)) { - throw new ResourceNotFoundException(UUID_NO_EXIST); - } - if (loadBalancerListenerInterface.neutronLoadBalancerListenerInUse(loadBalancerListenerID)) { - return Response.status(HttpURLConnection.HTTP_CONFLICT).build(); - } NeutronLoadBalancerListener singleton = loadBalancerListenerInterface.getNeutronLoadBalancerListener(loadBalancerListenerID); Object[] instances = NeutronUtil.getInstances(INeutronLoadBalancerListenerAware.class, this); if (instances != null) { diff --git a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronLoadBalancerNorthbound.java b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronLoadBalancerNorthbound.java index 1a17bf21c..ca0a40f23 100644 --- a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronLoadBalancerNorthbound.java +++ b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronLoadBalancerNorthbound.java @@ -182,12 +182,6 @@ public class NeutronLoadBalancerNorthbound { if (input.isSingleton()) { NeutronLoadBalancer singleton = input.getSingleton(); - /* - * Verify that the LoadBalancer doesn't already exist. - */ - if (loadBalancerInterface.neutronLoadBalancerExists(singleton.getLoadBalancerID())) { - throw new BadRequestException("LoadBalancer UUID already exists"); - } Object[] instances = NeutronUtil.getInstances(INeutronLoadBalancerAware.class, this); if (instances != null) { if (instances.length > 0) { @@ -213,23 +207,8 @@ public class NeutronLoadBalancerNorthbound { } } } else { - List bulk = input.getBulk(); - Iterator i = bulk.iterator(); - Map testMap = new HashMap(); Object[] instances = NeutronUtil.getInstances(INeutronLoadBalancerAware.class, this); - while (i.hasNext()) { - NeutronLoadBalancer test = i.next(); - - /* - * Verify that the loadbalancer doesn't already exist - */ - - if (loadBalancerInterface.neutronLoadBalancerExists(test.getLoadBalancerID())) { - throw new BadRequestException("Load Balancer Pool UUID already is already created"); - } - if (testMap.containsKey(test.getLoadBalancerID())) { - throw new BadRequestException("Load Balancer Pool UUID already exists"); - } + for (NeutronLoadBalancer test : input.getBulk()) { if (instances != null) { if (instances.length > 0) { for (Object instance : instances) { @@ -249,9 +228,7 @@ public class NeutronLoadBalancerNorthbound { /* * now, each element of the bulk request can be added to the cache */ - i = bulk.iterator(); - while (i.hasNext()) { - NeutronLoadBalancer test = i.next(); + for (NeutronLoadBalancer test : input.getBulk()) { loadBalancerInterface.addNeutronLoadBalancer(test); if (instances != null) { for (Object instance : instances) { @@ -284,31 +261,9 @@ public class NeutronLoadBalancerNorthbound { @PathParam("loadBalancerID") String loadBalancerID, final NeutronLoadBalancerRequest input) { INeutronLoadBalancerCRUD loadBalancerInterface = getNeutronInterfaces().getLoadBalancerInterface(); - /* - * verify the LoadBalancer exists and there is only one delta provided - */ - if (!loadBalancerInterface.neutronLoadBalancerExists(loadBalancerID)) { - throw new ResourceNotFoundException(UUID_NO_EXIST); - } - if (!input.isSingleton()) { - throw new BadRequestException("Only singleton edit supported"); - } NeutronLoadBalancer delta = input.getSingleton(); NeutronLoadBalancer original = loadBalancerInterface.getNeutronLoadBalancer(loadBalancerID); - /* - * updates restricted by Neutron - */ - if (delta.getLoadBalancerID() != null || - delta.getLoadBalancerTenantID() != null || - delta.getLoadBalancerName() != null || - delta.getLoadBalancerDescription() != null || - delta.getLoadBalancerStatus() != null || - delta.getLoadBalancerVipAddress() != null || - delta.getLoadBalancerVipSubnetID() != null) { - throw new BadRequestException("Attribute edit blocked by Neutron"); - } - Object[] instances = NeutronUtil.getInstances(INeutronLoadBalancerAware.class, this); if (instances != null) { if (instances.length > 0) { @@ -358,15 +313,6 @@ public class NeutronLoadBalancerNorthbound { @PathParam("loadBalancerID") String loadBalancerID) { INeutronLoadBalancerCRUD loadBalancerInterface = getNeutronInterfaces().getLoadBalancerInterface(); - /* - * verify the LoadBalancer exists and it isn't currently in use - */ - if (!loadBalancerInterface.neutronLoadBalancerExists(loadBalancerID)) { - throw new ResourceNotFoundException(UUID_NO_EXIST); - } - if (loadBalancerInterface.neutronLoadBalancerInUse(loadBalancerID)) { - return Response.status(HttpURLConnection.HTTP_CONFLICT).build(); - } NeutronLoadBalancer singleton = loadBalancerInterface.getNeutronLoadBalancer(loadBalancerID); Object[] instances = NeutronUtil.getInstances(INeutronLoadBalancerAware.class, this); if (instances != null) { diff --git a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronLoadBalancerPoolMembersNorthbound.java b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronLoadBalancerPoolMembersNorthbound.java index 673acfd65..8dcf7a67b 100644 --- a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronLoadBalancerPoolMembersNorthbound.java +++ b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronLoadBalancerPoolMembersNorthbound.java @@ -21,6 +21,7 @@ import java.util.Map; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.GET; +import javax.ws.rs.POST; import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.PathParam; @@ -171,7 +172,7 @@ public Response showLoadBalancerPoolMember( /** * Adds a Member to an LBaaS Pool member */ -@PUT +@POST @Produces({MediaType.APPLICATION_JSON}) @Consumes({MediaType.APPLICATION_JSON}) @StatusCodes({ @@ -185,10 +186,6 @@ public Response createLoadBalancerPoolMember( final NeutronLoadBalancerPoolMemberRequest input) { INeutronLoadBalancerPoolCRUD loadBalancerPoolInterface = getNeutronInterfaces().getLoadBalancerPoolInterface(); - // Verify that the loadBalancerPool exists, for the member to be added to its cache - if (!loadBalancerPoolInterface.neutronLoadBalancerPoolExists(loadBalancerPoolUUID)) { - throw new ResourceNotFoundException(UUID_NO_EXIST); - } NeutronLoadBalancerPool singletonPool = loadBalancerPoolInterface.getNeutronLoadBalancerPool(loadBalancerPoolUUID); if (input.isSingleton()) { @@ -196,18 +193,6 @@ public Response createLoadBalancerPoolMember( singleton.setPoolID(loadBalancerPoolUUID); String loadBalancerPoolMemberUUID = singleton.getPoolMemberID(); - /* - * Verify that the LoadBalancerPoolMember doesn't already exist. - */ - if (singletonPool.getLoadBalancerPoolMembers() != null) { - List members = singletonPool.getLoadBalancerPoolMembers(); - for (NeutronLoadBalancerPoolMember member: members) { - if (member.getPoolMemberID().equals(loadBalancerPoolMemberUUID)) { - throw new BadRequestException("LoadBalancerPoolMember UUID already exists"); - } - } - } - Object[] instances = NeutronUtil.getInstances(INeutronLoadBalancerPoolMemberAware.class, this); if (instances != null) { if (instances.length > 0) { @@ -238,27 +223,10 @@ public Response createLoadBalancerPoolMember( singletonPool.addLoadBalancerPoolMember(singleton); } else { - List bulk = input.getBulk(); - Iterator i = bulk.iterator(); - Map testMap = new HashMap(); Object[] instances = NeutronUtil.getInstances(INeutronLoadBalancerPoolMemberAware.class, this); - while (i.hasNext()) { - NeutronLoadBalancerPoolMember test = i.next(); + for (NeutronLoadBalancerPoolMember test : input.getBulk()) { String loadBalancerPoolMemberUUID = test.getPoolMemberID(); - /* - * Verify that the LoadBalancerPoolMember doesn't already exist. - */ - List members = singletonPool.getLoadBalancerPoolMembers(); - for (NeutronLoadBalancerPoolMember member: members) { - if (member.getPoolMemberID().equals(loadBalancerPoolMemberUUID)) { - throw new BadRequestException("LoadBalancerPoolMember UUID already exists"); - } - } - - if (testMap.containsKey(test.getPoolMemberID())) { - throw new BadRequestException("Load Balancer PoolMember UUID already exists"); - } if (instances != null) { if (instances.length > 0) { for (Object instance : instances) { @@ -278,9 +246,7 @@ public Response createLoadBalancerPoolMember( /* * now, each element of the bulk request can be added to the cache */ - i = bulk.iterator(); - while (i.hasNext()) { - NeutronLoadBalancerPoolMember test = i.next(); + for (NeutronLoadBalancerPoolMember test : input.getBulk()) { if (instances != null) { for (Object instance : instances) { INeutronLoadBalancerPoolMemberAware service = (INeutronLoadBalancerPoolMemberAware) instance; @@ -335,11 +301,6 @@ public Response deleteLoadBalancerPoolMember( @PathParam("loadBalancerPoolMemberUUID") String loadBalancerPoolMemberUUID) { INeutronLoadBalancerPoolCRUD loadBalancerPoolInterface = getNeutronInterfaces().getLoadBalancerPoolInterface(); - // Verify that the loadBalancerPool exists, for the member to be removed from its cache - if (!loadBalancerPoolInterface.neutronLoadBalancerPoolExists(loadBalancerPoolUUID)) { - throw new ResourceNotFoundException(UUID_NO_EXIST); - } - //Verify that the LB pool member exists NeutronLoadBalancerPoolMember singleton = null; List members = diff --git a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronLoadBalancerPoolNorthbound.java b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronLoadBalancerPoolNorthbound.java index ddcaab730..b279f2274 100644 --- a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronLoadBalancerPoolNorthbound.java +++ b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronLoadBalancerPoolNorthbound.java @@ -195,13 +195,6 @@ public class NeutronLoadBalancerPoolNorthbound { if (input.isSingleton()) { NeutronLoadBalancerPool singleton = input.getSingleton(); - /* - * Verify that the LoadBalancerPool doesn't already exist. - */ - if (loadBalancerPoolInterface.neutronLoadBalancerPoolExists(singleton.getLoadBalancerPoolID())) { - throw new BadRequestException("LoadBalancerPool UUID already exists"); - } - Object[] instances = NeutronUtil.getInstances(INeutronLoadBalancerPoolAware.class, this); if (instances != null) { if (instances.length > 0) { @@ -226,23 +219,9 @@ public class NeutronLoadBalancerPoolNorthbound { } } } else { - List bulk = input.getBulk(); - Iterator i = bulk.iterator(); - Map testMap = new HashMap(); Object[] instances = NeutronUtil.getInstances(INeutronLoadBalancerPoolAware.class, this); - while (i.hasNext()) { - NeutronLoadBalancerPool test = i.next(); - - /* - * Verify that the loadBalancerPool doesn't already exist - */ + for (NeutronLoadBalancerPool test : input.getBulk()) { - if (loadBalancerPoolInterface.neutronLoadBalancerPoolExists(test.getLoadBalancerPoolID())) { - throw new BadRequestException("Load Balancer Pool UUID already is already created"); - } - if (testMap.containsKey(test.getLoadBalancerPoolID())) { - throw new BadRequestException("Load Balancer Pool UUID already exists"); - } if (instances != null) { if (instances.length > 0) { for (Object instance : instances) { @@ -262,9 +241,7 @@ public class NeutronLoadBalancerPoolNorthbound { /* * now, each element of the bulk request can be added to the cache */ - i = bulk.iterator(); - while (i.hasNext()) { - NeutronLoadBalancerPool test = i.next(); + for (NeutronLoadBalancerPool test : input.getBulk()) { loadBalancerPoolInterface.addNeutronLoadBalancerPool(test); if (instances != null) { for (Object instance : instances) { @@ -296,33 +273,9 @@ public class NeutronLoadBalancerPoolNorthbound { @PathParam("loadBalancerPoolID") String loadBalancerPoolID, final NeutronLoadBalancerPoolRequest input) { INeutronLoadBalancerPoolCRUD loadBalancerPoolInterface = getNeutronInterfaces().getLoadBalancerPoolInterface(); - /* - * verify the LoadBalancerPool exists and there is only one delta provided - */ - if (!loadBalancerPoolInterface.neutronLoadBalancerPoolExists(loadBalancerPoolID)) { - throw new ResourceNotFoundException(UUID_NO_EXIST); - } - if (!input.isSingleton()) { - throw new BadRequestException("Only singleton edit supported"); - } NeutronLoadBalancerPool delta = input.getSingleton(); NeutronLoadBalancerPool original = loadBalancerPoolInterface.getNeutronLoadBalancerPool(loadBalancerPoolID); - /* - * updates restricted by Neutron - */ - if (delta.getLoadBalancerPoolID() != null || - delta.getLoadBalancerPoolTenantID() != null || - delta.getLoadBalancerPoolName() != null || - delta.getLoadBalancerPoolDescription() != null || - delta.getLoadBalancerPoolProtocol() != null || - delta.getLoadBalancerPoolLbAlgorithm() != null || - delta.getNeutronLoadBalancerPoolHealthMonitorID() != null || - delta.getLoadBalancerPoolAdminIsStateIsUp() != null || - delta.getLoadBalancerPoolMembers() != null) { - throw new BadRequestException("Attribute edit blocked by Neutron"); - } - Object[] instances = NeutronUtil.getInstances(INeutronLoadBalancerPoolAware.class, this); if (instances != null) { if (instances.length > 0) { @@ -371,15 +324,6 @@ public class NeutronLoadBalancerPoolNorthbound { @PathParam("loadBalancerPoolUUID") String loadBalancerPoolUUID) { INeutronLoadBalancerPoolCRUD loadBalancerPoolInterface = getNeutronInterfaces().getLoadBalancerPoolInterface(); - /* - * verify the LoadBalancerPool exists and it isn't currently in use - */ - if (!loadBalancerPoolInterface.neutronLoadBalancerPoolExists(loadBalancerPoolUUID)) { - throw new ResourceNotFoundException(UUID_NO_EXIST); - } - if (loadBalancerPoolInterface.neutronLoadBalancerPoolInUse(loadBalancerPoolUUID)) { - return Response.status(HttpURLConnection.HTTP_CONFLICT).build(); - } NeutronLoadBalancerPool singleton = loadBalancerPoolInterface.getNeutronLoadBalancerPool(loadBalancerPoolUUID); Object[] instances = NeutronUtil.getInstances(INeutronLoadBalancerPoolAware.class, this); if (instances != null) { diff --git a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronMeteringLabelRulesNorthbound.java b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronMeteringLabelRulesNorthbound.java index b03fe2f47..dbcea8b4e 100644 --- a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronMeteringLabelRulesNorthbound.java +++ b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronMeteringLabelRulesNorthbound.java @@ -167,12 +167,6 @@ public class NeutronMeteringLabelRulesNorthbound { if (input.isSingleton()) { NeutronMeteringLabelRule singleton = input.getSingleton(); - /* - * verify that the meteringLabelRule doesn't already exist (issue: is deeper inspection necessary?) - */ - if (meteringLabelRuleInterface.neutronMeteringLabelRuleExists(singleton.getMeteringLabelRuleUUID())) { - throw new BadRequestException("meteringLabelRule UUID already exists"); - } Object[] instances = NeutronUtil.getInstances(INeutronMeteringLabelRuleAware.class, this); if (instances != null) { if (instances.length > 0) { @@ -226,12 +220,6 @@ public class NeutronMeteringLabelRulesNorthbound { @PathParam("ruleUUID") String ruleUUID) { INeutronMeteringLabelRuleCRUD meteringLabelRuleInterface = getNeutronInterfaces().getMeteringLabelRuleInterface(); - /* - * verify that the meteringLabelRule exists and is not in use before removing it - */ - if (!meteringLabelRuleInterface.neutronMeteringLabelRuleExists(ruleUUID)) { - throw new ResourceNotFoundException("MeteringLabelRule UUID not found"); - } NeutronMeteringLabelRule singleton = meteringLabelRuleInterface.getNeutronMeteringLabelRule(ruleUUID); Object[] instances = NeutronUtil.getInstances(INeutronMeteringLabelRuleAware.class, this); if (instances != null) { diff --git a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronMeteringLabelsNorthbound.java b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronMeteringLabelsNorthbound.java index 4991430a4..47cbd56d3 100644 --- a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronMeteringLabelsNorthbound.java +++ b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronMeteringLabelsNorthbound.java @@ -167,12 +167,6 @@ public class NeutronMeteringLabelsNorthbound { if (input.isSingleton()) { NeutronMeteringLabel singleton = input.getSingleton(); - /* - * verify that the meteringLabel doesn't already exist (issue: is deeper inspection necessary?) - */ - if (meteringLabelInterface.neutronMeteringLabelExists(singleton.getMeteringLabelUUID())) { - throw new BadRequestException("meteringLabel UUID already exists"); - } Object[] instances = NeutronUtil.getInstances(INeutronMeteringLabelAware.class, this); if (instances != null) { if (instances.length > 0) { @@ -226,12 +220,6 @@ public class NeutronMeteringLabelsNorthbound { @PathParam("labelUUID") String labelUUID) { INeutronMeteringLabelCRUD meteringLabelInterface = getNeutronInterfaces().getMeteringLabelInterface(); - /* - * verify that the meteringLabel exists and is not in use before removing it - */ - if (!meteringLabelInterface.neutronMeteringLabelExists(labelUUID)) { - throw new ResourceNotFoundException("MeteringLabel UUID not found"); - } NeutronMeteringLabel singleton = meteringLabelInterface.getNeutronMeteringLabel(labelUUID); Object[] instances = NeutronUtil.getInstances(INeutronMeteringLabelAware.class, this); if (instances != null) { diff --git a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronNetworksNorthbound.java b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronNetworksNorthbound.java index e57d31891..c26788340 100644 --- a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronNetworksNorthbound.java +++ b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronNetworksNorthbound.java @@ -209,13 +209,6 @@ public class NeutronNetworksNorthbound { if (input.isSingleton()) { NeutronNetwork singleton = input.getSingleton(); - /* - * network ID can't already exist - */ - if (networkInterface.networkExists(singleton.getID())) { - throw new BadRequestException(UUID_EXISTS); - } - Object[] instances = NeutronUtil.getInstances(INeutronNetworkAware.class, this); if (instances != null) { if (instances.length > 0) { @@ -244,23 +237,8 @@ public class NeutronNetworksNorthbound { } } else { - List bulk = input.getBulk(); - Iterator i = bulk.iterator(); - Map testMap = new HashMap(); Object[] instances = NeutronUtil.getInstances(INeutronNetworkAware.class, this); - while (i.hasNext()) { - NeutronNetwork test = i.next(); - - /* - * 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())) { - throw new BadRequestException(UUID_EXISTS); - } - if (testMap.containsKey(test.getID())) { - throw new BadRequestException(UUID_EXISTS); - } + for (NeutronNetwork test : input.getBulk()) { if (instances != null) { if (instances.length > 0) { for (Object instance: instances) { @@ -276,13 +254,10 @@ public class NeutronNetworksNorthbound { } else { throw new ServiceUnavailableException(NO_PROVIDER_LIST); } - testMap.put(test.getID(),test); } // now that everything passed, add items to the cache - i = bulk.iterator(); - while (i.hasNext()) { - NeutronNetwork test = i.next(); + for (NeutronNetwork test : input.getBulk()) { test.initDefaults(); networkInterface.addNetwork(test); if (instances != null) { @@ -315,15 +290,6 @@ public class NeutronNetworksNorthbound { ) { INeutronNetworkCRUD networkInterface = getNeutronInterfaces().getNetworkInterface(); - /* - * network has to exist and only a single object is supported - */ - if (!networkInterface.networkExists(netUUID)) { - throw new ResourceNotFoundException(UUID_NO_EXIST); - } - if (!input.isSingleton()) { - throw new BadRequestException("only singleton edits supported"); - } NeutronNetwork updatedObject = input.getSingleton(); /* @@ -380,16 +346,6 @@ public class NeutronNetworksNorthbound { @PathParam("netUUID") String netUUID) { INeutronNetworkCRUD networkInterface = getNeutronInterfaces().getNetworkInterface(); - /* - * network has to exist and not be in use before it can be removed - */ - if (!networkInterface.networkExists(netUUID)) { - throw new ResourceNotFoundException(UUID_NO_EXIST); - } - if (networkInterface.networkInUse(netUUID)) { - throw new ResourceConflictException("Network ID in use"); - } - NeutronNetwork singleton = networkInterface.getNetwork(netUUID); Object[] instances = NeutronUtil.getInstances(INeutronNetworkAware.class, this); if (instances != null) { diff --git a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronPortsNorthbound.java b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronPortsNorthbound.java index ca9304830..9aa3762b1 100644 --- a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronPortsNorthbound.java +++ b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronPortsNorthbound.java @@ -224,58 +224,6 @@ public class NeutronPortsNorthbound { if (input.isSingleton()) { NeutronPort singleton = input.getSingleton(); - /* - * 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) { - throw new BadRequestException("network UUID musy be specified"); - } - if (portInterface.portExists(singleton.getID())) { - throw new BadRequestException(UUID_EXISTS); - } - if (!networkInterface.networkExists(singleton.getNetworkUUID())) { - throw new ResourceNotFoundException("network UUID does not exist."); - } - if (singleton.getMacAddress() == null || - !singleton.getMacAddress().matches(MAC_REGEX)) { - throw new BadRequestException("MAC address not properly formatted"); - } - if (portInterface.macInUse(singleton.getMacAddress())) { - throw new ResourceConflictException("MAC Address is in use."); - } - /* - * if fixed IPs are specified, each one has to have an existing subnet ID - * that is in the same scoping network as the port. In addition, if an IP - * address is specified it has to be a valid address for the subnet and not - * already in use - */ - List fixedIPs = singleton.getFixedIPs(); - if (fixedIPs != null && fixedIPs.size() > 0) { - Iterator fixedIPIterator = fixedIPs.iterator(); - while (fixedIPIterator.hasNext()) { - Neutron_IPs ip = fixedIPIterator.next(); - if (ip.getSubnetUUID() == null) { - throw new BadRequestException("subnet UUID not specified"); - } - NeutronSubnet subnet = subnetInterface.getSubnet(ip.getSubnetUUID()); - if (subnet == null) { - throw new BadRequestException("subnet UUID must exist"); - } - if (!singleton.getNetworkUUID().equalsIgnoreCase(subnet.getNetworkUUID())) { - throw new BadRequestException(NET_UUID_MATCH); - } - if (ip.getIpAddress() != null) { - if (!subnet.isValidIP(ip.getIpAddress())) { - throw new BadRequestException("IP address is not valid"); - } - if (subnet.isIPInUse(ip.getIpAddress())) { - throw new ResourceConflictException("IP address is in use."); - } - } - } - } - Object[] instances = NeutronUtil.getInstances(INeutronPortAware.class, this); if (instances != null) { if (instances.length > 0) { @@ -302,81 +250,9 @@ public class NeutronPortsNorthbound { } } } else { - List bulk = input.getBulk(); - Iterator i = bulk.iterator(); - Map testMap = new HashMap(); Object[] instances = NeutronUtil.getInstances(INeutronPortAware.class, this); - while (i.hasNext()) { - NeutronPort test = i.next(); - - /* - * the port must be part of an existing network, must not already exist, - * 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())) { - throw new BadRequestException(UUID_EXISTS); - } - if (testMap.containsKey(test.getID())) { - throw new BadRequestException(UUID_EXISTS); - } - for (NeutronPort check : testMap.values()) { - if (test.getMacAddress().equalsIgnoreCase(check.getMacAddress())) { - throw new ResourceConflictException("MAC address already allocated"); - } - for (Neutron_IPs test_fixedIP : test.getFixedIPs()) { - for (Neutron_IPs check_fixedIP : check.getFixedIPs()) { - if (test_fixedIP.getSubnetUUID().equals(check_fixedIP.getSubnetUUID()) && - (test_fixedIP.getIpAddress().equals(check_fixedIP.getIpAddress()))) { - throw new ResourceConflictException("IP address already allocated"); - } - } - } - } - testMap.put(test.getID(), test); - if (!networkInterface.networkExists(test.getNetworkUUID())) { - throw new ResourceNotFoundException("network UUID does not exist."); - } - if (!test.getMacAddress().matches(MAC_REGEX)) { - throw new BadRequestException("MAC address not properly formatted"); - } - if (portInterface.macInUse(test.getMacAddress())) { - throw new ResourceConflictException("MAC address in use"); - } + for (NeutronPort test : input.getBulk()) { - /* - * if fixed IPs are specified, each one has to have an existing subnet ID - * that is in the same scoping network as the port. In addition, if an IP - * address is specified it has to be a valid address for the subnet and not - * already in use (or be the gateway IP address of the subnet) - */ - List fixedIPs = test.getFixedIPs(); - if (fixedIPs != null && fixedIPs.size() > 0) { - Iterator fixedIPIterator = fixedIPs.iterator(); - while (fixedIPIterator.hasNext()) { - Neutron_IPs ip = fixedIPIterator.next(); - if (ip.getSubnetUUID() == null) { - throw new BadRequestException("subnet UUID must be specified"); - } - if (!subnetInterface.subnetExists(ip.getSubnetUUID())) { - throw new BadRequestException("subnet UUID doesn't exists"); - } - NeutronSubnet subnet = subnetInterface.getSubnet(ip.getSubnetUUID()); - if (!test.getNetworkUUID().equalsIgnoreCase(subnet.getNetworkUUID())) { - throw new BadRequestException(NET_UUID_MATCH); - } - if (ip.getIpAddress() != null) { - if (!subnet.isValidIP(ip.getIpAddress())) { - throw new BadRequestException("ip address not valid"); - } - //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())) { - throw new ResourceConflictException("IP address in use"); - } - } - } - } if (instances != null) { if (instances.length > 0) { for (Object instance : instances) { @@ -395,9 +271,7 @@ public class NeutronPortsNorthbound { } //once everything has passed, then we can add to the cache - i = bulk.iterator(); - while (i.hasNext()) { - NeutronPort test = i.next(); + for (NeutronPort test : input.getBulk()) { portInterface.addPort(test); if (instances != null) { for (Object instance : instances) { @@ -433,15 +307,7 @@ public class NeutronPortsNorthbound { ) { NeutronCRUDInterfaces interfaces = getNeutronInterfaces(false, true); INeutronPortCRUD portInterface = interfaces.getPortInterface(); - // port has to exist and only a single delta is supported - if (!portInterface.portExists(portUUID)) { - throw new ResourceNotFoundException(UUID_NO_EXIST); - } NeutronPort original = portInterface.getPort(portUUID); - if (!input.isSingleton()) { - throw new BadRequestException("only singleton edit suported"); - } - /* * note: what we get appears to not be a delta, but rather a possibly * complete updated object. So, that needs to be sent down to @@ -498,15 +364,6 @@ public class NeutronPortsNorthbound { @PathParam("portUUID") String portUUID) { INeutronPortCRUD portInterface = getNeutronInterfaces(false, false).getPortInterface(); - // port has to exist and not be owned by anyone. then it can be removed from the cache - if (!portInterface.portExists(portUUID)) { - throw new ResourceNotFoundException(UUID_NO_EXIST); - } - NeutronPort port = portInterface.getPort(portUUID); - if (port.getDeviceID() != null || - port.getDeviceOwner() != null) { - Response.status(HttpURLConnection.HTTP_FORBIDDEN).build(); - } NeutronPort singleton = portInterface.getPort(portUUID); Object[] instances = NeutronUtil.getInstances(INeutronPortAware.class, this); if (instances != null) { diff --git a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronRoutersNorthbound.java b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronRoutersNorthbound.java index 6cf38dfcc..5fe6e6a72 100644 --- a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronRoutersNorthbound.java +++ b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronRoutersNorthbound.java @@ -219,24 +219,6 @@ public class NeutronRoutersNorthbound { if (input.isSingleton()) { NeutronRouter singleton = input.getSingleton(); - /* - * verify that the router doesn't already exist (issue: is deeper inspection necessary?) - * if there is external gateway information provided, verify that the specified network - * exists and has been designated as "router:external" - */ - if (routerInterface.routerExists(singleton.getID())) { - throw new BadRequestException("router UUID already exists"); - } - if (singleton.getExternalGatewayInfo() != null) { - String externNetworkPtr = singleton.getExternalGatewayInfo().getNetworkID(); - if (!networkInterface.networkExists(externNetworkPtr)) { - throw new BadRequestException("External Network Pointer doesn't exist"); - } - NeutronNetwork externNetwork = networkInterface.getNetwork(externNetworkPtr); - if (!externNetwork.isRouterExternal()) { - throw new BadRequestException("External Network Pointer isn't marked as router:external"); - } - } Object[] instances = NeutronUtil.getInstances(INeutronRouterAware.class, this); if (instances != null) { if (instances.length > 0) { @@ -297,15 +279,6 @@ public class NeutronRoutersNorthbound { INeutronRouterCRUD routerInterface = interfaces.getRouterInterface(); INeutronNetworkCRUD networkInterface = interfaces.getNetworkInterface(); - /* - * router has to exist and only a single delta can be supplied - */ - if (!routerInterface.routerExists(routerUUID)) { - throw new ResourceNotFoundException(UUID_NO_EXIST); - } - if (!input.isSingleton()) { - throw new BadRequestException("Only single router deltas supported"); - } NeutronRouter updatedRouter = input.getSingleton(); NeutronRouter original = routerInterface.getRouter(routerUUID); @@ -357,15 +330,6 @@ public class NeutronRoutersNorthbound { @PathParam("routerUUID") String routerUUID) { INeutronRouterCRUD routerInterface = getNeutronInterfaces(false).getRouterInterface(); - /* - * verify that the router exists and is not in use before removing it - */ - if (!routerInterface.routerExists(routerUUID)) { - throw new ResourceNotFoundException(UUID_NO_EXIST); - } - if (routerInterface.routerInUse(routerUUID)) { - throw new ResourceConflictException("Router UUID in Use"); - } NeutronRouter singleton = routerInterface.getRouter(routerUUID); Object[] instances = NeutronUtil.getInstances(INeutronRouterAware.class, this); if (instances != null) { @@ -418,43 +382,7 @@ public class NeutronRoutersNorthbound { INeutronPortCRUD portInterface = interfaces.getPortInterface(); INeutronSubnetCRUD subnetInterface = interfaces.getSubnetInterface(); - /* - * While the Neutron specification says that the router has to exist and the input can only specify either a subnet id - * or a port id, but not both, this code assumes that the plugin has filled everything in for us and so both must be present - */ - if (!routerInterface.routerExists(routerUUID)) { - throw new BadRequestException(UUID_NO_EXIST); - } NeutronRouter target = routerInterface.getRouter(routerUUID); - if (input.getSubnetUUID() == null || - input.getPortUUID() == null) { - throw new BadRequestException("Must specify at subnet id, port id or both"); - } - - // check that the port is part of the subnet - NeutronSubnet targetSubnet = subnetInterface.getSubnet(input.getSubnetUUID()); - if (targetSubnet == null) { - throw new BadRequestException("Subnet id doesn't exist"); - } - NeutronPort targetPort = portInterface.getPort(input.getPortUUID()); - if (targetPort == null) { - throw new BadRequestException("Port id doesn't exist"); - } - if (!targetSubnet.getPortsInSubnet().contains(targetPort)) { - throw new BadRequestException("Port id not part of subnet id"); - } - - if (targetPort.getFixedIPs().size() != 1) { - throw new BadRequestException("Port id must have a single fixedIP address"); - } - if (targetPort.getDeviceID() != null && !targetPort.getDeviceID().equals(routerUUID)) { - throw new ResourceConflictException("Target Port already allocated to a different device id"); - } - if (targetPort.getDeviceOwner() != null && - !targetPort.getDeviceOwner().equalsIgnoreCase(ROUTER_INTERFACE_STR) && - !targetPort.getDeviceOwner().equalsIgnoreCase(ROUTER_GATEWAY_STR)) { - throw new ResourceConflictException("Target Port already allocated to non-router interface"); - } Object[] instances = NeutronUtil.getInstances(INeutronRouterAware.class, this); if (instances != null) { if (instances.length > 0) { @@ -472,12 +400,6 @@ public class NeutronRoutersNorthbound { throw new ServiceUnavailableException(NO_PROVIDER_LIST); } - //mark the port device id and device owner fields - if (targetPort.getDeviceOwner() == null || targetPort.getDeviceOwner().isEmpty()) { - targetPort.setDeviceOwner(ROUTER_INTERFACE_STR); - } - targetPort.setDeviceID(routerUUID); - target.addInterface(input.getPortUUID(), input); if (instances != null) { for (Object instance : instances) { @@ -536,33 +458,13 @@ public class NeutronRoutersNorthbound { INeutronSubnetCRUD subnetInterface = interfaces.getSubnetInterface(); Object[] instances = NeutronUtil.getInstances(INeutronRouterAware.class, this); - // verify the router exists - if (!routerInterface.routerExists(routerUUID)) { - throw new BadRequestException("Router does not exist"); - } NeutronRouter target = routerInterface.getRouter(routerUUID); - NeutronPort port = portInterface.getPort(input.getPortUUID()); - if (port == null) { - throw new ResourceNotFoundException("Port UUID not found"); - } - if (port.getFixedIPs() == null) { - throw new ResourceNotFoundException("Port UUID has no fixed IPs"); - } - NeutronSubnet subnet = subnetInterface.getSubnet(input.getSubnetUUID()); - if (subnet == null) { - throw new ResourceNotFoundException("Subnet UUID not found"); - } - if (!subnet.isValidIP(port.getFixedIPs().get(0).getIpAddress())) { - throw new ResourceConflictException("Target Port IP not in Target Subnet"); - } input.setID(target.getID()); input.setTenantID(target.getTenantID()); int status = checkDownstreamDetach(target, input); if (status != HTTP_OK_BOTTOM) { return Response.status(status).build(); } - port.setDeviceID(null); - port.setDeviceOwner(null); target.removeInterface(input.getPortUUID()); for (Object instance : instances) { INeutronRouterAware service = (INeutronRouterAware) instance; diff --git a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronSecurityGroupsNorthbound.java b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronSecurityGroupsNorthbound.java index 3a969e5a3..c5c379ce1 100644 --- a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronSecurityGroupsNorthbound.java +++ b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronSecurityGroupsNorthbound.java @@ -171,13 +171,6 @@ public class NeutronSecurityGroupsNorthbound { if (input.isSingleton()) { NeutronSecurityGroup singleton = input.getSingleton(); - /* - * Verify that the Security Group doesn't already exist. - */ - if (securityGroupInterface.neutronSecurityGroupExists(singleton.getSecurityGroupUUID())) { - throw new BadRequestException("Security Group UUID already exists"); - } - Object[] instances = NeutronUtil.getInstances(INeutronSecurityGroupAware.class, this); if (instances != null) { if (instances.length > 0) { @@ -203,19 +196,8 @@ public class NeutronSecurityGroupsNorthbound { } } } else { - List bulk = input.getBulk(); - Iterator i = bulk.iterator(); Object[] instances = NeutronUtil.getInstances(INeutronSecurityGroupAware.class, this); - while (i.hasNext()) { - NeutronSecurityGroup test = i.next(); - - /* - * Verify that the security group doesn't already exist - */ - - if (securityGroupInterface.neutronSecurityGroupExists(test.getSecurityGroupUUID())) { - throw new BadRequestException("Security Group UUID already is already created"); - } + for (NeutronSecurityGroup test : input.getBulk()) { if (instances != null) { if (instances.length > 0) { for (Object instance : instances) { @@ -236,9 +218,7 @@ public class NeutronSecurityGroupsNorthbound { /* * now, each element of the bulk request can be added to the cache */ - i = bulk.iterator(); - while (i.hasNext()) { - NeutronSecurityGroup test = i.next(); + for (NeutronSecurityGroup test : input.getBulk()) { securityGroupInterface.addNeutronSecurityGroup(test); if (instances != null) { for (Object instance : instances) { @@ -271,25 +251,9 @@ public class NeutronSecurityGroupsNorthbound { @PathParam ("securityGroupUUID") String securityGroupUUID, final NeutronSecurityGroupRequest input) { INeutronSecurityGroupCRUD securityGroupInterface = getNeutronInterfaces().getSecurityGroupInterface(); - /* - * verify the Security Group exists and there is only one delta provided - */ - if (!securityGroupInterface.neutronSecurityGroupExists(securityGroupUUID)) { - throw new ResourceNotFoundException(UUID_NO_EXIST); - } - if (!input.isSingleton()) { - throw new BadRequestException("Only singleton edit supported"); - } NeutronSecurityGroup delta = input.getSingleton(); NeutronSecurityGroup original = securityGroupInterface.getNeutronSecurityGroup(securityGroupUUID); - if (delta.getSecurityGroupUUID() != null || - delta.getSecurityGroupTenantID() != null || - delta.getSecurityGroupName() != null || - delta.getSecurityGroupDescription() != null) { - throw new BadRequestException("Attribute edit blocked by Neutron"); - } - Object[] instances = NeutronUtil.getInstances(INeutronSecurityGroupAware.class, this); if (instances != null) { if (instances.length > 0) { @@ -338,15 +302,6 @@ public class NeutronSecurityGroupsNorthbound { @PathParam ("securityGroupUUID") String securityGroupUUID) { INeutronSecurityGroupCRUD securityGroupInterface = getNeutronInterfaces().getSecurityGroupInterface(); - /* - * verify the Security Group exists and it isn't currently in use - */ - if (!securityGroupInterface.neutronSecurityGroupExists(securityGroupUUID)) { - throw new ResourceNotFoundException(UUID_NO_EXIST); - } - if (securityGroupInterface.neutronSecurityGroupInUse(securityGroupUUID)) { - return Response.status(HttpURLConnection.HTTP_CONFLICT).build(); - } NeutronSecurityGroup singleton = securityGroupInterface.getNeutronSecurityGroup(securityGroupUUID); Object[] instances = NeutronUtil.getInstances(INeutronSecurityGroupAware.class, this); if (instances != null) { diff --git a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronSecurityRulesNorthbound.java b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronSecurityRulesNorthbound.java index 80d999d2e..a1fddabb5 100644 --- a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronSecurityRulesNorthbound.java +++ b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronSecurityRulesNorthbound.java @@ -189,16 +189,8 @@ public class NeutronSecurityRulesNorthbound { public Response createSecurityRules(final NeutronSecurityRuleRequest input) { INeutronSecurityRuleCRUD securityRuleInterface = getNeutronInterfaces().getSecurityRuleInterface(); - /* - * Existing entry checks - */ - if (input.isSingleton()) { NeutronSecurityRule singleton = input.getSingleton(); - - if (securityRuleInterface.neutronSecurityRuleExists(singleton.getSecurityRuleUUID())) { - throw new BadRequestException(UUID_EXISTS); - } Object[] instances = NeutronUtil.getInstances(INeutronSecurityRuleAware.class, this); if (instances != null) { if (instances.length > 0) { @@ -226,23 +218,8 @@ public class NeutronSecurityRulesNorthbound { } } } else { - List bulk = input.getBulk(); - Iterator i = bulk.iterator(); - Map testMap = new HashMap(); Object[] instances = NeutronUtil.getInstances(INeutronSecurityRuleAware.class, this); - while (i.hasNext()) { - NeutronSecurityRule test = i.next(); - - /* - * Verify that the security rule doesn't already exist - */ - - if (securityRuleInterface.neutronSecurityRuleExists(test.getSecurityRuleUUID())) { - throw new BadRequestException(UUID_EXISTS); - } - if (testMap.containsKey(test.getSecurityRuleUUID())) { - throw new BadRequestException(UUID_EXISTS); - } + for (NeutronSecurityRule test : input.getBulk()) { if (instances != null) { if (instances.length > 0) { for (Object instance : instances) { @@ -263,9 +240,7 @@ public class NeutronSecurityRulesNorthbound { /* * now, each element of the bulk request can be added to the cache */ - i = bulk.iterator(); - while (i.hasNext()) { - NeutronSecurityRule test = i.next(); + for (NeutronSecurityRule test : input.getBulk()) { securityRuleInterface.addNeutronSecurityRule(test); if (instances != null) { for (Object instance : instances) { @@ -298,35 +273,9 @@ public class NeutronSecurityRulesNorthbound { @PathParam ("securityRuleUUID") String securityRuleUUID, final NeutronSecurityRuleRequest input) { INeutronSecurityRuleCRUD securityRuleInterface = getNeutronInterfaces().getSecurityRuleInterface(); - /* - * verify the Security Rule exists and there is only one delta provided - */ - if (!securityRuleInterface.neutronSecurityRuleExists(securityRuleUUID)) { - throw new ResourceNotFoundException(UUID_NO_EXIST); - } - if (!input.isSingleton()) { - throw new BadRequestException("Only singleton edit supported"); - } NeutronSecurityRule delta = input.getSingleton(); NeutronSecurityRule original = securityRuleInterface.getNeutronSecurityRule(securityRuleUUID); - /* - * updates restricted by Neutron - * - */ - if (delta.getSecurityRuleUUID() != null || - delta.getSecurityRuleDirection() != null || - delta.getSecurityRuleProtocol() != null || - delta.getSecurityRulePortMin() != null || - delta.getSecurityRulePortMax() != null || - delta.getSecurityRuleEthertype() != null || - delta.getSecurityRuleRemoteIpPrefix() != null || - delta.getSecurityRuleGroupID() != null || - delta.getSecurityRemoteGroupID() != null || - delta.getSecurityRuleTenantID() != null) { - throw new BadRequestException("Attribute edit blocked by Neutron"); - } - Object[] instances = NeutronUtil.getInstances(INeutronSecurityRuleAware.class, this); if (instances != null) { if (instances.length > 0) { @@ -375,15 +324,6 @@ public class NeutronSecurityRulesNorthbound { @PathParam ("securityRuleUUID") String securityRuleUUID) { INeutronSecurityRuleCRUD securityRuleInterface = getNeutronInterfaces().getSecurityRuleInterface(); - /* - * verify the Security Rule exists and it isn't currently in use - */ - if (!securityRuleInterface.neutronSecurityRuleExists(securityRuleUUID)) { - throw new ResourceNotFoundException(UUID_NO_EXIST); - } - if (securityRuleInterface.neutronSecurityRuleInUse(securityRuleUUID)) { - return Response.status(HttpURLConnection.HTTP_CONFLICT).build(); - } NeutronSecurityRule singleton = securityRuleInterface.getNeutronSecurityRule(securityRuleUUID); Object[] instances = NeutronUtil.getInstances(INeutronSecurityRuleAware.class, this); if (instances != null) { diff --git a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronSubnetsNorthbound.java b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronSubnetsNorthbound.java index c7bb93c27..597e4e519 100644 --- a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronSubnetsNorthbound.java +++ b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronSubnetsNorthbound.java @@ -209,27 +209,6 @@ public class NeutronSubnetsNorthbound { if (input.isSingleton()) { NeutronSubnet singleton = input.getSingleton(); - /* - * Verify that the subnet doesn't already exist (Issue: is a deeper check necessary?) - * the specified network exists, the subnet has a valid network address, - * and that the gateway IP doesn't overlap with the allocation pools - * *then* add the subnet to the cache - */ - if (subnetInterface.subnetExists(singleton.getID())) { - throw new BadRequestException(UUID_EXISTS); - } - if (!networkInterface.networkExists(singleton.getNetworkUUID())) { - throw new ResourceNotFoundException("network UUID does not exist."); - } - if (!singleton.isValidCIDR()) { - throw new BadRequestException("invaild CIDR"); - } - if (!singleton.initDefaults()) { - throw new InternalServerErrorException("subnet object could not be initialized properly"); - } - if (singleton.gatewayIP_Pool_overlap()) { - throw new ResourceConflictException("IP pool overlaps with gateway"); - } Object[] instances = NeutronUtil.getInstances(INeutronSubnetAware.class, this); if (instances != null) { if (instances.length > 0) { @@ -254,39 +233,8 @@ public class NeutronSubnetsNorthbound { } } } else { - List bulk = input.getBulk(); - Iterator i = bulk.iterator(); - Map testMap = new HashMap(); Object[] instances = NeutronUtil.getInstances(INeutronSubnetAware.class, this); - while (i.hasNext()) { - NeutronSubnet test = i.next(); - - /* - * Verify that the subnet doesn't already exist (Issue: is a deeper check necessary?) - * the specified network exists, the subnet has a valid network address, - * and that the gateway IP doesn't overlap with the allocation pools, - * and that the bulk request doesn't already contain a subnet with this id - */ - - if (!test.initDefaults()) { - throw new InternalServerErrorException("subnet object could not be initialized properly"); - } - if (subnetInterface.subnetExists(test.getID())) { - throw new BadRequestException(UUID_EXISTS); - } - if (testMap.containsKey(test.getID())) { - throw new BadRequestException(UUID_EXISTS); - } - testMap.put(test.getID(), test); - if (!networkInterface.networkExists(test.getNetworkUUID())) { - throw new ResourceNotFoundException("network UUID does not exist."); - } - if (!test.isValidCIDR()) { - throw new BadRequestException("Invalid CIDR"); - } - if (test.gatewayIP_Pool_overlap()) { - throw new ResourceConflictException("IP pool overlaps with gateway"); - } + for (NeutronSubnet test : input.getBulk()) { if (instances != null) { if (instances.length > 0) { for (Object instance : instances) { @@ -307,9 +255,7 @@ public class NeutronSubnetsNorthbound { /* * now, each element of the bulk request can be added to the cache */ - i = bulk.iterator(); - while (i.hasNext()) { - NeutronSubnet test = i.next(); + for (NeutronSubnet test : input.getBulk()) { subnetInterface.addSubnet(test); if (instances != null) { for (Object instance : instances) { @@ -343,16 +289,6 @@ public class NeutronSubnetsNorthbound { ) { INeutronSubnetCRUD subnetInterface = getNeutronInterfaces(false).getSubnetInterface(); - /* - * verify the subnet exists and there is only one delta provided - */ - if (!subnetInterface.subnetExists(subnetUUID)) { - throw new ResourceNotFoundException(UUID_NO_EXIST); - } - if (!input.isSingleton()) { - throw new BadRequestException("Only singleton edit supported"); - } - /* * note: what we get appears to not be a delta, but rather a * complete updated object. So, that needs to be sent down to @@ -409,15 +345,6 @@ public class NeutronSubnetsNorthbound { @PathParam("subnetUUID") String subnetUUID) { INeutronSubnetCRUD subnetInterface = getNeutronInterfaces(false).getSubnetInterface(); - /* - * verify the subnet exists and it isn't currently in use - */ - if (!subnetInterface.subnetExists(subnetUUID)) { - throw new ResourceNotFoundException(UUID_NO_EXIST); - } - if (subnetInterface.subnetInUse(subnetUUID)) { - return Response.status(HttpURLConnection.HTTP_CONFLICT).build(); - } NeutronSubnet singleton = subnetInterface.getSubnet(subnetUUID); Object[] instances = NeutronUtil.getInstances(INeutronSubnetAware.class, this); if (instances != null) { diff --git a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronVPNIKEPoliciesNorthbound.java b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronVPNIKEPoliciesNorthbound.java index 4387dfe7d..04860483c 100644 --- a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronVPNIKEPoliciesNorthbound.java +++ b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronVPNIKEPoliciesNorthbound.java @@ -179,12 +179,6 @@ public class NeutronVPNIKEPoliciesNorthbound { if (input.isSingleton()) { NeutronVPNIKEPolicy singleton = input.getSingleton(); - /* - * verify that the ikePolicy doesn't already exist (issue: is deeper inspection necessary?) - */ - if (ikePolicyInterface.neutronVPNIKEPolicyExists(singleton.getID())) { - throw new BadRequestException("ikePolicy UUID already exists"); - } Object[] instances = NeutronUtil.getInstances(INeutronVPNIKEPolicyAware.class, this); if (instances != null) { if (instances.length > 0) { @@ -240,25 +234,9 @@ public class NeutronVPNIKEPoliciesNorthbound { ) { INeutronVPNIKEPolicyCRUD ikePolicyInterface = getNeutronInterfaces().getVPNIKEPolicyInterface(); - /* - * ikePolicy has to exist and only a single delta can be supplied - */ - if (!ikePolicyInterface.neutronVPNIKEPolicyExists(policyUUID)) { - throw new ResourceNotFoundException(UUID_NO_EXIST); - } - if (!input.isSingleton()) { - throw new BadRequestException("Only single ikePolicy deltas supported"); - } NeutronVPNIKEPolicy singleton = input.getSingleton(); NeutronVPNIKEPolicy original = ikePolicyInterface.getNeutronVPNIKEPolicy(policyUUID); - /* - * attribute changes blocked by Neutron - */ - if (singleton.getID() != null || singleton.getTenantID() != null) { - throw new BadRequestException("Request attribute change not allowed"); - } - Object[] instances = NeutronUtil.getInstances(INeutronVPNIKEPolicyAware.class, this); if (instances != null) { if (instances.length > 0) { @@ -306,12 +284,6 @@ public class NeutronVPNIKEPoliciesNorthbound { @PathParam("policyID") String policyUUID) { INeutronVPNIKEPolicyCRUD policyInterface = getNeutronInterfaces().getVPNIKEPolicyInterface(); - /* - * verify that the policy exists and is not in use before removing it - */ - if (!policyInterface.neutronVPNIKEPolicyExists(policyUUID)) { - throw new ResourceNotFoundException(UUID_NO_EXIST); - } NeutronVPNIKEPolicy singleton = policyInterface.getNeutronVPNIKEPolicy(policyUUID); Object[] instances = NeutronUtil.getInstances(INeutronVPNIKEPolicyAware.class, this); if (instances != null) { diff --git a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronVPNIPSECPoliciesNorthbound.java b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronVPNIPSECPoliciesNorthbound.java index a62aa2667..c37c34d6f 100644 --- a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronVPNIPSECPoliciesNorthbound.java +++ b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronVPNIPSECPoliciesNorthbound.java @@ -180,12 +180,6 @@ public class NeutronVPNIPSECPoliciesNorthbound { if (input.isSingleton()) { NeutronVPNIPSECPolicy singleton = input.getSingleton(); - /* - * verify that the ipsecPolicy doesn't already exist (issue: is deeper inspection necessary?) - */ - if (ipsecPolicyInterface.neutronVPNIPSECPolicyExists(singleton.getID())) { - throw new BadRequestException("ipsecPolicy UUID already exists"); - } Object[] instances = NeutronUtil.getInstances(INeutronVPNIPSECPolicyAware.class, this); if (instances != null) { if (instances.length > 0) { @@ -241,25 +235,9 @@ public class NeutronVPNIPSECPoliciesNorthbound { ) { INeutronVPNIPSECPolicyCRUD ipsecPolicyInterface = getNeutronInterfaces().getVPNIPSECPolicyInterface(); - /* - * ipsecPolicy has to exist and only a single delta can be supplied - */ - if (!ipsecPolicyInterface.neutronVPNIPSECPolicyExists(policyUUID)) { - throw new ResourceNotFoundException(UUID_NO_EXIST); - } - if (!input.isSingleton()) { - throw new BadRequestException("Only single ipsecPolicy deltas supported"); - } NeutronVPNIPSECPolicy singleton = input.getSingleton(); NeutronVPNIPSECPolicy original = ipsecPolicyInterface.getNeutronVPNIPSECPolicy(policyUUID); - /* - * attribute changes blocked by Neutron - */ - if (singleton.getID() != null || singleton.getTenantID() != null) { - throw new BadRequestException("Request attribute change not allowed"); - } - Object[] instances = NeutronUtil.getInstances(INeutronVPNIPSECPolicyAware.class, this); if (instances != null) { if (instances.length > 0) { @@ -307,12 +285,6 @@ public class NeutronVPNIPSECPoliciesNorthbound { @PathParam("policyID") String policyUUID) { INeutronVPNIPSECPolicyCRUD policyInterface = getNeutronInterfaces().getVPNIPSECPolicyInterface(); - /* - * verify that the policy exists and is not in use before removing it - */ - if (!policyInterface.neutronVPNIPSECPolicyExists(policyUUID)) { - throw new ResourceNotFoundException(UUID_NO_EXIST); - } NeutronVPNIPSECPolicy singleton = policyInterface.getNeutronVPNIPSECPolicy(policyUUID); Object[] instances = NeutronUtil.getInstances(INeutronVPNIPSECPolicyAware.class, this); if (instances != null) { diff --git a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronVPNIPSECSiteConnectionsNorthbound.java b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronVPNIPSECSiteConnectionsNorthbound.java index f0ba4896e..1a4b35555 100644 --- a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronVPNIPSECSiteConnectionsNorthbound.java +++ b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronVPNIPSECSiteConnectionsNorthbound.java @@ -191,14 +191,6 @@ public class NeutronVPNIPSECSiteConnectionsNorthbound { .getVPNIPSECSiteConnectionsInterface(); if (input.isSingleton()) { NeutronVPNIPSECSiteConnection singleton = input.getSingleton(); - - /* - * verify that the ipsec site connection doesn't already exist (issue: is deeper - * inspection necessary?) - */ - if (ipsecSiteConnectionsInterface.neutronVPNIPSECSiteConnectionsExists(singleton.getID())) { - throw new BadRequestException("VPNIPSECSiteConnections ID already exists"); - } Object[] instances = NeutronUtil.getInstances(INeutronVPNIPSECSiteConnectionAware.class, this); if (instances != null) { if (instances.length > 0) { @@ -253,27 +245,10 @@ public class NeutronVPNIPSECSiteConnectionsNorthbound { INeutronVPNIPSECSiteConnectionsCRUD ipsecSiteConnectionsInterface = getNeutronInterfaces() .getVPNIPSECSiteConnectionsInterface(); - /* - * ipsecSiteConnection has to exist and only a single delta can be - * supplied - */ - if (!ipsecSiteConnectionsInterface.neutronVPNIPSECSiteConnectionsExists(policyID)) { - throw new ResourceNotFoundException("VPNIPSECSiteConnections ID not found"); - } - if (!input.isSingleton()) { - throw new BadRequestException("Only singleton deltas supported"); - } NeutronVPNIPSECSiteConnection singleton = input.getSingleton(); NeutronVPNIPSECSiteConnection original = ipsecSiteConnectionsInterface .getNeutronVPNIPSECSiteConnections(policyID); - /* - * attribute changes blocked by Neutron - */ - if (singleton.getID() != null || singleton.getTenantID() != null) { - throw new BadRequestException("Request attribute change not allowed"); - } - Object[] instances = NeutronUtil.getInstances(INeutronVPNIKEPolicyAware.class, this); if (instances != null) { if (instances.length > 0) { @@ -324,13 +299,6 @@ public class NeutronVPNIPSECSiteConnectionsNorthbound { INeutronVPNIPSECSiteConnectionsCRUD ipsecSiteConnectionsInterface = getNeutronInterfaces() .getVPNIPSECSiteConnectionsInterface(); - /* - * verify that the iSiteConnections exists and is not in use before - * removing it - */ - if (!ipsecSiteConnectionsInterface.neutronVPNIPSECSiteConnectionsExists(policyID)) { - throw new ResourceNotFoundException("VPNIPSECSiteConnections ID not found"); - } NeutronVPNIPSECSiteConnection singleton = ipsecSiteConnectionsInterface .getNeutronVPNIPSECSiteConnections(policyID); Object[] instances = NeutronUtil.getInstances(INeutronVPNIPSECSiteConnectionAware.class, this); diff --git a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronVPNServicesNorthbound.java b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronVPNServicesNorthbound.java index b8ae46767..bc998035b 100644 --- a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronVPNServicesNorthbound.java +++ b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronVPNServicesNorthbound.java @@ -181,12 +181,6 @@ public class NeutronVPNServicesNorthbound { if (input.isSingleton()) { NeutronVPNService singleton = input.getSingleton(); - /* - * Verify that the VPNService doesn't already exist. - */ - if (VPNServiceInterface.neutronVPNServiceExists(singleton.getID())) { - throw new BadRequestException("VPNService UUID already exists"); - } Object[] instances = NeutronUtil.getInstances(INeutronVPNServiceAware.class, this); if (instances != null) { if (instances.length > 0) { @@ -212,23 +206,8 @@ public class NeutronVPNServicesNorthbound { } } } else { - List bulk = input.getBulk(); - Iterator i = bulk.iterator(); - Map testMap = new HashMap(); Object[] instances = NeutronUtil.getInstances(INeutronVPNServiceAware.class, this); - while (i.hasNext()) { - NeutronVPNService test = i.next(); - - /* - * Verify that the VPNService doesn't already exist - */ - - if (VPNServiceInterface.neutronVPNServiceExists(test.getID())) { - throw new BadRequestException("VPN Service UUID already is already created"); - } - if (testMap.containsKey(test.getID())) { - throw new BadRequestException("VPN Service UUID already exists"); - } + for (NeutronVPNService test : input.getBulk()) { if (instances != null) { if (instances.length > 0) { for (Object instance : instances) { @@ -248,9 +227,7 @@ public class NeutronVPNServicesNorthbound { /* * now, each element of the bulk request can be added to the cache */ - i = bulk.iterator(); - while (i.hasNext()) { - NeutronVPNService test = i.next(); + for (NeutronVPNService test : input.getBulk()) { VPNServiceInterface.addVPNService(test); if (instances != null) { for (Object instance : instances) { @@ -280,27 +257,9 @@ public class NeutronVPNServicesNorthbound { public Response updateVPNService(@PathParam("serviceID") String serviceID, final NeutronVPNServiceRequest input) { INeutronVPNServiceCRUD VPNServiceInterface = getNeutronInterfaces().getVPNServiceInterface(); - /* - * verify the VPNService exists and there is only one delta provided - */ - if (!VPNServiceInterface.neutronVPNServiceExists(serviceID)) { - throw new ResourceNotFoundException(UUID_NO_EXIST); - } - if (!input.isSingleton()) { - throw new BadRequestException("Only singleton edit supported"); - } NeutronVPNService delta = input.getSingleton(); NeutronVPNService original = VPNServiceInterface.getVPNService(serviceID); - /* - * updates restricted by Neutron - */ - if (delta.getID() != null || delta.getTenantID() != null || delta.getName() != null - || delta.getRouterUUID() != null || delta.getStatus() != null || delta.getAdminStateUp() != null - || delta.getSubnetUUID() != null) { - throw new BadRequestException("Attribute edit blocked by Neutron"); - } - Object[] instances = NeutronUtil.getInstances(INeutronVPNServiceAware.class, this); if (instances != null) { if (instances.length > 0) { @@ -348,15 +307,6 @@ public class NeutronVPNServicesNorthbound { public Response deleteVPNService(@PathParam("serviceID") String serviceID) { INeutronVPNServiceCRUD VPNServiceInterface = getNeutronInterfaces().getVPNServiceInterface(); - /* - * verify the VPNService exists and it isn't currently in use - */ - if (!VPNServiceInterface.neutronVPNServiceExists(serviceID)) { - throw new ResourceNotFoundException(UUID_NO_EXIST); - } - if (VPNServiceInterface.neutronVPNServiceInUse(serviceID)) { - return Response.status(HttpURLConnection.HTTP_CONFLICT).build(); - } NeutronVPNService singleton = VPNServiceInterface.getVPNService(serviceID); Object[] instances = NeutronUtil.getInstances(INeutronVPNServiceAware.class, this); if (instances != null) { -- 2.36.6