ip = floatingIpApi.create(); return Optional.of(ip); } catch (ResourceNotFoundException ex) {
ip = floatingIpApi.create(); return Optional.of(ip); } catch (ResourceNotFoundException ex) {
try { logger.debug(">> allocating or reassigning floating ip for node(%s)", node.getId()); ip = floatingIpApi.create(); } catch (InsufficientResourcesException e) { logger.trace("<< [%s] allocating a new floating ip for node(%s)", e.getMessage(), node.getId());
ip = floatingIpApi.create(); return Optional.of(ip); } catch (ResourceNotFoundException ex) {
try { logger.debug(">> allocating or reassigning floating ip for node(%s)", node.getId()); ip = floatingIpApi.create(); } catch (InsufficientResourcesException e) { logger.trace("<< [%s] allocating a new floating ip for node(%s)", e.getMessage(), node.getId());
try { logger.debug(">> allocating or reassigning floating ip for node(%s)", node.getId()); ip = floatingIpApi.create(); } catch (InsufficientResourcesException e) { logger.trace("<< [%s] allocating a new floating ip for node(%s)", e.getMessage(), node.getId());
@Test public void testAllocateAndDecreateFloatingIPs() throws Exception { for (String zoneId : api.getConfiguredZones()) { Optional<? extends FloatingIPApi> apiOption = api.getFloatingIPExtensionForZone(zoneId); if (!apiOption.isPresent()) continue; FloatingIPApi api = apiOption.get(); FloatingIP floatingIP = api.create(); assertNotNull(floatingIP); Set<? extends FloatingIP> response = api.list().toSet(); boolean ipInSet = false; for (FloatingIP ip : response) { if (ip.getId().equals(floatingIP.getId())) ipInSet = true; } assertTrue(ipInSet); api.delete(floatingIP.getId()); response = api.list().toSet(); ipInSet = false; for (FloatingIP ip : response) { if (ip.getId().equals(floatingIP.getId())) { ipInSet = true; } } assertFalse(ipInSet); } }
@Test public void testAllocateAndDecreateFloatingIPs() throws Exception { for (String regionId : api.getConfiguredRegions()) { Optional<? extends FloatingIPApi> apiOption = api.getFloatingIPApi(regionId); if (!apiOption.isPresent()) continue; FloatingIPApi api = apiOption.get(); FloatingIP floatingIP = api.create(); assertNotNull(floatingIP); Set<? extends FloatingIP> response = api.list().toSet(); boolean ipInSet = false; for (FloatingIP ip : response) { if (ip.getId().equals(floatingIP.getId())) ipInSet = true; } assertTrue(ipInSet); api.delete(floatingIP.getId()); response = api.list().toSet(); ipInSet = false; for (FloatingIP ip : response) { if (ip.getId().equals(floatingIP.getId())) { ipInSet = true; } } assertFalse(ipInSet); } }
public void testAllocateWhenResponseIs404() throws Exception { HttpRequest createFloatingIP = HttpRequest .builder() .method("POST") .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-floating-ips") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken) .payload(payloadFromStringWithContentType("{}", "application/json")).build(); HttpResponse createFloatingIPResponse = HttpResponse.builder().statusCode(404).build(); NovaApi apiWhenNoServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, createFloatingIP, createFloatingIPResponse); assertNull(apiWhenNoServersExist.getFloatingIPExtensionForZone("az-1.region-a.geo-1").get().create()); }
@Test public void testAddAndRemoveFloatingIp() throws Exception { for (String zoneId : api.getConfiguredZones()) { Optional<? extends FloatingIPApi> apiOption = api.getFloatingIPExtensionForZone(zoneId); if (!apiOption.isPresent()) continue; FloatingIPApi api = apiOption.get(); ServerApi serverApi = this.api.getServerApiForZone(zoneId); Server server = createServerInZone(zoneId); FloatingIP floatingIP = api.create(); assertNotNull(floatingIP); try { api.addToServer(floatingIP.getIp(), server.getId()); assertEventually(new ServerHasFloatingIP(serverApi, server.getId(), floatingIP.getIp())); } finally { api.removeFromServer(floatingIP.getIp(), server.getId()); serverApi.delete(server.getId()); } } }
@Test public void testAddAndRemoveFloatingIp() throws Exception { for (String regionId : api.getConfiguredRegions()) { Optional<? extends FloatingIPApi> apiOption = api.getFloatingIPApi(regionId); if (!apiOption.isPresent()) continue; FloatingIPApi api = apiOption.get(); ServerApi serverApi = this.api.getServerApi(regionId); Server server = createServerInRegion(regionId); FloatingIP floatingIP = api.create(); assertNotNull(floatingIP); try { api.addToServer(floatingIP.getIp(), server.getId()); assertEventually(new ServerHasFloatingIP(serverApi, server.getId(), floatingIP.getIp())); } finally { api.removeFromServer(floatingIP.getIp(), server.getId()); serverApi.delete(server.getId()); } } }
public void testAllocateWhenResponseIs2xx() throws Exception { HttpRequest createFloatingIP = HttpRequest .builder() .method("POST") .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-floating-ips") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken) .payload(payloadFromStringWithContentType("{}", "application/json")).build(); HttpResponse createFloatingIPResponse = HttpResponse.builder().statusCode(200) .payload(payloadFromResource("/floatingip_details.json")).build(); NovaApi apiWhenFloatingIPsExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, createFloatingIP, createFloatingIPResponse); assertEquals(apiWhenFloatingIPsExist.getFloatingIPExtensionForZone("az-1.region-a.geo-1").get().create().toString(), new ParseFloatingIPTest().expected().toString()); }
public void testAllocateWhenResponseIs2xx() throws Exception { HttpRequest createFloatingIP = HttpRequest .builder() .method("POST") .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-floating-ips") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken) .payload(payloadFromStringWithContentType("{}", "application/json")).build(); HttpResponse createFloatingIPResponse = HttpResponse.builder().statusCode(200) .payload(payloadFromResource("/floatingip_details.json")).build(); NovaApi apiWhenFloatingIPsExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, createFloatingIP, createFloatingIPResponse); assertEquals(apiWhenFloatingIPsExist.getFloatingIPApi("az-1.region-a.geo-1").get().create().toString(), new ParseFloatingIPTest().expected().toString()); }