diff --git a/labs/openstack-quantum/pom.xml b/labs/openstack-quantum/pom.xml index f105267988..39b4ff1922 100644 --- a/labs/openstack-quantum/pom.xml +++ b/labs/openstack-quantum/pom.xml @@ -42,8 +42,6 @@ FIXME_IDENTITY FIXME_CREDENTIALS passwordCredentials - FIXME_HTTPURL - FIXME_HTTPMD5 @@ -54,7 +52,7 @@ org.jclouds - jclouds-blobstore + jclouds-core ${project.version} @@ -71,13 +69,6 @@ test-jar test - - org.jclouds - jclouds-blobstore - ${project.version} - test-jar - test - org.jclouds.driver jclouds-slf4j @@ -115,8 +106,6 @@ ${test.openstack-quantum.identity} ${test.openstack-quantum.credential} ${test.jclouds.keystone.credential-type} - ${jclouds.blobstore.httpstream.url} - ${jclouds.blobstore.httpstream.md5} diff --git a/labs/openstack-quantum/src/main/java/org/jclouds/openstack/quantum/v1_0/QuantumAsyncClient.java b/labs/openstack-quantum/src/main/java/org/jclouds/openstack/quantum/v1_0/QuantumAsyncClient.java index 53d85c9f37..98ffeb386c 100644 --- a/labs/openstack-quantum/src/main/java/org/jclouds/openstack/quantum/v1_0/QuantumAsyncClient.java +++ b/labs/openstack-quantum/src/main/java/org/jclouds/openstack/quantum/v1_0/QuantumAsyncClient.java @@ -20,6 +20,9 @@ package org.jclouds.openstack.quantum.v1_0; import java.util.Set; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; + import org.jclouds.javax.annotation.Nullable; import org.jclouds.location.Region; import org.jclouds.location.functions.RegionToEndpoint; @@ -57,5 +60,7 @@ public interface QuantumAsyncClient { * Provides asynchronous access to Port features. */ @Delegate - PortAsyncClient getPortClientForRegion(@EndpointParam(parser = RegionToEndpoint.class) @Nullable String region); + @Path("/networks/{net}") + PortAsyncClient getPortClientForRegionAndNetwork(@EndpointParam(parser = RegionToEndpoint.class) @Nullable String region, + @PathParam("net") String networkId); } diff --git a/labs/openstack-quantum/src/main/java/org/jclouds/openstack/quantum/v1_0/QuantumClient.java b/labs/openstack-quantum/src/main/java/org/jclouds/openstack/quantum/v1_0/QuantumClient.java index 8bd93615cb..d670036eb8 100644 --- a/labs/openstack-quantum/src/main/java/org/jclouds/openstack/quantum/v1_0/QuantumClient.java +++ b/labs/openstack-quantum/src/main/java/org/jclouds/openstack/quantum/v1_0/QuantumClient.java @@ -21,6 +21,9 @@ package org.jclouds.openstack.quantum.v1_0; import java.util.Set; import java.util.concurrent.TimeUnit; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; + import org.jclouds.concurrent.Timeout; import org.jclouds.javax.annotation.Nullable; import org.jclouds.location.Region; @@ -59,5 +62,7 @@ public interface QuantumClient { * Provides synchronous access to Port features. */ @Delegate - PortClient getPortClientForRegion(@EndpointParam(parser = RegionToEndpoint.class) @Nullable String region); + @Path("/networks/{net}") + PortClient getPortClientForRegionAndNetwork(@EndpointParam(parser = RegionToEndpoint.class) @Nullable String region, + @PathParam("net") String networkId); } diff --git a/labs/openstack-quantum/src/main/java/org/jclouds/openstack/quantum/v1_0/features/NetworkAsyncClient.java b/labs/openstack-quantum/src/main/java/org/jclouds/openstack/quantum/v1_0/features/NetworkAsyncClient.java index fbefb75d3c..b0d114e0c8 100644 --- a/labs/openstack-quantum/src/main/java/org/jclouds/openstack/quantum/v1_0/features/NetworkAsyncClient.java +++ b/labs/openstack-quantum/src/main/java/org/jclouds/openstack/quantum/v1_0/features/NetworkAsyncClient.java @@ -76,22 +76,22 @@ public interface NetworkAsyncClient { ListenableFuture> list(); /** - * @see NetworkClient#show + * @see NetworkClient#get */ @GET @SelectJson("network") @Path("/{id}") @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture show(@PathParam("id") String id); + ListenableFuture get(@PathParam("id") String id); /** - * @see NetworkClient#showDetails + * @see NetworkClient#getDetails */ @GET @SelectJson("network") @Path("/{id}/detail") @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture showDetails(@PathParam("id") String id); + ListenableFuture getDetails(@PathParam("id") String id); /** * @see NetworkClient#create @@ -103,13 +103,13 @@ public interface NetworkAsyncClient { ListenableFuture create(@PayloadParam("name") String name); /** - * @see NetworkClient#update + * @see NetworkClient#rename */ @PUT @Produces(MediaType.APPLICATION_JSON) @Path("/{id}") @WrapWith("network") - ListenableFuture update(@PathParam("id") String id, @PayloadParam("name") String name); + ListenableFuture rename(@PathParam("id") String id, @PayloadParam("name") String name); /** * @see NetworkClient#delete diff --git a/labs/openstack-quantum/src/main/java/org/jclouds/openstack/quantum/v1_0/features/NetworkClient.java b/labs/openstack-quantum/src/main/java/org/jclouds/openstack/quantum/v1_0/features/NetworkClient.java index 5647b33394..7ea23268a0 100644 --- a/labs/openstack-quantum/src/main/java/org/jclouds/openstack/quantum/v1_0/features/NetworkClient.java +++ b/labs/openstack-quantum/src/main/java/org/jclouds/openstack/quantum/v1_0/features/NetworkClient.java @@ -54,12 +54,12 @@ public interface NetworkClient { /** * Returns the specific network. */ - Network show(String id); + Network get(String id); /** * Returns the details of the specific network. */ - NetworkDetails showDetails(String id); + NetworkDetails getDetails(String id); /** * Create a new network with the specified symbolic name @@ -72,7 +72,7 @@ public interface NetworkClient { * @param id the id of the Network to modify * @param name the new name for the Network */ - Boolean update(String id, String name); + Boolean rename(String id, String name); /** * Deletes the specified network diff --git a/labs/openstack-quantum/src/main/java/org/jclouds/openstack/quantum/v1_0/features/PortAsyncClient.java b/labs/openstack-quantum/src/main/java/org/jclouds/openstack/quantum/v1_0/features/PortAsyncClient.java index 6eab8cc10e..9535bc6bf5 100644 --- a/labs/openstack-quantum/src/main/java/org/jclouds/openstack/quantum/v1_0/features/PortAsyncClient.java +++ b/labs/openstack-quantum/src/main/java/org/jclouds/openstack/quantum/v1_0/features/PortAsyncClient.java @@ -55,7 +55,7 @@ import com.google.common.util.concurrent.ListenableFuture; @SkipEncoding({'/', '='}) @RequestFilters(AuthenticateRequest.class) @Consumes(MediaType.APPLICATION_JSON) -@Path("/networks") +@Path("/ports") public interface PortAsyncClient { /** @@ -63,93 +63,90 @@ public interface PortAsyncClient { */ @GET @SelectJson("ports") - @Path("/{net}/ports") @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) - ListenableFuture> listReferences(@PathParam("net") String networkId); + ListenableFuture> listReferences(); /** * @see PortClient#list */ @GET @SelectJson("ports") - @Path("/{net}/ports/detail") + @Path("/detail") @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) - ListenableFuture> list(@PathParam("net") String networkId); + ListenableFuture> list(); /** - * @see PortClient#show + * @see PortClient#get */ @GET @SelectJson("port") - @Path("/{net}/ports/{id}") + @Path("/{id}") @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture show(@PathParam("net") String networkId, @PathParam("id") String id); + ListenableFuture get(@PathParam("id") String id); /** - * @see PortClient#showDetails + * @see PortClient#getDetails */ @GET @SelectJson("port") @Consumes(MediaType.APPLICATION_JSON) - @Path("/{net}/ports/{id}/detail") + @Path("/{id}/detail") @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture showDetails(@PathParam("net") String networkId, @PathParam("id") String id); + ListenableFuture getDetails(@PathParam("id") String id); /** - * @see PortClient#create(String) + * @see PortClient#create() */ @POST @SelectJson("port") - @Path("/{net}/ports") - ListenableFuture create(@PathParam("net") String networkId); + ListenableFuture create(); /** - * @see PortClient#create(String, org.jclouds.openstack.quantum.v1_0.domain.Port.State) + * @see PortClient#create(org.jclouds.openstack.quantum.v1_0.domain.Port.State) */ @POST @SelectJson("port") - @Path("/{net}/ports") @WrapWith("port") - ListenableFuture create(@PathParam("net") String networkId, @PayloadParam("state") Port.State state); + ListenableFuture create(@PayloadParam("state") Port.State state); /** - * @see PortClient#update + * @see PortClient#updateState */ @PUT - @Path("/{net}/ports/{id}") + @Path("/{id}") @WrapWith("port") - ListenableFuture update(@PathParam("net") String networkId, @PathParam("id") String id, @PayloadParam("state") Port.State state); + ListenableFuture updateState(@PathParam("id") String id, @PayloadParam("state") Port.State state); /** * @see PortClient#delete */ @DELETE - @Path("/{net}/ports/{id}") - ListenableFuture delete(@PathParam("net") String networkId, @PathParam("id") String id); + @Path("/{id}") + ListenableFuture delete(@PathParam("id") String id); /** * @see PortClient#showAttachment */ @GET @SelectJson("attachment") - @Path("/{net}/ports/{portId}/attachment") + @Path("/{id}/attachment") @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture showAttachment(@PathParam("net") String networkId, @PathParam("portId") String portId); + ListenableFuture showAttachment(@PathParam("id") String portId); /** * @see PortClient#plugAttachment */ @PUT - @Path("/{net}/ports/{portId}/attachment") + @Path("/{id}/attachment") @WrapWith("attachment") - ListenableFuture plugAttachment(@PathParam("net") String networkId, @PathParam("portId") String portId, + ListenableFuture plugAttachment(@PathParam("id") String portId, @PayloadParam("id") String attachmentId); /** * @see PortClient#unplugAttachment */ @DELETE - @Path("/{net}/ports/{portId}/attachment") - ListenableFuture unplugAttachment(@PathParam("net") String networkId, @PathParam("portId") String portId); + @Path("{id}/attachment") + ListenableFuture unplugAttachment(@PathParam("id") String portId); } diff --git a/labs/openstack-quantum/src/main/java/org/jclouds/openstack/quantum/v1_0/features/PortClient.java b/labs/openstack-quantum/src/main/java/org/jclouds/openstack/quantum/v1_0/features/PortClient.java index c500a97b13..155e19f2f4 100644 --- a/labs/openstack-quantum/src/main/java/org/jclouds/openstack/quantum/v1_0/features/PortClient.java +++ b/labs/openstack-quantum/src/main/java/org/jclouds/openstack/quantum/v1_0/features/PortClient.java @@ -44,55 +44,55 @@ public interface PortClient { /** * Returns the list of all ports currently defined in Quantum for the requested network */ - Set listReferences(String networkId); + Set listReferences(); /** * Returns the set of ports currently defined in Quantum for the requested network. */ - Set list(String networkId); + Set list(); /** * Returns a specific port. */ - Port show(String networkId, String id); + Port get(String id); /** * Returns a specific port in detail. */ - PortDetails showDetails(String networkId, String id); + PortDetails getDetails(String id); /** * Create a new port on the specified network */ - Reference create(String networkId); + Reference create(); /** * Create a new port on the specified network, with the requested state */ - Reference create(String networkId, Port.State state); + Reference create(Port.State state); /** * Updates the state of a port */ - Boolean update(String networkId, String id, Port.State state); + Boolean updateState(String id, Port.State state); /** * Deletes a port from a network */ - Boolean delete(String networkId, String id); + Boolean delete(String id); /** * Returns the attachment for the specified port. */ - Attachment showAttachment(String networkId, String portId); + Attachment showAttachment(String portId); /** * Plugs an attachment into the specified port */ - Boolean plugAttachment(String networkId, String portId, String attachmentId); + Boolean plugAttachment(String portId, String attachmentId); /** * Unplugs the attachment currently plugged into the specified port */ - Boolean unplugAttachment(String networkId, String portId); + Boolean unplugAttachment(String portId); } diff --git a/labs/openstack-quantum/src/test/java/org/jclouds/openstack/quantum/v1_0/features/NetworkClientExpectTest.java b/labs/openstack-quantum/src/test/java/org/jclouds/openstack/quantum/v1_0/features/NetworkClientExpectTest.java index b89b3ffc7b..0fc695e5f7 100644 --- a/labs/openstack-quantum/src/test/java/org/jclouds/openstack/quantum/v1_0/features/NetworkClientExpectTest.java +++ b/labs/openstack-quantum/src/test/java/org/jclouds/openstack/quantum/v1_0/features/NetworkClientExpectTest.java @@ -96,7 +96,7 @@ public class NetworkClientExpectTest extends BaseQuantumClientExpectTest { standardResponseBuilder(200).payload(payloadFromResourceWithContentType("/network.json", APPLICATION_JSON)).build()) .getNetworkClientForRegion("region-a.geo-1"); - Network net = client.show("16dba3bc-f3fa-4775-afdc-237e12c72f6a"); + Network net = client.get("16dba3bc-f3fa-4775-afdc-237e12c72f6a"); assertEquals(net, new ParseNetworkTest().expected()); } @@ -107,7 +107,7 @@ public class NetworkClientExpectTest extends BaseQuantumClientExpectTest { standardResponseBuilder(404).build()) .getNetworkClientForRegion("region-a.geo-1"); - assertNull(client.show("16dba3bc-f3fa-4775-afdc-237e12c72f6a")); + assertNull(client.get("16dba3bc-f3fa-4775-afdc-237e12c72f6a")); } public void testShowDetailsReturns2xx() { @@ -117,7 +117,7 @@ public class NetworkClientExpectTest extends BaseQuantumClientExpectTest { standardResponseBuilder(200).payload(payloadFromResourceWithContentType("/network_details.json", APPLICATION_JSON)).build()) .getNetworkClientForRegion("region-a.geo-1"); - NetworkDetails net = client.showDetails("16dba3bc-f3fa-4775-afdc-237e12c72f6a"); + NetworkDetails net = client.getDetails("16dba3bc-f3fa-4775-afdc-237e12c72f6a"); assertEquals(net, new ParseNetworkDetailsTest().expected()); } @@ -128,7 +128,7 @@ public class NetworkClientExpectTest extends BaseQuantumClientExpectTest { standardResponseBuilder(404).build()) .getNetworkClientForRegion("region-a.geo-1"); - assertNull(client.showDetails("16dba3bc-f3fa-4775-afdc-237e12c72f6a")); + assertNull(client.getDetails("16dba3bc-f3fa-4775-afdc-237e12c72f6a")); } public void testCreateReturns2xx() { @@ -163,7 +163,7 @@ public class NetworkClientExpectTest extends BaseQuantumClientExpectTest { standardResponseBuilder(200).build()) .getNetworkClientForRegion("region-a.geo-1"); - assertTrue(client.update("12345", "another-test")); + assertTrue(client.rename("12345", "another-test")); } @Test(expectedExceptions = ResourceNotFoundException.class) @@ -175,7 +175,7 @@ public class NetworkClientExpectTest extends BaseQuantumClientExpectTest { standardResponseBuilder(404).build()) .getNetworkClientForRegion("region-a.geo-1"); - client.update("12345", "another-test"); + client.rename("12345", "another-test"); } public void testDeleteReturns2xx() { diff --git a/labs/openstack-quantum/src/test/java/org/jclouds/openstack/quantum/v1_0/features/NetworkClientLiveTest.java b/labs/openstack-quantum/src/test/java/org/jclouds/openstack/quantum/v1_0/features/NetworkClientLiveTest.java index 80baef53f3..d807888dd8 100644 --- a/labs/openstack-quantum/src/test/java/org/jclouds/openstack/quantum/v1_0/features/NetworkClientLiveTest.java +++ b/labs/openstack-quantum/src/test/java/org/jclouds/openstack/quantum/v1_0/features/NetworkClientLiveTest.java @@ -59,8 +59,8 @@ public class NetworkClientLiveTest extends BaseQuantumClientLiveTest { Reference net = client.create("jclouds-test"); assertNotNull(net); - Network network = client.show(net.getId()); - NetworkDetails details = client.showDetails(net.getId()); + Network network = client.get(net.getId()); + NetworkDetails details = client.getDetails(net.getId()); for(Network checkme : ImmutableList.of(network, details)) { assertEquals(checkme.getId(), net.getId()); @@ -69,11 +69,11 @@ public class NetworkClientLiveTest extends BaseQuantumClientLiveTest { assertTrue(details.getPorts().isEmpty()); - assertTrue(client.update(net.getId(), "jclouds-live-test")); + assertTrue(client.rename(net.getId(), "jclouds-live-test")); // Grab the updated metadata - network = client.show(net.getId()); - details = client.showDetails(net.getId()); + network = client.get(net.getId()); + details = client.getDetails(net.getId()); for(Network checkme : ImmutableList.of(network, details)) { assertEquals(checkme.getId(), net.getId()); diff --git a/labs/openstack-quantum/src/test/java/org/jclouds/openstack/quantum/v1_0/features/PortClientExpectTest.java b/labs/openstack-quantum/src/test/java/org/jclouds/openstack/quantum/v1_0/features/PortClientExpectTest.java index 662210daaa..80434441ec 100644 --- a/labs/openstack-quantum/src/test/java/org/jclouds/openstack/quantum/v1_0/features/PortClientExpectTest.java +++ b/labs/openstack-quantum/src/test/java/org/jclouds/openstack/quantum/v1_0/features/PortClientExpectTest.java @@ -53,9 +53,9 @@ public class PortClientExpectTest extends BaseQuantumClientExpectTest { keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, standardRequestBuilder(endpoint + "/tenants/3456/networks/1a104cf5-cb18-4d35-9407-2fd2646d9d0b/ports").build(), standardResponseBuilder(200).payload(payloadFromStringWithContentType("{\"ports\": [{\"id\": \"a6058a59-fa8c-46cc-bac8-08904e6ff0a5\"}]}", APPLICATION_JSON)).build()) - .getPortClientForRegion("region-a.geo-1"); + .getPortClientForRegionAndNetwork("region-a.geo-1", "1a104cf5-cb18-4d35-9407-2fd2646d9d0b"); - Set nets = client.listReferences("1a104cf5-cb18-4d35-9407-2fd2646d9d0b"); + Set nets = client.listReferences(); assertEquals(nets, ImmutableSet.of(Reference.builder().id("a6058a59-fa8c-46cc-bac8-08904e6ff0a5").build())); } @@ -64,9 +64,9 @@ public class PortClientExpectTest extends BaseQuantumClientExpectTest { keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, standardRequestBuilder(endpoint + "/tenants/3456/networks/1a104cf5-cb18-4d35-9407-2fd2646d9d0b/ports").build(), standardResponseBuilder(404).build()) - .getPortClientForRegion("region-a.geo-1"); + .getPortClientForRegionAndNetwork("region-a.geo-1", "1a104cf5-cb18-4d35-9407-2fd2646d9d0b"); - assertTrue(client.listReferences("1a104cf5-cb18-4d35-9407-2fd2646d9d0b").isEmpty()); + assertTrue(client.listReferences().isEmpty()); } public void testListReturns2xx() { @@ -74,9 +74,9 @@ public class PortClientExpectTest extends BaseQuantumClientExpectTest { keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, standardRequestBuilder(endpoint + "/tenants/3456/networks/1a104cf5-cb18-4d35-9407-2fd2646d9d0b/ports/detail").build(), standardResponseBuilder(200).payload(payloadFromStringWithContentType("{\"ports\": [{\"state\": \"DOWN\", \"id\": \"814ae4bb-33d9-425f-8ee2-13a5c90b1465\"}]}", APPLICATION_JSON)).build()) - .getPortClientForRegion("region-a.geo-1"); + .getPortClientForRegionAndNetwork("region-a.geo-1", "1a104cf5-cb18-4d35-9407-2fd2646d9d0b"); - Set nets = client.list("1a104cf5-cb18-4d35-9407-2fd2646d9d0b"); + Set nets = client.list(); assertEquals(nets, ImmutableSet.of(Port.builder().state(Port.State.DOWN).id("814ae4bb-33d9-425f-8ee2-13a5c90b1465").build())); } @@ -85,9 +85,9 @@ public class PortClientExpectTest extends BaseQuantumClientExpectTest { keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, standardRequestBuilder(endpoint + "/tenants/3456/networks/1a104cf5-cb18-4d35-9407-2fd2646d9d0b/ports/detail").build(), standardResponseBuilder(404).build()) - .getPortClientForRegion("region-a.geo-1"); + .getPortClientForRegionAndNetwork("region-a.geo-1", "1a104cf5-cb18-4d35-9407-2fd2646d9d0b"); - assertTrue(client.list("1a104cf5-cb18-4d35-9407-2fd2646d9d0b").isEmpty()); + assertTrue(client.list().isEmpty()); } public void testShowReturns2xx() { @@ -95,9 +95,9 @@ public class PortClientExpectTest extends BaseQuantumClientExpectTest { keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, standardRequestBuilder(endpoint + "/tenants/3456/networks/16dba3bc-f3fa-4775-afdc-237e12c72f6a/ports/646c123b-871a-4124-9fa2-a94f04a582df").build(), standardResponseBuilder(200).payload(payloadFromResourceWithContentType("/port.json", APPLICATION_JSON)).build()) - .getPortClientForRegion("region-a.geo-1"); + .getPortClientForRegionAndNetwork("region-a.geo-1", "16dba3bc-f3fa-4775-afdc-237e12c72f6a"); - Port port = client.show("16dba3bc-f3fa-4775-afdc-237e12c72f6a", "646c123b-871a-4124-9fa2-a94f04a582df"); + Port port = client.get("646c123b-871a-4124-9fa2-a94f04a582df"); assertEquals(port, new ParsePortTest().expected()); } @@ -106,9 +106,9 @@ public class PortClientExpectTest extends BaseQuantumClientExpectTest { keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, standardRequestBuilder(endpoint + "/tenants/3456/networks/16dba3bc-f3fa-4775-afdc-237e12c72f6a/ports/646c123b-871a-4124-9fa2-a94f04a582df").build(), standardResponseBuilder(404).build()) - .getPortClientForRegion("region-a.geo-1"); + .getPortClientForRegionAndNetwork("region-a.geo-1", "16dba3bc-f3fa-4775-afdc-237e12c72f6a"); - assertNull(client.show("16dba3bc-f3fa-4775-afdc-237e12c72f6a", "646c123b-871a-4124-9fa2-a94f04a582df")); + assertNull(client.get("646c123b-871a-4124-9fa2-a94f04a582df")); } public void testShowDetailsReturns2xx() { @@ -116,9 +116,9 @@ public class PortClientExpectTest extends BaseQuantumClientExpectTest { keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, standardRequestBuilder(endpoint + "/tenants/3456/networks/16dba3bc-f3fa-4775-afdc-237e12c72f6a/ports/646c123b-871a-4124-9fa2-a94f04a582df/detail").build(), standardResponseBuilder(200).payload(payloadFromResourceWithContentType("/port_details.json", APPLICATION_JSON)).build()) - .getPortClientForRegion("region-a.geo-1"); + .getPortClientForRegionAndNetwork("region-a.geo-1", "16dba3bc-f3fa-4775-afdc-237e12c72f6a"); - PortDetails net = client.showDetails("16dba3bc-f3fa-4775-afdc-237e12c72f6a", "646c123b-871a-4124-9fa2-a94f04a582df"); + PortDetails net = client.getDetails("646c123b-871a-4124-9fa2-a94f04a582df"); assertEquals(net, new ParsePortDetailsTest().expected()); } @@ -127,9 +127,9 @@ public class PortClientExpectTest extends BaseQuantumClientExpectTest { keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, standardRequestBuilder(endpoint + "/tenants/3456/networks/16dba3bc-f3fa-4775-afdc-237e12c72f6a/ports/646c123b-871a-4124-9fa2-a94f04a582df/detail").build(), standardResponseBuilder(404).build()) - .getPortClientForRegion("region-a.geo-1"); + .getPortClientForRegionAndNetwork("region-a.geo-1", "16dba3bc-f3fa-4775-afdc-237e12c72f6a"); - assertNull(client.showDetails("16dba3bc-f3fa-4775-afdc-237e12c72f6a", "646c123b-871a-4124-9fa2-a94f04a582df")); + assertNull(client.getDetails("646c123b-871a-4124-9fa2-a94f04a582df")); } public void testCreateReturns2xx() { @@ -137,9 +137,9 @@ public class PortClientExpectTest extends BaseQuantumClientExpectTest { keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, standardRequestBuilder(endpoint + "/tenants/3456/networks/16dba3bc-f3fa-4775-afdc-237e12c72f6a/ports").method("POST").build(), standardResponseBuilder(200).payload(payloadFromStringWithContentType("{\"port\":{\"id\":\"12345\"}}", APPLICATION_JSON)).build()) - .getPortClientForRegion("region-a.geo-1"); + .getPortClientForRegionAndNetwork("region-a.geo-1", "16dba3bc-f3fa-4775-afdc-237e12c72f6a"); - Reference port = client.create("16dba3bc-f3fa-4775-afdc-237e12c72f6a"); + Reference port = client.create(); assertEquals(port, Reference.builder().id("12345").build()); } @@ -149,9 +149,9 @@ public class PortClientExpectTest extends BaseQuantumClientExpectTest { keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, standardRequestBuilder(endpoint + "/tenants/3456/networks/16dba3bc-f3fa-4775-afdc-237e12c72f6a/ports").method("POST").build(), standardResponseBuilder(404).build()) - .getPortClientForRegion("region-a.geo-1"); + .getPortClientForRegionAndNetwork("region-a.geo-1", "16dba3bc-f3fa-4775-afdc-237e12c72f6a"); - client.create("16dba3bc-f3fa-4775-afdc-237e12c72f6a"); + client.create(); } public void testUpdateReturns2xx() { @@ -160,9 +160,9 @@ public class PortClientExpectTest extends BaseQuantumClientExpectTest { standardRequestBuilder(endpoint + "/tenants/3456/networks/16dba3bc-f3fa-4775-afdc-237e12c72f6a/ports/77777").method("PUT") .payload(payloadFromStringWithContentType("{\"port\":{\"state\":\"ACTIVE\"}}", MediaType.APPLICATION_JSON)).build(), standardResponseBuilder(200).build()) - .getPortClientForRegion("region-a.geo-1"); + .getPortClientForRegionAndNetwork("region-a.geo-1", "16dba3bc-f3fa-4775-afdc-237e12c72f6a"); - assertTrue(client.update("16dba3bc-f3fa-4775-afdc-237e12c72f6a", "77777", Port.State.ACTIVE)); + assertTrue(client.updateState("77777", Port.State.ACTIVE)); } @Test(expectedExceptions = AuthorizationException.class) @@ -172,9 +172,9 @@ public class PortClientExpectTest extends BaseQuantumClientExpectTest { standardRequestBuilder(endpoint + "/tenants/3456/networks/16dba3bc-f3fa-4775-afdc-237e12c72f6a/ports/77777").method("PUT") .payload(payloadFromStringWithContentType("{\"port\":{\"state\":\"ACTIVE\"}}", MediaType.APPLICATION_JSON)).build(), standardResponseBuilder(401).build()) - .getPortClientForRegion("region-a.geo-1"); + .getPortClientForRegionAndNetwork("region-a.geo-1", "16dba3bc-f3fa-4775-afdc-237e12c72f6a"); - client.update("16dba3bc-f3fa-4775-afdc-237e12c72f6a", "77777", Port.State.ACTIVE); + client.updateState("77777", Port.State.ACTIVE); } public void testShowAttachment() { @@ -182,9 +182,9 @@ public class PortClientExpectTest extends BaseQuantumClientExpectTest { keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, standardRequestBuilder(endpoint + "/tenants/3456/networks/16dba3bc-f3fa-4775-afdc-237e12c72f6a/ports/77777/attachment").build(), standardResponseBuilder(200).payload(payloadFromResourceWithContentType("/attachment.json", APPLICATION_JSON)).build()) - .getPortClientForRegion("region-a.geo-1"); + .getPortClientForRegionAndNetwork("region-a.geo-1", "16dba3bc-f3fa-4775-afdc-237e12c72f6a"); - Attachment attachment = client.showAttachment("16dba3bc-f3fa-4775-afdc-237e12c72f6a", "77777"); + Attachment attachment = client.showAttachment("77777"); assertEquals(attachment, Attachment.builder().id("jclouds-live-test").build()); } @@ -193,9 +193,9 @@ public class PortClientExpectTest extends BaseQuantumClientExpectTest { keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, standardRequestBuilder(endpoint + "/tenants/3456/networks/16dba3bc-f3fa-4775-afdc-237e12c72f6a/ports/77777/attachment").build(), standardResponseBuilder(404).build()) - .getPortClientForRegion("region-a.geo-1"); + .getPortClientForRegionAndNetwork("region-a.geo-1", "16dba3bc-f3fa-4775-afdc-237e12c72f6a"); - assertNull(client.showAttachment("16dba3bc-f3fa-4775-afdc-237e12c72f6a", "77777")); + assertNull(client.showAttachment("77777")); } public void testPlugAttachment() { @@ -205,9 +205,9 @@ public class PortClientExpectTest extends BaseQuantumClientExpectTest { .payload(payloadFromStringWithContentType("{\"attachment\":{\"id\":\"jclouds-live-test\"}}", MediaType.APPLICATION_JSON)) .method("PUT").build(), standardResponseBuilder(200).build()) - .getPortClientForRegion("region-a.geo-1"); + .getPortClientForRegionAndNetwork("region-a.geo-1", "16dba3bc-f3fa-4775-afdc-237e12c72f6a"); - assertTrue(client.plugAttachment("16dba3bc-f3fa-4775-afdc-237e12c72f6a", "77777", "jclouds-live-test")); + assertTrue(client.plugAttachment("77777", "jclouds-live-test")); } @Test(expectedExceptions = AuthorizationException.class) @@ -218,18 +218,18 @@ public class PortClientExpectTest extends BaseQuantumClientExpectTest { .payload(payloadFromStringWithContentType("{\"attachment\":{\"id\":\"jclouds-live-test\"}}", MediaType.APPLICATION_JSON)) .method("PUT").build(), standardResponseBuilder(403).build()) - .getPortClientForRegion("region-a.geo-1"); + .getPortClientForRegionAndNetwork("region-a.geo-1", "16dba3bc-f3fa-4775-afdc-237e12c72f6a"); - client.plugAttachment("16dba3bc-f3fa-4775-afdc-237e12c72f6a", "77777", "jclouds-live-test"); + client.plugAttachment("77777", "jclouds-live-test"); } public void testUnplugAttachment() { PortClient client = requestsSendResponses( keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, standardRequestBuilder(endpoint + "/tenants/3456/networks/16dba3bc-f3fa-4775-afdc-237e12c72f6a/ports/77777/attachment").method("DELETE").build(), standardResponseBuilder(200).build()) - .getPortClientForRegion("region-a.geo-1"); + .getPortClientForRegionAndNetwork("region-a.geo-1", "16dba3bc-f3fa-4775-afdc-237e12c72f6a"); - assertTrue(client.unplugAttachment("16dba3bc-f3fa-4775-afdc-237e12c72f6a", "77777")); + assertTrue(client.unplugAttachment("77777")); } @Test(expectedExceptions = ResourceNotFoundException.class) @@ -238,9 +238,9 @@ public class PortClientExpectTest extends BaseQuantumClientExpectTest { keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, standardRequestBuilder(endpoint + "/tenants/3456/networks/16dba3bc-f3fa-4775-afdc-237e12c72f6a/ports/77777/attachment").method("DELETE").build(), standardResponseBuilder(404).build()) - .getPortClientForRegion("region-a.geo-1"); + .getPortClientForRegionAndNetwork("region-a.geo-1", "16dba3bc-f3fa-4775-afdc-237e12c72f6a"); - client.unplugAttachment("16dba3bc-f3fa-4775-afdc-237e12c72f6a", "77777"); + client.unplugAttachment("77777"); } } diff --git a/labs/openstack-quantum/src/test/java/org/jclouds/openstack/quantum/v1_0/features/PortClientLiveTest.java b/labs/openstack-quantum/src/test/java/org/jclouds/openstack/quantum/v1_0/features/PortClientLiveTest.java index 75f02de0dc..dfab804255 100644 --- a/labs/openstack-quantum/src/test/java/org/jclouds/openstack/quantum/v1_0/features/PortClientLiveTest.java +++ b/labs/openstack-quantum/src/test/java/org/jclouds/openstack/quantum/v1_0/features/PortClientLiveTest.java @@ -46,11 +46,11 @@ public class PortClientLiveTest extends BaseQuantumClientLiveTest { public void testListPorts() { for (String regionId : quantumContext.getApi().getConfiguredRegions()) { NetworkClient netClient = quantumContext.getApi().getNetworkClientForRegion(regionId); - PortClient portClient = quantumContext.getApi().getPortClientForRegion(regionId); Set nets = netClient.listReferences(); for(Reference net : nets) { - Set portRefs = portClient.listReferences(net.getId()); - Set ports = portClient.list(net.getId()); + PortClient portClient = quantumContext.getApi().getPortClientForRegionAndNetwork(regionId, net.getId()); + Set portRefs = portClient.listReferences(); + Set ports = portClient.list(); assertEquals(portRefs.size(), ports.size()); for (Port port : ports) { @@ -63,16 +63,16 @@ public class PortClientLiveTest extends BaseQuantumClientLiveTest { public void testCreateUpdateAndDeletePort() { for (String regionId : quantumContext.getApi().getConfiguredRegions()) { NetworkClient netClient = quantumContext.getApi().getNetworkClientForRegion(regionId); - PortClient portClient = quantumContext.getApi().getPortClientForRegion(regionId); Reference net = netClient.create("jclouds-port-test"); assertNotNull(net); - - Reference portRef = portClient.create(net.getId()); + PortClient portClient = quantumContext.getApi().getPortClientForRegionAndNetwork(regionId, net.getId()); + + Reference portRef = portClient.create(); assertNotNull(portRef); - Port port = portClient.show(net.getId(), portRef.getId()); - PortDetails portDetails = portClient.showDetails(net.getId(), portRef.getId()); - NetworkDetails networkDetails = netClient.showDetails(net.getId()); + Port port = portClient.get(portRef.getId()); + PortDetails portDetails = portClient.getDetails(portRef.getId()); + NetworkDetails networkDetails = netClient.getDetails(net.getId()); assertEquals(port.getState(), portDetails.getState()); @@ -80,29 +80,29 @@ public class PortClientLiveTest extends BaseQuantumClientLiveTest { assertEquals(checkme.getId(), portRef.getId()); } - assertTrue(portClient.update(net.getId(), portRef.getId(), Port.State.DOWN)); + assertTrue(portClient.updateState(portRef.getId(), Port.State.DOWN)); - port = portClient.show(net.getId(), portRef.getId()); - portDetails = portClient.showDetails(net.getId(), portRef.getId()); + port = portClient.get(portRef.getId()); + portDetails = portClient.getDetails(portRef.getId()); for(Port checkme : ImmutableList.of(port, portDetails)) { assertEquals(checkme.getId(), portRef.getId()); assertEquals(checkme.getState(), Port.State.DOWN); } - assertTrue(portClient.plugAttachment(net.getId(), port.getId(), "jclouds-live-test")); + assertTrue(portClient.plugAttachment(port.getId(), "jclouds-live-test")); - Attachment attachment = portClient.showAttachment(net.getId(), port.getId()); - portDetails = portClient.showDetails(net.getId(), portRef.getId()); + Attachment attachment = portClient.showAttachment(port.getId()); + portDetails = portClient.getDetails(portRef.getId()); for(Attachment checkme : ImmutableList.of(attachment, portDetails.getAttachment())) { assertNotNull(checkme); assertEquals(checkme.getId(), "jclouds-live-test"); } - assertTrue(portClient.unplugAttachment(net.getId(), port.getId())); + assertTrue(portClient.unplugAttachment(port.getId())); - assertTrue(portClient.delete(net.getId(), portRef.getId())); + assertTrue(portClient.delete(portRef.getId())); assertTrue(netClient.delete(net.getId())); } } @@ -111,26 +111,27 @@ public class PortClientLiveTest extends BaseQuantumClientLiveTest { public void testAttachAndDetachPort() { for (String regionId : quantumContext.getApi().getConfiguredRegions()) { NetworkClient netClient = quantumContext.getApi().getNetworkClientForRegion(regionId); - PortClient portClient = quantumContext.getApi().getPortClientForRegion(regionId); Reference net = netClient.create("jclouds-attach-test"); assertNotNull(net); - Reference port = portClient.create(net.getId()); + PortClient portClient = quantumContext.getApi().getPortClientForRegionAndNetwork(regionId, net.getId()); + + Reference port = portClient.create(); assertNotNull(port); - assertTrue(portClient.plugAttachment(net.getId(), port.getId(), "jclouds-live-test")); + assertTrue(portClient.plugAttachment(port.getId(), "jclouds-live-test")); - Attachment attachment = portClient.showAttachment(net.getId(), port.getId()); - PortDetails portDetails = portClient.showDetails(net.getId(), port.getId()); + Attachment attachment = portClient.showAttachment(port.getId()); + PortDetails portDetails = portClient.getDetails(port.getId()); for(Attachment checkme : ImmutableList.of(attachment, portDetails.getAttachment())) { assertNotNull(checkme); assertEquals(checkme.getId(), "jclouds-live-test"); } - assertTrue(portClient.unplugAttachment(net.getId(), port.getId())); + assertTrue(portClient.unplugAttachment(port.getId())); - assertTrue(portClient.delete(net.getId(), port.getId())); + assertTrue(portClient.delete(port.getId())); assertTrue(netClient.delete(net.getId())); } }