org.jclouds.ec2.domain.Volume类的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(10.0k)|赞(0)|评价(0)|浏览(130)

本文整理了Java中org.jclouds.ec2.domain.Volume类的一些代码示例,展示了Volume类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Volume类的具体详情如下:
包路径:org.jclouds.ec2.domain.Volume
类名称:Volume

Volume介绍

暂无

代码示例

代码示例来源:origin: jclouds/legacy-jclouds

public Volume build() {
  return new Volume(region, id, size, snapshotId, availabilityZone, status, createTime, attachments);
}

代码示例来源:origin: jclouds/legacy-jclouds

public Builder toBuilder() {
 return builder().fromVolume(this);
}

代码示例来源:origin: jclouds/legacy-jclouds

public boolean apply(Volume volume) {
 logger.trace("looking for status on volume %s", volume.getId());
 volume = Iterables.getOnlyElement(client.describeVolumesInRegion(volume.getRegion(), volume
      .getId()));
 logger.trace("%s: looking for status %s: currently: %s", volume, Volume.Status.AVAILABLE,
      volume.getStatus());
 return volume.getStatus() == Volume.Status.AVAILABLE;
}

代码示例来源:origin: apache/jclouds

@Test(dependsOnMethods = "testCreateVolumeFromSnapshotInAvailabilityZoneWithOptions")
void testCreateVolumeFromSnapshotInAvailabilityZoneWithSize() {
 Volume volume = client.createVolumeFromSnapshotInAvailabilityZone(defaultZone, 2, snapshot.getId());
 assertNotNull(volume);
 Predicate<Volume> availabile = retry(new VolumeAvailable(client), 600, 10, SECONDS);
 assert availabile.apply(volume);
 Volume result = Iterables.getOnlyElement(client.describeVolumesInRegion(defaultRegion, volume.getId()));
 assertEquals(volume.getId(), result.getId());
 assertEquals(volume.getSnapshotId(), snapshot.getId());
 assertEquals(volume.getAvailabilityZone(), defaultZone);
 assertEquals(volume.getSize(), 2);
 assertEquals(result.getStatus(), Volume.Status.AVAILABLE);
 client.deleteVolumeInRegion(defaultRegion, result.getId());
}

代码示例来源:origin: apache/jclouds

@Test(enabled = false, dependsOnMethods = "testBundleInstance")
void testAMIFromBundle() {
 volume = Iterables.getOnlyElement(client.getElasticBlockStoreApi().get().describeVolumesInRegion(
    volume.getRegion(), volume.getId()));
 if (!volume.getAttachments().isEmpty()) {
   client.getElasticBlockStoreApi().get().detachVolumeInRegion(instance.getRegion(), volume.getId(), false);
   System.out.printf("%d: %s awaiting detachment to complete%n", System.currentTimeMillis(), volume.getId());
   assert volumeTester.apply(volume);
 } else {
 snapshot = client.getElasticBlockStoreApi().get().createSnapshotInRegion(volume.getRegion(), volume.getId(),
    withDescription("EBS Ubuntu Hardy"));

代码示例来源:origin: apache/jclouds

@Test
void testCreateVolumeInAvailabilityZoneWithVolumeType() {
 Volume expected = client.createVolumeInAvailabilityZone(defaultZone,
     volumeType("gp2"), withSize(1));
 assertNotNull(expected);
 assertEquals(expected.getAvailabilityZone(), defaultZone);
 assertEquals(expected.getVolumeType(), "gp2");
 Set<Volume> result = Sets.newLinkedHashSet(client.describeVolumesInRegion(defaultRegion, expected.getId()));
 assertNotNull(result);
 assertEquals(result.size(), 1);
 Volume volume = result.iterator().next();
 assertEquals(volume.getId(), expected.getId());
 assertEquals(volume.getVolumeType(), expected.getVolumeType());
 client.deleteVolumeInRegion(volume.getRegion(), volume.getId());
}

代码示例来源:origin: jclouds/legacy-jclouds

Snapshot snapshot = ebsClient.createSnapshotInRegion(volume.getRegion(), volume.getId());
ebsClient.deleteVolumeInRegion(volume.getRegion(), volume.getId());
      device.getVolumeId()));
  assertEquals(volumeSize, volume.getSize());
      device.getVolumeId()));
  assertEquals(volumeSize, volume.getSize());
  assertEquals(snapshot.getId(), volume.getSnapshotId());

代码示例来源:origin: apache/jclouds

client.getElasticBlockStoreApi().get().detachVolumeInRegion(volume.getRegion(), volume.getId(), true);
 assert volumeTester.apply(volume);
} catch (Exception e) {
 client.getElasticBlockStoreApi().get().deleteVolumeInRegion(volume.getRegion(), volume.getId());
} catch (Exception e) {
 e.printStackTrace();

代码示例来源:origin: apache/jclouds

@Test
void testDescribeVolumes() {
 String region = defaultRegion;
 SortedSet<Volume> allResults = Sets.newTreeSet(client.describeVolumesInRegion(region));
 assertNotNull(allResults);
 assertFalse(allResults.isEmpty());
 Volume volume = allResults.last();
 SortedSet<Volume> result = Sets.newTreeSet(client.describeVolumesInRegion(region, volume.getId()));
 assertNotNull(result);
 Volume compare = result.last();
 assertEquals(compare, volume);
}

代码示例来源:origin: jclouds/legacy-jclouds

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;
}

代码示例来源:origin: apache/jclouds

@Test
void testCreateVolumeInAvailabilityZone() {
 Volume expected = client.createVolumeInAvailabilityZone(defaultZone,
     withSize(1));
 assertNotNull(expected);
 assertEquals(expected.getAvailabilityZone(), defaultZone);
 this.volumeId = expected.getId();
 Set<Volume> result = Sets.newLinkedHashSet(client.describeVolumesInRegion(defaultRegion, expected.getId()));
 assertNotNull(result);
 assertEquals(result.size(), 1);
 Volume volume = result.iterator().next();
 assertEquals(volume.getId(), expected.getId());
 assertEquals(volume.getVolumeType(), expected.getVolumeType());
}

代码示例来源:origin: jclouds/legacy-jclouds

@Test
void testCreateVolumeInAvailabilityZone() {
 Volume expected = client.createVolumeInAvailabilityZone(defaultZone, 1);
 assertNotNull(expected);
 assertEquals(expected.getAvailabilityZone(), defaultZone);
 this.volumeId = expected.getId();
 Set<Volume> result = Sets.newLinkedHashSet(client.describeVolumesInRegion(defaultRegion, expected.getId()));
 assertNotNull(result);
 assertEquals(result.size(), 1);
 Volume volume = result.iterator().next();
 assertEquals(volume.getId(), expected.getId());
}

代码示例来源:origin: jclouds/legacy-jclouds

@Test(dependsOnMethods = "testCreateSnapshotInRegion")
void testDeleteVolumeInRegion() {
 client.deleteVolumeInRegion(defaultRegion, volumeId);
 Set<Volume> result = Sets.newLinkedHashSet(client.describeVolumesInRegion(defaultRegion, volumeId));
 assertEquals(result.size(), 1);
 Volume volume = result.iterator().next();
 assertEquals(volume.getStatus(), Volume.Status.DELETING);
}

代码示例来源:origin: apache/jclouds

@Test(dependsOnMethods = "testCreateSnapshotInRegion")
void testCreateVolumeFromSnapshotInAvailabilityZone() {
 Volume volume = client.createVolumeFromSnapshotInAvailabilityZone(defaultZone, snapshot.getId());
 assertNotNull(volume);
 Predicate<Volume> availabile = retry(new VolumeAvailable(client), 600, 10, SECONDS);
 assert availabile.apply(volume);
 Volume result = Iterables.getOnlyElement(client.describeVolumesInRegion(defaultRegion, volume.getId()));
 assertEquals(volume.getId(), result.getId());
 assertEquals(volume.getSnapshotId(), snapshot.getId());
 assertEquals(volume.getAvailabilityZone(), defaultZone);
 assertEquals(result.getStatus(), Volume.Status.AVAILABLE);
 client.deleteVolumeInRegion(defaultRegion, result.getId());
}

代码示例来源:origin: jclouds/legacy-jclouds

@Test(enabled = false, dependsOnMethods = "testBundleInstance")
void testAMIFromBundle() {
 volume = Iterables.getOnlyElement(client.getElasticBlockStoreServices().describeVolumesInRegion(
    volume.getRegion(), volume.getId()));
 if (volume.getAttachments().size() > 0) {
   client.getElasticBlockStoreServices().detachVolumeInRegion(instance.getRegion(), volume.getId(), false);
   System.out.printf("%d: %s awaiting detachment to complete%n", System.currentTimeMillis(), volume.getId());
   assert volumeTester.apply(volume);
 } else {
 snapshot = client.getElasticBlockStoreServices().createSnapshotInRegion(volume.getRegion(), volume.getId(),
    withDescription("EBS Ubuntu Hardy"));

代码示例来源:origin: apache/jclouds

Snapshot snapshot = ebsClient.createSnapshotInRegion(volume.getRegion(), volume.getId());
ebsClient.deleteVolumeInRegion(volume.getRegion(), volume.getId());
      device.getVolumeId()));
  assertEquals(volumeSize, volume.getSize());
      device.getVolumeId()));
  assertEquals(volumeSize, volume.getSize());
  assertEquals(snapshot.getId(), volume.getSnapshotId());

代码示例来源:origin: jclouds/legacy-jclouds

client.getElasticBlockStoreServices().detachVolumeInRegion(volume.getRegion(), volume.getId(), true);
 assert volumeTester.apply(volume);
} catch (Exception e) {
 client.getElasticBlockStoreServices().deleteVolumeInRegion(volume.getRegion(), volume.getId());
} catch (Exception e) {
 e.printStackTrace();

代码示例来源:origin: apache/jclouds

@Test(expectedExceptions = AWSResponseException.class)
void testDescribeVolumesWithInvalidFilter() {
 String region = defaultRegion;
 SortedSet<Volume> allResults = Sets.newTreeSet(client.describeVolumesInRegion(region));
 assertNotNull(allResults);
 assertFalse(allResults.isEmpty());
 Volume volume = allResults.last();
 client.describeVolumesInRegionWithFilter(region,
     ImmutableMultimap.<String, String>builder()
         .put("invalid-filter", volume.getId()).build());
}

代码示例来源:origin: org.jclouds.api/ec2

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;
}

代码示例来源:origin: apache/jclouds

@Test(dependsOnMethods = "testGetCreateVolumePermissionForSnapshot")
void testDeleteVolumeInRegion() {
 client.deleteVolumeInRegion(defaultRegion, volumeId);
 Set<Volume> volumes = client.describeVolumesInRegionWithFilter(defaultRegion, ImmutableMultimap
    .<String, String> builder().put("volume-id", volumeId).build());
 // The volume may not exist or remain in "deleting" state for a while
 Volume volume = getOnlyElement(volumes, null);
 assertTrue(volume == null || Status.DELETING == volume.getStatus());
}

相关文章