mirror of https://github.com/apache/jclouds.git
Nova VolumeClient: adjusting attachment method names after review
This commit is contained in:
parent
ff1428e6f7
commit
32022723ad
|
@ -131,7 +131,7 @@ public interface VolumeAsyncClient {
|
|||
@SelectJson("volumeAttachments")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
|
||||
ListenableFuture<Set<VolumeAttachment>> listAttachments(@PathParam("server_id") String serverId);
|
||||
ListenableFuture<Set<VolumeAttachment>> listAttachmentsOnServer(@PathParam("server_id") String serverId);
|
||||
|
||||
/**
|
||||
* Get a specific attached volume.
|
||||
|
@ -143,7 +143,8 @@ public interface VolumeAsyncClient {
|
|||
@SelectJson("volumeAttachment")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||
ListenableFuture<VolumeAttachment> getAttachment(@PathParam("server_id") String serverId, @PathParam("id") String volumeId);
|
||||
ListenableFuture<VolumeAttachment> getAttachmentForVolumeOnServer(@PathParam("id") String volumeId,
|
||||
@PathParam("server_id") String serverId);
|
||||
|
||||
/**
|
||||
* Attach a volume to an instance
|
||||
|
@ -156,9 +157,8 @@ public interface VolumeAsyncClient {
|
|||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Payload("%7B\"volumeAttachment\":%7B\"volumeId\":\"{id}\",\"device\":\"{device}\"%7D%7D")
|
||||
ListenableFuture<VolumeAttachment> attachVolume(@PathParam("server_id") String serverId,
|
||||
@PayloadParam("id") String volumeId,
|
||||
@PayloadParam("device") String device);
|
||||
ListenableFuture<VolumeAttachment> attachVolumeToServerAsDevice(@PayloadParam("id") String volumeId,
|
||||
@PathParam("server_id") String serverId, @PayloadParam("device") String device);
|
||||
|
||||
/**
|
||||
* Detach a Volume from an instance.
|
||||
|
@ -169,7 +169,7 @@ public interface VolumeAsyncClient {
|
|||
@Path("/servers/{server_id}/os-volume_attachments/{id}")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@ExceptionParser(ReturnFalseOnNotFoundOr404.class)
|
||||
ListenableFuture<Boolean> detachVolume(@PathParam("server_id") String serverId, @PathParam("id") String volumeId);
|
||||
ListenableFuture<Boolean> detachVolumeFromServer(@PathParam("id") String volumeId, @PathParam("server_id") String serverId);
|
||||
|
||||
/**
|
||||
* Returns a summary list of snapshots.
|
||||
|
|
|
@ -80,28 +80,28 @@ public interface VolumeClient {
|
|||
*
|
||||
* @return all Floating IPs
|
||||
*/
|
||||
Set<VolumeAttachment> listAttachments(String serverId);
|
||||
Set<VolumeAttachment> listAttachmentsOnServer(String serverId);
|
||||
|
||||
/**
|
||||
* Get a specific attached volume.
|
||||
*
|
||||
* @return data about the given volume attachment.
|
||||
*/
|
||||
VolumeAttachment getAttachment(String serverId, String volumeId);
|
||||
VolumeAttachment getAttachmentForVolumeOnServer(String volumeId, String serverId);
|
||||
|
||||
/**
|
||||
* Attach a volume to an instance
|
||||
*
|
||||
* @return data about the new volume attachment
|
||||
*/
|
||||
VolumeAttachment attachVolume(String serverId, String volumeId, String device);
|
||||
VolumeAttachment attachVolumeToServerAsDevice(String volumeId, String serverId, String device);
|
||||
|
||||
/**
|
||||
* Detach a Volume from an instance.
|
||||
*
|
||||
* @return true if successful
|
||||
*/
|
||||
Boolean detachVolume(String server_id, String volumeId);
|
||||
Boolean detachVolumeFromServer(String server_id, String volumeId);
|
||||
|
||||
/**
|
||||
* Returns a summary list of snapshots.
|
||||
|
|
|
@ -199,7 +199,7 @@ public class VolumeClientExpectTest extends BaseNovaClientExpectTest {
|
|||
standardResponseBuilder(200).payload(payloadFromResource("/attachment_list.json")).build()
|
||||
).getVolumeExtensionForZone("az-1.region-a.geo-1").get();
|
||||
|
||||
Set<VolumeAttachment> attachments = client.listAttachments("instance-1");
|
||||
Set<VolumeAttachment> attachments = client.listAttachmentsOnServer("instance-1");
|
||||
assertEquals(attachments, ImmutableSet.of(testAttachment()));
|
||||
// double-check individual fields
|
||||
VolumeAttachment attachment = Iterables.getOnlyElement(attachments);
|
||||
|
@ -219,7 +219,7 @@ public class VolumeClientExpectTest extends BaseNovaClientExpectTest {
|
|||
standardResponseBuilder(401).build()
|
||||
).getVolumeExtensionForZone("az-1.region-a.geo-1").get();
|
||||
|
||||
client.listAttachments("instance-2");
|
||||
client.listAttachmentsOnServer("instance-2");
|
||||
}
|
||||
|
||||
public void testGetAttachment() {
|
||||
|
@ -231,7 +231,7 @@ public class VolumeClientExpectTest extends BaseNovaClientExpectTest {
|
|||
standardResponseBuilder(200).payload(payloadFromResource("/attachment_details.json")).build()
|
||||
).getVolumeExtensionForZone("az-1.region-a.geo-1").get();
|
||||
|
||||
VolumeAttachment attachment = client.getAttachment("instance-1", "1");
|
||||
VolumeAttachment attachment = client.getAttachmentForVolumeOnServer("1", "instance-1");
|
||||
assertEquals(attachment, testAttachment());
|
||||
}
|
||||
|
||||
|
@ -244,7 +244,7 @@ public class VolumeClientExpectTest extends BaseNovaClientExpectTest {
|
|||
standardResponseBuilder(404).build()
|
||||
).getVolumeExtensionForZone("az-1.region-a.geo-1").get();
|
||||
|
||||
assertNull(client.getAttachment("instance-1", "1"));
|
||||
assertNull(client.getAttachmentForVolumeOnServer("1", "instance-1"));
|
||||
}
|
||||
|
||||
public void testAttachVolume() {
|
||||
|
@ -257,7 +257,7 @@ public class VolumeClientExpectTest extends BaseNovaClientExpectTest {
|
|||
standardResponseBuilder(200).payload(payloadFromResource("/attachment_details.json")).build()
|
||||
).getVolumeExtensionForZone("az-1.region-a.geo-1").get();
|
||||
|
||||
VolumeAttachment result = client.attachVolume("instance-1", "1", "/dev/vdc");
|
||||
VolumeAttachment result = client.attachVolumeToServerAsDevice("1", "instance-1", "/dev/vdc");
|
||||
assertEquals(result, testAttachment());
|
||||
}
|
||||
|
||||
|
@ -272,7 +272,7 @@ public class VolumeClientExpectTest extends BaseNovaClientExpectTest {
|
|||
standardResponseBuilder(404).build()
|
||||
).getVolumeExtensionForZone("az-1.region-a.geo-1").get();
|
||||
|
||||
client.attachVolume("instance-1", "1", "/dev/vdc");
|
||||
client.attachVolumeToServerAsDevice("1", "instance-1","/dev/vdc");
|
||||
}
|
||||
|
||||
public void testDetachVolume() {
|
||||
|
@ -284,7 +284,7 @@ public class VolumeClientExpectTest extends BaseNovaClientExpectTest {
|
|||
standardResponseBuilder(200).payload(payloadFromResource("/attachment_details.json")).build()
|
||||
).getVolumeExtensionForZone("az-1.region-a.geo-1").get();
|
||||
|
||||
assertTrue(client.detachVolume("instance-1", "1"));
|
||||
assertTrue(client.detachVolumeFromServer("1", "instance-1"));
|
||||
}
|
||||
|
||||
public void testDetachVolumeFail() {
|
||||
|
@ -296,7 +296,7 @@ public class VolumeClientExpectTest extends BaseNovaClientExpectTest {
|
|||
standardResponseBuilder(404).build()
|
||||
).getVolumeExtensionForZone("az-1.region-a.geo-1").get();
|
||||
|
||||
assertFalse(client.detachVolume("instance-1", "1"));
|
||||
assertFalse(client.detachVolumeFromServer("1", "instance-1"));
|
||||
}
|
||||
|
||||
public void testListSnapshots() {
|
||||
|
|
|
@ -218,22 +218,22 @@ public class VolumeClientLiveTest extends BaseNovaClientLiveTest {
|
|||
Set<Resource> servers = novaContext.getApi().getServerClientForZone(zone).listServers();
|
||||
if (!servers.isEmpty()) {
|
||||
final String serverId = Iterables.getFirst(servers, null).getId();
|
||||
Set<VolumeAttachment> attachments = client.listAttachments(serverId);
|
||||
Set<VolumeAttachment> attachments = client.listAttachmentsOnServer(serverId);
|
||||
assertNotNull(attachments);
|
||||
final int before = attachments.size();
|
||||
|
||||
VolumeAttachment testAttachment = client.attachVolume(serverId, testVolume.getId(), "/dev/vdf");
|
||||
VolumeAttachment testAttachment = client.attachVolumeToServerAsDevice(testVolume.getId(), serverId, "/dev/vdf");
|
||||
assertNotNull(testAttachment.getId());
|
||||
assertEquals(testAttachment.getVolumeId(), testVolume.getId());
|
||||
|
||||
assertTrue(new RetryablePredicate<VolumeClient>(new Predicate<VolumeClient>() {
|
||||
@Override
|
||||
public boolean apply(VolumeClient volumeClient) {
|
||||
return client.listAttachments(serverId).size() == before+1;
|
||||
return client.listAttachmentsOnServer(serverId).size() == before+1;
|
||||
}
|
||||
}, 60 * 1000L).apply(client));
|
||||
|
||||
attachments = client.listAttachments(serverId);
|
||||
attachments = client.listAttachmentsOnServer(serverId);
|
||||
assertNotNull(attachments);
|
||||
assertEquals(attachments.size(), before+1);
|
||||
|
||||
|
@ -241,7 +241,7 @@ public class VolumeClientLiveTest extends BaseNovaClientLiveTest {
|
|||
|
||||
boolean foundIt = false;
|
||||
for (VolumeAttachment att : attachments) {
|
||||
VolumeAttachment details = client.getAttachment(serverId, att.getId());
|
||||
VolumeAttachment details = client.getAttachmentForVolumeOnServer(att.getVolumeId(), serverId);
|
||||
assertNotNull(details);
|
||||
assertNotNull(details.getId());
|
||||
assertNotNull(details.getServerId());
|
||||
|
@ -255,11 +255,11 @@ public class VolumeClientLiveTest extends BaseNovaClientLiveTest {
|
|||
|
||||
assertTrue(foundIt, "Failed to find the attachment we created in listAttachments() response");
|
||||
|
||||
client.detachVolume(serverId, testVolume.getId());
|
||||
client.detachVolumeFromServer(testVolume.getId(), serverId);
|
||||
assertTrue(new RetryablePredicate<VolumeClient>(new Predicate<VolumeClient>() {
|
||||
@Override
|
||||
public boolean apply(VolumeClient volumeClient) {
|
||||
return client.listAttachments(serverId).size() == before;
|
||||
return client.listAttachmentsOnServer(serverId).size() == before;
|
||||
}
|
||||
}, 60 * 1000L).apply(client));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue