public Attachment build() { return new Attachment(region, volumeId, instanceId, device, status, attachTime); } }
public boolean apply(Attachment attachment) { logger.trace("looking for volume %s", attachment.getVolumeId()); Volume volume = Iterables.getOnlyElement(client.describeVolumesInRegion(attachment .getRegion(), attachment.getVolumeId())); if (volume.getAttachments().size() == 0) { return false; } Attachment lastAttachment = Sets.newTreeSet(volume.getAttachments()).last(); logger.trace("%s: looking for status %s: currently: %s", lastAttachment, Attachment.Status.ATTACHED, lastAttachment.getStatus()); return lastAttachment.getStatus() == Attachment.Status.ATTACHED; }
@Test public void testVolumeWithEmptyListOfAttachments() { Attachment attachment = newAttachmentWithStatus(Status.ATTACHED); Set<Volume> volumes = newHashSet(newVolumeWithAttachments(/* empty */)); expect(client.describeVolumesInRegion(attachment.getRegion(), attachment.getVolumeId())).andReturn(volumes); replay(client); assertTrue(volumeDetached.apply(attachment)); verify(client); }
private Attachment newAttachmentWithStatus(Status status) { return Attachment.builder() .volumeId("1").status(status).region("us-east-1").attachTime(new Date()) .device("/dev/sda").instanceId("us-east-1/i-1234").build(); } }
@Test(enabled = false, dependsOnMethods = "testCreateRunningInstance") void testCreateAndAttachVolume() { volume = client.getElasticBlockStoreServices().createVolumeInAvailabilityZone(instance.getAvailabilityZone(), VOLUME_SIZE); System.out.printf("%d: %s awaiting volume to become available%n", System.currentTimeMillis(), volume.getId()); assert volumeTester.apply(volume); Attachment attachment = client.getElasticBlockStoreServices().attachVolumeInRegion(instance.getRegion(), volume.getId(), instance.getId(), "/dev/sdh"); System.out.printf("%d: %s awaiting attachment to complete%n", System.currentTimeMillis(), attachment.getId()); assert attachTester.apply(attachment); System.out.printf("%d: %s attachment complete%n", System.currentTimeMillis(), attachment.getId()); }
@Test public void testWithStatusDetached() { Attachment attachment = newAttachmentWithStatus(Status.DETACHED); Set<Volume> volumes = newHashSet(newVolumeWithAttachments(attachment)); expect(client.describeVolumesInRegion(attachment.getRegion(), attachment.getVolumeId())).andReturn(volumes); replay(client); assertTrue(volumeDetached.apply(attachment)); verify(client); }
private Attachment newAttachmentWithStatus(Status status) { return Attachment.builder() .volumeId("1").status(status).region("us-east-1").attachTime(new Date()) .device("/dev/sda").instanceId("us-east-1/i-1234").build(); } }
@Test(enabled = false, dependsOnMethods = "testCreateRunningInstance") void testCreateAndAttachVolume() { volume = client.getElasticBlockStoreApi().get().createVolumeInAvailabilityZone(instance.getAvailabilityZone(), VOLUME_SIZE); System.out.printf("%d: %s awaiting volume to become available%n", System.currentTimeMillis(), volume.getId()); assert volumeTester.apply(volume); Attachment attachment = client.getElasticBlockStoreApi().get().attachVolumeInRegion(instance.getRegion(), volume.getId(), instance.getId(), "/dev/sdh"); System.out.printf("%d: %s awaiting attachment to complete%n", System.currentTimeMillis(), attachment.getId()); assert attachTester.apply(attachment); System.out.printf("%d: %s attachment complete%n", System.currentTimeMillis(), attachment.getId()); }
public boolean apply(Attachment attachment) { logger.trace("looking for volume %s", attachment.getVolumeId()); Volume volume = Iterables.getOnlyElement(client.describeVolumesInRegion(attachment .getRegion(), attachment.getVolumeId())); if (volume.getAttachments().size() == 0) { return false; } Attachment lastAttachment = Sets.newTreeSet(volume.getAttachments()).last(); logger.trace("%s: looking for status %s: currently: %s", lastAttachment, Attachment.Status.ATTACHED, lastAttachment.getStatus()); return lastAttachment.getStatus() == Attachment.Status.ATTACHED; }
@Test(dataProvider = "notDetachedStatuses") public void testWithDifferentStatus(Status attachmentStatus) { Attachment attachment = newAttachmentWithStatus(attachmentStatus); Set<Volume> volumes = newHashSet(newVolumeWithAttachments(attachment)); expect(client.describeVolumesInRegion(attachment.getRegion(), attachment.getVolumeId())).andReturn(volumes); replay(client); assertFalse(volumeDetached.apply(attachment)); verify(client); }
public Attachment build() { return new Attachment(region, volumeId, instanceId, device, status, attachTime); } }
public void testDescribeVolumesWithNovaEC2Status() { ElasticBlockStoreApi client = requestsSendResponses( describeAvailabilityZonesRequest, describeAvailabilityZonesResponse, HttpRequest.builder().method("POST") .endpoint("http://localhost:8773/services/Cloud/") .addHeader("Host", "localhost:8773") .payload(payloadFromStringWithContentType("Action=DescribeVolumes&Signature=AvRznSzGExM%2Buaj2JJj66wq4v4f%2BakicyLooRDtC0t0%3D&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2012-04-16T15%3A54%3A08.897Z&Version=2009-04-04&AWSAccessKeyId=identity", "application/x-www-form-urlencoded")).build(), HttpResponse.builder().statusCode(200).payload(payloadFromResource("/nova_ec2_describe_volumes.xml")).build() ).getElasticBlockStoreApi().get(); Set<Volume> expected = ImmutableSet.of(Volume .builder() .status(Volume.Status.AVAILABLE) .availabilityZone("nova") .region("nova") .id("vol-00000007") .size(1) .attachments(Attachment.builder().region("nova").build()) .createTime(dateService.iso8601SecondsDateParse("2012-04-10T10:39:52Z")) .build()); assertEquals(client.describeVolumesInRegion("nova"), expected); }
public boolean apply(Attachment attachment) { logger.trace("looking for volume %s", attachment.getVolumeId()); Volume volume = Iterables.getOnlyElement(client.describeVolumesInRegion(attachment .getRegion(), attachment.getVolumeId())); if (volume.getAttachments().isEmpty()) { return false; } Attachment lastAttachment = Sets.newTreeSet(volume.getAttachments()).last(); logger.trace("%s: looking for status %s: currently: %s", lastAttachment, Attachment.Status.ATTACHED, lastAttachment.getStatus()); return lastAttachment.getStatus() == Attachment.Status.ATTACHED; }
@Test public void testWithStatusDetached() { Attachment attachment = newAttachmentWithStatus(Status.DETACHED); Set<Volume> volumes = newHashSet(newVolumeWithAttachments(attachment)); expect(client.describeVolumesInRegion(attachment.getRegion(), attachment.getVolumeId())).andReturn(volumes); replay(client); assertTrue(volumeDetached.apply(attachment)); verify(client); }
public Attachment build() { return new Attachment(region, volumeId, instanceId, device, status, attachTime); } }
public boolean apply(Attachment attachment) { logger.trace("looking for volume %s", attachment.getVolumeId()); Volume volume = Iterables.getOnlyElement(client.describeVolumesInRegion(attachment .getRegion(), attachment.getVolumeId())); if (volume.getAttachments().isEmpty()) { return false; } Attachment lastAttachment = Sets.newTreeSet(volume.getAttachments()).last(); logger.trace("%s: looking for status %s: currently: %s", lastAttachment, Attachment.Status.ATTACHED, lastAttachment.getStatus()); return lastAttachment.getStatus() == Attachment.Status.ATTACHED; }
@Test public void testVolumeWithEmptyListOfAttachments() { Attachment attachment = newAttachmentWithStatus(Status.ATTACHED); Set<Volume> volumes = newHashSet(newVolumeWithAttachments(/* empty */)); expect(client.describeVolumesInRegion(attachment.getRegion(), attachment.getVolumeId())).andReturn(volumes); replay(client); assertTrue(volumeDetached.apply(attachment)); verify(client); }
public Attachment build() { return new Attachment(region, volumeId, instanceId, device, status, attachTime); } }
public boolean apply(Attachment attachment) { logger.trace("looking for volume %s", attachment.getVolumeId()); Volume volume = Iterables.getOnlyElement(client.describeVolumesInRegion(attachment .getRegion(), attachment.getVolumeId())); if (volume.getAttachments().isEmpty()) { return false; } Attachment lastAttachment = Sets.newTreeSet(volume.getAttachments()).last(); logger.trace("%s: looking for status %s: currently: %s", lastAttachment, Attachment.Status.ATTACHED, lastAttachment.getStatus()); return lastAttachment.getStatus() == Attachment.Status.ATTACHED; }
@Test(dataProvider = "notDetachedStatuses") public void testWithDifferentStatus(Status attachmentStatus) { Attachment attachment = newAttachmentWithStatus(attachmentStatus); Set<Volume> volumes = newHashSet(newVolumeWithAttachments(attachment)); expect(client.describeVolumesInRegion(attachment.getRegion(), attachment.getVolumeId())).andReturn(volumes); replay(client); assertFalse(volumeDetached.apply(attachment)); verify(client); }