Package org.jclouds.ec2.domain

Examples of org.jclouds.ec2.domain.Attachment


      }

      /* But if attachment size is > 0, then the attachment could be in any state.
         * So we need to check if the status is DETACHED (return true) or not (return false).
         */
      Attachment lastAttachment = getLast(volume.getAttachments());
      logger.trace("%s: looking for status %s: currently: %s", lastAttachment,
              Attachment.Status.DETACHED, lastAttachment.getStatus());
      return lastAttachment.getStatus() == Attachment.Status.DETACHED;
   }
View Full Code Here


      volumeDetached = new VolumeDetached(client);
   }

   @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);
   }
View Full Code Here

      };
   }

   @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);
   }
View Full Code Here

      verify(client);
   }

   @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);
   }
View Full Code Here

            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());
   }
View Full Code Here

         iops = Integer.parseInt(currentText.toString().trim());
      } else if (qName.equals("encrypted")) {
         encrypted = Boolean.parseBoolean(currentText.toString().trim());
      } else if (qName.equals("item")) {
         if (inAttachmentSet) {
            attachments.add(new Attachment(region, volumeId, instanceId, device, attachmentStatus, attachTime));
            volumeId = null;
            instanceId = null;
            device = null;
            attachmentStatus = null;
            attachTime = null;
View Full Code Here

   public Attachment getResult() {
      String region = AWSUtils.findRegionInArgsOrNull(getRequest());
      if (region == null)
         region = defaultRegion.get();
      return new Attachment(region, volumeId, instanceId, device, attachmentStatus, attachTime);
   }
View Full Code Here

               "standard", 0, false, Sets.<Attachment> newLinkedHashSet()));
      expected.add(new Volume(defaultRegion, "vol-4282672b", 800, "snap-536d1b3a",
              "us-east-1a", Volume.Status.IN_USE, dateService
              .iso8601DateParse("2008-05-07T11:51:50.000Z"),
              "standard", 0, false,
              Sets.<Attachment> newHashSet(new Attachment(defaultRegion, "vol-4282672b", "i-6058a509",
                      "/dev/sdh", Attachment.Status.ATTACHED, dateService
                      .iso8601DateParse("2008-05-07T12:51:50.000Z")))));

      DescribeVolumesResponseHandler handler = injector
               .getInstance(DescribeVolumesResponseHandler.class);
View Full Code Here

public class AttachmentHandlerTest extends BaseEC2HandlerTest {
   public void testApplyInputStream() {
      DateService dateService = injector.getInstance(DateService.class);
      InputStream is = getClass().getResourceAsStream("/attach.xml");

      Attachment expected = new Attachment(defaultRegion, "vol-4d826724", "i-6058a509", "/dev/sdh",
            Attachment.Status.ATTACHING, dateService.iso8601DateParse("2008-05-07T11:51:50.000Z"));

      AttachmentHandler handler = injector.getInstance(AttachmentHandler.class);
      addDefaultRegionToHandler(handler);
      Attachment result = factory.create(handler).parse(is);

      assertEquals(result, expected);
   }
View Full Code Here

            IOException {
      Invokable<?, ?> method = method(InstanceAsyncClient.class, "setBlockDeviceMappingForInstanceInRegion", String.class,
               String.class, Map.class);

      Map<String, BlockDevice> mapping = Maps.newLinkedHashMap();
      mapping.put("/dev/sda1", new BlockDevice("vol-test1", true));
      GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1", mapping));

      request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);

      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
View Full Code Here

TOP

Related Classes of org.jclouds.ec2.domain.Attachment

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.