@Test public void testGetFloatingIp() throws Exception { when(openOperationUtil.executeNovaRequest(any(HttpUriRequest.class))). thenReturn(FLOATING_IPS); when(openStackConfig.getPublicFloatingPool(any(PaasManagerUser.class), anyString())). thenReturn("public-ext-net-01"); String floatingip = openStackUtil.getFloatingIP(paasManagerUser, "RegionOne"); assertEquals(floatingip, "130.206.112.238"); }
public String getFloatingIP(PaasManagerUser user, String region) throws OpenStackException { String floatingIP = null; String getFloatingIPsResponse = getFloatingIPs(region, user.getToken(), user.getTenantId()); String floatingIpPool = openStackConfigUtil.getPublicFloatingPool(user, region); try { if (isAnyFloatingIPFreeToBeAssigned(getFloatingIPsResponse)) { floatingIP = getFloatingIPFree(getFloatingIPsResponse); } else { floatingIP = allocateFloatingIP(buildAllocateFloatingIPPayload(floatingIpPool), region, user.getToken(), user.getTenantId()); getFloatingIPsResponse = getFloatingIPs(region, user.getToken(), user.getTenantId()); floatingIP = getFloatingIPFree(getFloatingIPsResponse); } } catch (JSONException e) { floatingIP = null; log.debug("Error to obtain the IP " + e.getMessage()); } return floatingIP; }
OpenStackUtilImpl implements OpenStackUtil { public String getFloatingIP(PaasManagerUser user, String region) throws OpenStackException { String floatingIP = null; String getFloatingIPsResponse = getFloatingIPs(region, user.getToken(), user.getTenantId()); String floatingIpPool = openStackConfigUtil.getPublicFloatingPool(user, region); try { if (isAnyFloatingIPFreeToBeAssigned(getFloatingIPsResponse)) { floatingIP = getFloatingIPFree(getFloatingIPsResponse); } else { floatingIP = allocateFloatingIP(buildAllocateFloatingIPPayload(floatingIpPool), region, user.getToken(), user.getTenantId()); getFloatingIPsResponse = getFloatingIPs(region, user.getToken(), user.getTenantId()); floatingIP = getFloatingIPFree(getFloatingIPsResponse); } } catch (JSONException e) { floatingIP = null; log.debug("Error to obtain the IP " + e.getMessage()); } return floatingIP; } }
OpenStackUtilImpl implements OpenStackUtil { public String getFloatingIP(PaasManagerUser user, String region) throws OpenStackException { String floatingIP = null; String getFloatingIPsResponse = getFloatingIPs(region, user.getToken(), user.getTenantId()); String floatingIpPool = openStackConfigUtil.getPublicFloatingPool(user, region); try { if (isAnyFloatingIPFreeToBeAssigned(getFloatingIPsResponse)) { floatingIP = getFloatingIPFree(getFloatingIPsResponse); } else { floatingIP = allocateFloatingIP(buildAllocateFloatingIPPayload(floatingIpPool), region, user.getToken(), user.getTenantId()); getFloatingIPsResponse = getFloatingIPs(region, user.getToken(), user.getTenantId()); floatingIP = getFloatingIPFree(getFloatingIPsResponse); } } catch (JSONException e) { floatingIP = null; log.debug("Error to obtain the IP " + e.getMessage()); } return floatingIP; } OpenStackUtilImpl(); }
OpenStackUtilImpl implements OpenStackUtil { public String getFloatingIP(PaasManagerUser user, String region) throws OpenStackException { String floatingIP = null; String getFloatingIPsResponse = getFloatingIPs(region, user.getToken(), user.getTenantId()); String floatingIpPool = openStackConfigUtil.getPublicFloatingPool(user, region); try { if (isAnyFloatingIPFreeToBeAssigned(getFloatingIPsResponse)) { floatingIP = getFloatingIPFree(getFloatingIPsResponse); } else { floatingIP = allocateFloatingIP(buildAllocateFloatingIPPayload(floatingIpPool), region, user.getToken(), user.getTenantId()); getFloatingIPsResponse = getFloatingIPs(region, user.getToken(), user.getTenantId()); floatingIP = getFloatingIPFree(getFloatingIPsResponse); } } catch (JSONException e) { floatingIP = null; log.debug("Error to obtain the IP " + e.getMessage()); } return floatingIP; } OpenStackUtilImpl(); HttpClientConnectionManager getHttpConnectionManager(); void setHttpConnectionManager(HttpClientConnectionManager httpConnectionManager); String addInterface(String idRouter, NetworkInstance net, String region, String token, String vdc); String addInterfaceToPublicRouter(PaasManagerUser user, NetworkInstance net, String region); String addRouterInterface(String routerId, String subNetId, String region, String token, String vdc); String allocateFloatingIP(String payload, String region, String token, String vdc); String getFloatingIPs(String region, String token, String vdc, String dd); void disAllocateFloatingIP(String region, String token, String vdc, String floatingIp); String assignFloatingIP(String serverId, String floatingIP, String region, String token, String vdc); String createNetwork(String payload, String region, String token, String vdc); String createRouter(RouterInstance router, String region, String token, String vdc); String createServer(String payload, String region, String token, String vdc); String createSubNet(SubNetworkInstance subNet, String region, String token, String vdc); String deleteNetwork(String networkId, String region, String token, String vdc); String deleteRouter(String routerId, String region, String token, String vdc); String deleteServer(String serverId, String region, String token, String vdc); void deleteSubNetwork(String idSubNet, String region, String vdc, String token); String getFloatingIP(PaasManagerUser user, String region); String getNetworkDetails(String networkId, String region, String token, String vdc); String getSubNetworkDetails(String subNetworkId, String region, String token, String vdc); String getNetworks(String region, String token, String vdc); String getServer(String serverId, String region, String token, String vdc); boolean existsServerForDelete(String serverId, String region, String token, String vdc); String listServers(String region, String token, String vdc); String removeInterface(RouterInstance router, String net, String region, String token, String vdc); String getAbsoluteLimits(PaasManagerUser user, String region); String listNetworks(PaasManagerUser user, String region); String listSubNetworks(PaasManagerUser user, String region); String listPorts(PaasManagerUser user, String region); String deleteInterfaceToPublicRouter(PaasManagerUser user, NetworkInstance net, String region); OpenStackRegion getOpenStackRegion(); void setOpenStackRegion(OpenStackRegion openStackRegion); void setOpenOperationUtil(OpenOperationUtil openOperationUtil); void setOpenStackConfigUtil(OpenStackConfigUtil openStackConfigUtil); String joinNetworks(NetworkInstance networkInstance, NetworkInstance networkInstance2, String token); }
OpenStackUtilImpl implements OpenStackUtil { public String getFloatingIP(PaasManagerUser user, String region) throws OpenStackException { String floatingIP = null; String getFloatingIPsResponse = getFloatingIPs(region, user.getToken(), user.getTenantId()); String floatingIpPool = openStackConfigUtil.getPublicFloatingPool(user, region); try { if (isAnyFloatingIPFreeToBeAssigned(getFloatingIPsResponse)) { floatingIP = getFloatingIPFree(getFloatingIPsResponse); } else { floatingIP = allocateFloatingIP(buildAllocateFloatingIPPayload(floatingIpPool), region, user.getToken(), user.getTenantId()); getFloatingIPsResponse = getFloatingIPs(region, user.getToken(), user.getTenantId()); floatingIP = getFloatingIPFree(getFloatingIPsResponse); } } catch (JSONException e) { floatingIP = null; log.debug("Error to obtain the IP " + e.getMessage()); } return floatingIP; } OpenStackUtilImpl(); HttpClientConnectionManager getHttpConnectionManager(); void setHttpConnectionManager(HttpClientConnectionManager httpConnectionManager); String addInterface(String idRouter, NetworkInstance net, String region, String token, String vdc); String addInterfaceToPublicRouter(PaasManagerUser user, NetworkInstance net, String region); String addRouterInterface(String routerId, String subNetId, String region, String token, String vdc); String allocateFloatingIP(String payload, String region, String token, String vdc); String getFloatingIPs(String region, String token, String vdc, String dd); void disAllocateFloatingIP(String region, String token, String vdc, String floatingIp); String assignFloatingIP(String serverId, String floatingIP, String region, String token, String vdc); String createNetwork(String payload, String region, String token, String vdc); String createRouter(RouterInstance router, String region, String token, String vdc); String createServer(String payload, String region, String token, String vdc); String createSubNet(SubNetworkInstance subNet, String region, String token, String vdc); String deleteNetwork(String networkId, String region, String token, String vdc); String deleteRouter(String routerId, String region, String token, String vdc); String deleteServer(String serverId, String region, String token, String vdc); void deleteSubNetwork(String idSubNet, String region, String vdc, String token); String getFloatingIP(PaasManagerUser user, String region); String getNetworkDetails(String networkId, String region, String token, String vdc); String getSubNetworkDetails(String subNetworkId, String region, String token, String vdc); String getNetworks(String region, String token, String vdc); String getServer(String serverId, String region, String token, String vdc); boolean existsServerForDelete(String serverId, String region, String token, String vdc); String listServers(String region, String token, String vdc); String removeInterface(RouterInstance router, String net, String region, String token, String vdc); String getAbsoluteLimits(PaasManagerUser user, String region); String listNetworks(PaasManagerUser user, String region); String listSubNetworks(PaasManagerUser user, String region); String listPorts(PaasManagerUser user, String region); String deleteInterfaceToPublicRouter(PaasManagerUser user, NetworkInstance net, String region); OpenStackRegion getOpenStackRegion(); void setOpenStackRegion(OpenStackRegion openStackRegion); void setOpenOperationUtil(OpenOperationUtil openOperationUtil); void setOpenStackConfigUtil(OpenStackConfigUtil openStackConfigUtil); String joinNetworks(NetworkInstance networkInstance, NetworkInstance networkInstance2, String token);  }