From: Flavio Fernandes Date: Wed, 13 Aug 2014 16:43:38 +0000 (-0400) Subject: Fix comparison logic in neutron floating ip rest implementation X-Git-Tag: release/helium~296 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=085713d3e52264d57398e07e55b6abed9dbdc980 Fix comparison logic in neutron floating ip rest implementation * Detect when external network has no subnets (in addition to more than one) * Fix compare after looking up NeutronFloatingIP singleton Change-Id: Id84360fc9d984e9815de56b90be4a1c753fdbcd8 Signed-off-by: Flavio Fernandes --- diff --git a/opendaylight/northbound/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronFloatingIPsNorthbound.java b/opendaylight/northbound/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronFloatingIPsNorthbound.java index f93191220b..af7cfd18b9 100644 --- a/opendaylight/northbound/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronFloatingIPsNorthbound.java +++ b/opendaylight/northbound/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronFloatingIPsNorthbound.java @@ -203,7 +203,7 @@ public class NeutronFloatingIPsNorthbound { // if floating IP is specified, make sure it can come from the network String floatingIP = singleton.getFloatingIPAddress(); if (floatingIP != null) { - if (externNetwork.getSubnets().size() > 1) + if (externNetwork.getSubnets().size() != 1) throw new BadRequestException("external network doesn't have a subnet"); NeutronSubnet externSubnet = subnetInterface.getSubnet(externNetwork.getSubnets().get(0)); if (!externSubnet.isValidIP(floatingIP)) @@ -312,7 +312,7 @@ public class NeutronFloatingIPsNorthbound { if (!input.isSingleton()) throw new BadRequestException("only singleton requests allowed."); NeutronFloatingIP singleton = input.getSingleton(); - if (singleton.getID() != null) + if (singleton.getID() == null) throw new BadRequestException("singleton UUID doesn't exist."); NeutronNetwork externNetwork = networkInterface.getNetwork( @@ -321,7 +321,7 @@ public class NeutronFloatingIPsNorthbound { // if floating IP is specified, make sure it can come from the network String floatingIP = singleton.getFloatingIPAddress(); if (floatingIP != null) { - if (externNetwork.getSubnets().size() > 1) + if (externNetwork.getSubnets().size() != 1) throw new BadRequestException("external network doesn't have a subnet."); NeutronSubnet externSubnet = subnetInterface.getSubnet(externNetwork.getSubnets().get(0)); if (!externSubnet.isValidIP(floatingIP))