myPorts.remove(port);
}
+ public List<NeutronPort> getFloatingIpPortsInSubnet() {
+ List<NeutronPort> result = new ArrayList<NeutronPort>();
+ List<NeutronPort> ports = getPortsInSubnet();
+ for(NeutronPort port: ports) {
+ if(port.getDeviceOwner().equals("network:floatingip")) {
+ result.add(port);
+ }
+ }
+ return result;
+ }
+
+ public List<NeutronPort> getFloatingIpPortsInSubnet(String floatingIPaddress) {
+ List<NeutronPort> result = new ArrayList<NeutronPort>();
+ List<NeutronPort> floatingIpPorts = getFloatingIpPortsInSubnet();
+ for(NeutronPort port: floatingIpPorts) {
+ List<Neutron_IPs> fixedIps = port.getFixedIPs();
+ for(Neutron_IPs fixedIp: fixedIps) {
+ if(fixedIp.getIpAddress() != null && fixedIp.getIpAddress().equals(floatingIPaddress)) {
+ result.add(port);
+ break;
+ }
+ }
+ }
+ return result;
+ }
+
/* this method tests to see if the supplied IPv4 address
* is valid for this subnet or not
*/
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.isIPInUse(floatingIP))
+ 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