@Test public void testGetAllPredefinedFloatingIPs() throws Exception { List<String> allPredefinedFloatingIPs = neutronNetworkingApi.getAllPredefinedFloatingIPs(networkInterfaces); Assert.assertEquals(String.format("%s. Predefined floating IP count not valid", validationError), 1, allPredefinedFloatingIPs.size()); Assert.assertTrue(String.format("%s. Predefined floating IP not returned", validationError), allPredefinedFloatingIPs.contains("192.168.16.59")); }
public List<String> getAllPredefinedFloatingIPs(NetworkInterface[] networkInterfaces) { String nwInterfacesNullMsg = "Input NetworkInterface array cannot be null"; assertNotNull(networkInterfaces, nwInterfacesNullMsg); List<String> allPredefinedFloatingIPs = new ArrayList<String>(); for (NetworkInterface networkInterface : networkInterfaces) { if (null == networkInterface.getFloatingNetworks()) { continue; } FloatingNetwork[] floatingNetworks = networkInterface.getFloatingNetworks().getFloatingNetworks(); if (floatingNetworks == null || floatingNetworks.length == 0) { continue; } for (FloatingNetwork floatingNetwork : floatingNetworks) { String floatingIP = floatingNetwork.getFloatingIP(); String networkUuid = floatingNetwork.getNetworkUuid(); if (networkUuid == null || networkUuid.isEmpty()) { if (floatingIP != null && InetAddresses.isInetAddress(floatingIP)) { allPredefinedFloatingIPs.add(floatingIP); } } } } return allPredefinedFloatingIPs; }
NeutronNetworkingApi implements OpenstackNetworkingApi { public List<String> getAllPredefinedFloatingIPs(NetworkInterface[] networkInterfaces) { String nwInterfacesNullMsg = "Input NetworkInterface array cannot be null"; assertNotNull(networkInterfaces, nwInterfacesNullMsg); List<String> allPredefinedFloatingIPs = new ArrayList<String>(); for (NetworkInterface networkInterface : networkInterfaces) { if (null == networkInterface.getFloatingNetworks()) { continue; } FloatingNetwork[] floatingNetworks = networkInterface.getFloatingNetworks().getFloatingNetworks(); if (floatingNetworks == null || floatingNetworks.length == 0) { continue; } for (FloatingNetwork floatingNetwork : floatingNetworks) { String floatingIP = floatingNetwork.getFloatingIP(); String networkUuid = floatingNetwork.getNetworkUuid(); if (networkUuid == null || networkUuid.isEmpty()) { if (floatingIP != null && InetAddresses.isInetAddress(floatingIP)) { allPredefinedFloatingIPs.add(floatingIP); } } } } return allPredefinedFloatingIPs; } }
NeutronNetworkingApi implements OpenstackNetworkingApi { public List<String> getAllPredefinedFloatingIPs(NetworkInterface[] networkInterfaces) { String nwInterfacesNullMsg = "Input NetworkInterface array cannot be null"; assertNotNull(networkInterfaces, nwInterfacesNullMsg); List<String> allPredefinedFloatingIPs = new ArrayList<String>(); for (NetworkInterface networkInterface : networkInterfaces) { if (null == networkInterface.getFloatingNetworks()) { continue; } FloatingNetwork[] floatingNetworks = networkInterface.getFloatingNetworks().getFloatingNetworks(); if (floatingNetworks == null || floatingNetworks.length == 0) { continue; } for (FloatingNetwork floatingNetwork : floatingNetworks) { String floatingIP = floatingNetwork.getFloatingIP(); String networkUuid = floatingNetwork.getNetworkUuid(); if (networkUuid == null || networkUuid.isEmpty()) { if (floatingIP != null && InetAddresses.isInetAddress(floatingIP)) { allPredefinedFloatingIPs.add(floatingIP); } } } } return allPredefinedFloatingIPs; } NeutronNetworkingApi(IaasProvider iaasProvider); }
NeutronNetworkingApi implements OpenstackNetworkingApi { public List<String> getAllPredefinedFloatingIPs(NetworkInterface[] networkInterfaces) { String nwInterfacesNullMsg = "Input NetworkInterface array cannot be null"; assertNotNull(networkInterfaces, nwInterfacesNullMsg); List<String> allPredefinedFloatingIPs = new ArrayList<String>(); for (NetworkInterface networkInterface : networkInterfaces) { if (null == networkInterface.getFloatingNetworks()) { continue; } FloatingNetwork[] floatingNetworks = networkInterface.getFloatingNetworks().getFloatingNetworks(); if (floatingNetworks == null || floatingNetworks.length == 0) { continue; } for (FloatingNetwork floatingNetwork : floatingNetworks) { String floatingIP = floatingNetwork.getFloatingIP(); String networkUuid = floatingNetwork.getNetworkUuid(); if (networkUuid == null || networkUuid.isEmpty()) { if (floatingIP != null && InetAddresses.isInetAddress(floatingIP)) { allPredefinedFloatingIPs.add(floatingIP); } } } } return allPredefinedFloatingIPs; } NeutronNetworkingApi(IaasProvider iaasProvider); @Override List<String> associateAddresses(NodeMetadata node); @Override String associatePredefinedAddress(NodeMetadata node, String ip); @Override void releaseAddress(String ip); Map<String, List<FloatingNetwork>> getNetworkUuidToFloatingNetworksMap(NetworkInterface[] networkInterfaces); Map<String, List<FloatingNetwork>> getFixedIPToFloatingNetworksMap(NetworkInterface[] networkInterfaces); List<String> getAllPredefinedFloatingIPs(NetworkInterface[] networkInterfaces); }
NeutronNetworkingApi implements OpenstackNetworkingApi { public List<String> getAllPredefinedFloatingIPs(NetworkInterface[] networkInterfaces) { String nwInterfacesNullMsg = "Input NetworkInterface array cannot be null"; assertNotNull(networkInterfaces, nwInterfacesNullMsg); List<String> allPredefinedFloatingIPs = new ArrayList<String>(); for (NetworkInterface networkInterface : networkInterfaces) { if (null == networkInterface.getFloatingNetworks()) { continue; } FloatingNetwork[] floatingNetworks = networkInterface.getFloatingNetworks().getFloatingNetworks(); if (floatingNetworks == null || floatingNetworks.length == 0) { continue; } for (FloatingNetwork floatingNetwork : floatingNetworks) { String floatingIP = floatingNetwork.getFloatingIP(); String networkUuid = floatingNetwork.getNetworkUuid(); if (networkUuid == null || networkUuid.isEmpty()) { if (floatingIP != null && InetAddresses.isInetAddress(floatingIP)) { allPredefinedFloatingIPs.add(floatingIP); } } } } return allPredefinedFloatingIPs; } NeutronNetworkingApi(IaasProvider iaasProvider); @Override List<String> associateAddresses(NodeMetadata node); @Override String associatePredefinedAddress(NodeMetadata node, String ip); @Override void releaseAddress(String ip); Map<String, List<FloatingNetwork>> getNetworkUuidToFloatingNetworksMap(NetworkInterface[] networkInterfaces); Map<String, List<FloatingNetwork>> getFixedIPToFloatingNetworksMap(NetworkInterface[] networkInterfaces); List<String> getAllPredefinedFloatingIPs(NetworkInterface[] networkInterfaces);  }