mirror of https://github.com/apache/jclouds.git
Add the possibility to create a floating IP from a pool of floating IPs
This commit is contained in:
parent
ef08f1b8d3
commit
4bbf8380c7
|
@ -57,6 +57,15 @@ public interface FloatingIPApi {
|
|||
*/
|
||||
FloatingIP create();
|
||||
|
||||
/**
|
||||
* Allocate a Floating IP address from a pool
|
||||
*
|
||||
* @param pool
|
||||
* Pool to allocate IP address from
|
||||
* @return a newly created FloatingIP
|
||||
*/
|
||||
FloatingIP create(String pool);
|
||||
|
||||
/**
|
||||
* Decreate a Floating IP address
|
||||
*
|
||||
|
|
|
@ -97,6 +97,20 @@ public interface FloatingIPAsyncApi {
|
|||
@Payload("{}")
|
||||
ListenableFuture<? extends FloatingIP> create();
|
||||
|
||||
/**
|
||||
* @see org.jclouds.openstack.nova.v2_0.extensions.FloatingIPApi#create
|
||||
*/
|
||||
@Named("floatingip:create")
|
||||
@POST
|
||||
@Path("/os-floating-ips")
|
||||
@SelectJson("floating_ip")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Fallback(NullOnNotFoundOr404.class)
|
||||
@Payload("%7B\"pool\":\"{pool}\"%7D")
|
||||
ListenableFuture<? extends FloatingIP> create(@PayloadParam("pool") String pool);
|
||||
|
||||
|
||||
/**
|
||||
* @see FloatingIPApi#delete
|
||||
*/
|
||||
|
|
|
@ -171,4 +171,23 @@ public class FloatingIPApiExpectTest extends BaseNovaApiExpectTest {
|
|||
assertNull(apiWhenNoServersExist.getFloatingIPExtensionForZone("az-1.region-a.geo-1").get().create());
|
||||
}
|
||||
|
||||
public void testAllocateWithPoolNameWhenResponseIs2xx() 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("{\"pool\":\"myPool\"}", "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("myPool").toString(),
|
||||
new ParseFloatingIPTest().expected().toString());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -173,4 +173,25 @@ public class FloatingIPAsyncApiExpectTest extends BaseNovaAsyncApiExpectTest {
|
|||
assertNull(apiWhenNoServersExist.getFloatingIPExtensionForZone("az-1.region-a.geo-1").get().create().get());
|
||||
}
|
||||
|
||||
public void testAllocateWithPoolNameWhenResponseIs2xx() 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("{\"pool\":\"myPool\"}", "application/json")).build();
|
||||
|
||||
HttpResponse createFloatingIPResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResource("/floatingip_details.json")).build();
|
||||
|
||||
NovaAsyncApi apiWhenFloatingIPsExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, createFloatingIP,
|
||||
createFloatingIPResponse);
|
||||
|
||||
assertEquals(apiWhenFloatingIPsExist.getFloatingIPExtensionForZone("az-1.region-a.geo-1").get().create("myPool")
|
||||
.get()
|
||||
.toString(), new ParseFloatingIPTest().expected().toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue