mirror of https://github.com/apache/jclouds.git
openstack-quantum: addressing review comments - adjusting method names and using @Path and @PathParam on delegate method to simplify PortClient
This commit is contained in:
parent
4008407de3
commit
c9de23a272
|
@ -42,8 +42,6 @@
|
|||
<test.openstack-quantum.identity>FIXME_IDENTITY</test.openstack-quantum.identity>
|
||||
<test.openstack-quantum.credential>FIXME_CREDENTIALS</test.openstack-quantum.credential>
|
||||
<test.jclouds.keystone.credential-type>passwordCredentials</test.jclouds.keystone.credential-type>
|
||||
<jclouds.blobstore.httpstream.url>FIXME_HTTPURL</jclouds.blobstore.httpstream.url>
|
||||
<jclouds.blobstore.httpstream.md5>FIXME_HTTPMD5</jclouds.blobstore.httpstream.md5>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
@ -54,7 +52,7 @@
|
|||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jclouds</groupId>
|
||||
<artifactId>jclouds-blobstore</artifactId>
|
||||
<artifactId>jclouds-core</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -71,13 +69,6 @@
|
|||
<type>test-jar</type>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jclouds</groupId>
|
||||
<artifactId>jclouds-blobstore</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>test-jar</type>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jclouds.driver</groupId>
|
||||
<artifactId>jclouds-slf4j</artifactId>
|
||||
|
@ -115,8 +106,6 @@
|
|||
<test.openstack-quantum.identity>${test.openstack-quantum.identity}</test.openstack-quantum.identity>
|
||||
<test.openstack-quantum.credential>${test.openstack-quantum.credential}</test.openstack-quantum.credential>
|
||||
<test.jclouds.keystone.credential-type>${test.jclouds.keystone.credential-type}</test.jclouds.keystone.credential-type>
|
||||
<jclouds.blobstore.httpstream.url>${jclouds.blobstore.httpstream.url}</jclouds.blobstore.httpstream.url>
|
||||
<jclouds.blobstore.httpstream.md5>${jclouds.blobstore.httpstream.md5}</jclouds.blobstore.httpstream.md5>
|
||||
</systemPropertyVariables>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -76,22 +76,22 @@ public interface NetworkAsyncClient {
|
|||
ListenableFuture<Set<Network>> list();
|
||||
|
||||
/**
|
||||
* @see NetworkClient#show
|
||||
* @see NetworkClient#get
|
||||
*/
|
||||
@GET
|
||||
@SelectJson("network")
|
||||
@Path("/{id}")
|
||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||
ListenableFuture<Network> show(@PathParam("id") String id);
|
||||
ListenableFuture<Network> get(@PathParam("id") String id);
|
||||
|
||||
/**
|
||||
* @see NetworkClient#showDetails
|
||||
* @see NetworkClient#getDetails
|
||||
*/
|
||||
@GET
|
||||
@SelectJson("network")
|
||||
@Path("/{id}/detail")
|
||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||
ListenableFuture<NetworkDetails> showDetails(@PathParam("id") String id);
|
||||
ListenableFuture<NetworkDetails> getDetails(@PathParam("id") String id);
|
||||
|
||||
/**
|
||||
* @see NetworkClient#create
|
||||
|
@ -103,13 +103,13 @@ public interface NetworkAsyncClient {
|
|||
ListenableFuture<Reference> create(@PayloadParam("name") String name);
|
||||
|
||||
/**
|
||||
* @see NetworkClient#update
|
||||
* @see NetworkClient#rename
|
||||
*/
|
||||
@PUT
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Path("/{id}")
|
||||
@WrapWith("network")
|
||||
ListenableFuture<Boolean> update(@PathParam("id") String id, @PayloadParam("name") String name);
|
||||
ListenableFuture<Boolean> rename(@PathParam("id") String id, @PayloadParam("name") String name);
|
||||
|
||||
/**
|
||||
* @see NetworkClient#delete
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<Set<Reference>> listReferences(@PathParam("net") String networkId);
|
||||
ListenableFuture<Set<Reference>> listReferences();
|
||||
|
||||
/**
|
||||
* @see PortClient#list
|
||||
*/
|
||||
@GET
|
||||
@SelectJson("ports")
|
||||
@Path("/{net}/ports/detail")
|
||||
@Path("/detail")
|
||||
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
|
||||
ListenableFuture<Set<Port>> list(@PathParam("net") String networkId);
|
||||
ListenableFuture<Set<Port>> list();
|
||||
|
||||
/**
|
||||
* @see PortClient#show
|
||||
* @see PortClient#get
|
||||
*/
|
||||
@GET
|
||||
@SelectJson("port")
|
||||
@Path("/{net}/ports/{id}")
|
||||
@Path("/{id}")
|
||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||
ListenableFuture<Port> show(@PathParam("net") String networkId, @PathParam("id") String id);
|
||||
ListenableFuture<Port> 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<PortDetails> showDetails(@PathParam("net") String networkId, @PathParam("id") String id);
|
||||
ListenableFuture<PortDetails> getDetails(@PathParam("id") String id);
|
||||
|
||||
/**
|
||||
* @see PortClient#create(String)
|
||||
* @see PortClient#create()
|
||||
*/
|
||||
@POST
|
||||
@SelectJson("port")
|
||||
@Path("/{net}/ports")
|
||||
ListenableFuture<Reference> create(@PathParam("net") String networkId);
|
||||
ListenableFuture<Reference> 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<Port> create(@PathParam("net") String networkId, @PayloadParam("state") Port.State state);
|
||||
ListenableFuture<Port> create(@PayloadParam("state") Port.State state);
|
||||
|
||||
/**
|
||||
* @see PortClient#update
|
||||
* @see PortClient#updateState
|
||||
*/
|
||||
@PUT
|
||||
@Path("/{net}/ports/{id}")
|
||||
@Path("/{id}")
|
||||
@WrapWith("port")
|
||||
ListenableFuture<Boolean> update(@PathParam("net") String networkId, @PathParam("id") String id, @PayloadParam("state") Port.State state);
|
||||
ListenableFuture<Boolean> updateState(@PathParam("id") String id, @PayloadParam("state") Port.State state);
|
||||
|
||||
/**
|
||||
* @see PortClient#delete
|
||||
*/
|
||||
@DELETE
|
||||
@Path("/{net}/ports/{id}")
|
||||
ListenableFuture<Boolean> delete(@PathParam("net") String networkId, @PathParam("id") String id);
|
||||
@Path("/{id}")
|
||||
ListenableFuture<Boolean> delete(@PathParam("id") String id);
|
||||
|
||||
/**
|
||||
* @see PortClient#showAttachment
|
||||
*/
|
||||
@GET
|
||||
@SelectJson("attachment")
|
||||
@Path("/{net}/ports/{portId}/attachment")
|
||||
@Path("/{id}/attachment")
|
||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||
ListenableFuture<Attachment> showAttachment(@PathParam("net") String networkId, @PathParam("portId") String portId);
|
||||
ListenableFuture<Attachment> showAttachment(@PathParam("id") String portId);
|
||||
|
||||
/**
|
||||
* @see PortClient#plugAttachment
|
||||
*/
|
||||
@PUT
|
||||
@Path("/{net}/ports/{portId}/attachment")
|
||||
@Path("/{id}/attachment")
|
||||
@WrapWith("attachment")
|
||||
ListenableFuture<Boolean> plugAttachment(@PathParam("net") String networkId, @PathParam("portId") String portId,
|
||||
ListenableFuture<Boolean> plugAttachment(@PathParam("id") String portId,
|
||||
@PayloadParam("id") String attachmentId);
|
||||
|
||||
/**
|
||||
* @see PortClient#unplugAttachment
|
||||
*/
|
||||
@DELETE
|
||||
@Path("/{net}/ports/{portId}/attachment")
|
||||
ListenableFuture<Boolean> unplugAttachment(@PathParam("net") String networkId, @PathParam("portId") String portId);
|
||||
@Path("{id}/attachment")
|
||||
ListenableFuture<Boolean> unplugAttachment(@PathParam("id") String portId);
|
||||
|
||||
}
|
||||
|
|
|
@ -44,55 +44,55 @@ public interface PortClient {
|
|||
/**
|
||||
* Returns the list of all ports currently defined in Quantum for the requested network
|
||||
*/
|
||||
Set<Reference> listReferences(String networkId);
|
||||
Set<Reference> listReferences();
|
||||
|
||||
/**
|
||||
* Returns the set of ports currently defined in Quantum for the requested network.
|
||||
*/
|
||||
Set<Port> list(String networkId);
|
||||
Set<Port> 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);
|
||||
}
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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<Reference> nets = client.listReferences("1a104cf5-cb18-4d35-9407-2fd2646d9d0b");
|
||||
Set<Reference> 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<Port> nets = client.list("1a104cf5-cb18-4d35-9407-2fd2646d9d0b");
|
||||
Set<Port> 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");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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<Reference> nets = netClient.listReferences();
|
||||
for(Reference net : nets) {
|
||||
Set<Reference> portRefs = portClient.listReferences(net.getId());
|
||||
Set<Port> ports = portClient.list(net.getId());
|
||||
PortClient portClient = quantumContext.getApi().getPortClientForRegionAndNetwork(regionId, net.getId());
|
||||
Set<Reference> portRefs = portClient.listReferences();
|
||||
Set<Port> 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()));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue