当前位置: 首页>>代码示例>>Java>>正文


Java BlockDeviceMapping类代码示例

本文整理汇总了Java中com.amazonaws.services.ec2.model.BlockDeviceMapping的典型用法代码示例。如果您正苦于以下问题:Java BlockDeviceMapping类的具体用法?Java BlockDeviceMapping怎么用?Java BlockDeviceMapping使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


BlockDeviceMapping类属于com.amazonaws.services.ec2.model包,在下文中一共展示了BlockDeviceMapping类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSnapshotIdsFromImageId

import com.amazonaws.services.ec2.model.BlockDeviceMapping; //导入依赖的package包/类
List<String> getSnapshotIdsFromImageId(AmazonEC2Async client, ImageCreateRequest request, Context context) {

		// LambdaLogger logger = context.getLogger();
		String imageId = request.getImageId();

		DescribeImagesResult result = client.describeImages(new DescribeImagesRequest().withImageIds(imageId));

		List<String> snapshotIds = new ArrayList<String>();

		for (Image image : result.getImages()) {
			for (BlockDeviceMapping block : image.getBlockDeviceMappings()) {
				snapshotIds.add(block.getEbs().getSnapshotId());
			}
		}
		return snapshotIds;
	}
 
开发者ID:uzresk,项目名称:aws-auto-operations-using-lambda,代码行数:17,代码来源:ImageStateCheckAndPargeFunction.java

示例2: suppressExcessInstanceStoreDevices

import com.amazonaws.services.ec2.model.BlockDeviceMapping; //导入依赖的package包/类
/**
 * Instance Type(like r3.large etc) supports a limited number of instance-store disks. All the
 * extra instance-store mappings that are more than those supported by the instance-type are
 * termed as excess. Excess mappings does not result in provisioning a disk.
 * <p>
 * Suppress the excess instance-store mappings in the image by setting NoDevice to 'true'.
 */
private void suppressExcessInstanceStoreDevices(List<BlockDeviceMapping> deviceMappings,
        InstanceType type) {

    List<BlockDeviceMapping> unsuppressedInstanceStoreMappings =
            getUnsuppressedInstanceStoreMappings(deviceMappings);

    int imageInstanceStoreCount = unsuppressedInstanceStoreMappings != null ?
            unsuppressedInstanceStoreMappings.size() : 0;

    int maxSupported = type.dataDiskMaxCount != null ? type.dataDiskMaxCount : 0;

    if (imageInstanceStoreCount > maxSupported) {
        for (int i = 0; i < imageInstanceStoreCount; i++) {
            if (i >= maxSupported) {
                unsuppressedInstanceStoreMappings.get(i).setNoDevice("");
            }
        }
    }
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:27,代码来源:AWSInstanceService.java

示例3: addMandatoryProperties

import com.amazonaws.services.ec2.model.BlockDeviceMapping; //导入依赖的package包/类
/**
 * Add the disk information to disk state so that the disk state reflects the volume
 * information
 */
private void addMandatoryProperties(DiskState diskState, BlockDeviceMapping deviceMapping,
        InstanceType instanceType) {

    if (diskState.customProperties == null) {
        diskState.customProperties = new HashMap<>();
    }
    String deviceName = deviceMapping.getDeviceName();
    diskState.customProperties.put(DEVICE_NAME, deviceName);

    EbsBlockDevice ebs = deviceMapping.getEbs();
    if (ebs != null) {
        diskState.capacityMBytes = ebs.getVolumeSize() * 1024;
        diskState.customProperties.put(DEVICE_TYPE, AWSStorageType.EBS.getName());
    } else {
        diskState.capacityMBytes = instanceType.dataDiskSizeInMB;
        diskState.customProperties.put(DEVICE_TYPE, AWSStorageType.INSTANCE_STORE.getName());
    }
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:23,代码来源:AWSInstanceService.java

示例4: customizeBootDiskProperties

import com.amazonaws.services.ec2.model.BlockDeviceMapping; //导入依赖的package包/类
private void customizeBootDiskProperties(DiskState bootDisk, String rootDeviceType,
        BlockDeviceMapping rootDeviceMapping, boolean hasHardConstraint,
        AWSInstanceContext aws) {
    if (rootDeviceType.equals(AWSStorageType.EBS.name().toLowerCase())) {
        String requestedType = bootDisk.customProperties.get(DEVICE_TYPE);
        EbsBlockDevice ebs = rootDeviceMapping.getEbs();
        if (hasHardConstraint) {
            validateIfDeviceTypesAreMatching(rootDeviceType, requestedType);
        }
        bootDisk.capacityMBytes = ebs.getVolumeSize() * 1024;
        updateDeviceMapping(rootDeviceType, requestedType, rootDeviceMapping.getDeviceName(),
                ebs, bootDisk);
        bootDisk.customProperties.put(DEVICE_TYPE, AWSStorageType.EBS.getName());
        bootDisk.customProperties.put(DEVICE_NAME, rootDeviceMapping.getDeviceName());
        bootDisk.customProperties.put(VOLUME_TYPE, ebs.getVolumeType());
        bootDisk.customProperties.put(DISK_IOPS, String.valueOf(ebs.getIops()));
    } else {
        if (aws.instanceTypeInfo.dataDiskSizeInMB != null) {
            this.logInfo(
                    () -> "[AWSInstanceService] Instance-Store boot disk size is set to the "
                            + "value supported by instance-type.");
            bootDisk.capacityMBytes = aws.instanceTypeInfo.dataDiskSizeInMB;
            bootDisk.customProperties.put(DEVICE_TYPE, AWSStorageType.INSTANCE_STORE.getName());
        }
    }
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:27,代码来源:AWSInstanceService.java

示例5: provisionAWSEBSVMWithEC2Client

import com.amazonaws.services.ec2.model.BlockDeviceMapping; //导入依赖的package包/类
public static String provisionAWSEBSVMWithEC2Client(VerificationHost host, AmazonEC2Client client,
        String ami, String subnetId, String securityGroupId, BlockDeviceMapping blockDeviceMapping) {

    RunInstancesRequest runInstancesRequest = new RunInstancesRequest()
            .withSubnetId(subnetId)
            .withImageId(ami)
            .withInstanceType(instanceType)
            .withMinCount(1).withMaxCount(1)
            .withSecurityGroupIds(securityGroupId)
            .withBlockDeviceMappings(blockDeviceMapping);

    // handler invoked once the EC2 runInstancesAsync commands completes
    RunInstancesResult result = null;
    try {
        result = client.runInstances(runInstancesRequest);
    } catch (Exception e) {
        host.log(Level.SEVERE, "Error encountered in provisioning machine on AWS",
                Utils.toString(e));
    }
    assertNotNull(result);
    assertNotNull(result.getReservation());
    assertNotNull(result.getReservation().getInstances());
    assertEquals(1, result.getReservation().getInstances().size());

    return result.getReservation().getInstances().get(0).getInstanceId();
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:27,代码来源:TestAWSSetupUtils.java

示例6: getVolumes

import com.amazonaws.services.ec2.model.BlockDeviceMapping; //导入依赖的package包/类
/**
 * Get EBS volumes attached to the specified virtual instance id.
 *
 * @return list of ebs volumes
 */
@VisibleForTesting
List<Volume> getVolumes(String virtualInstanceId) {
  String ec2InstanceId = getOnlyElement(
      getEC2InstanceIdsByVirtualInstanceId(
          Collections.singletonList(virtualInstanceId)
      ).values()
  );

  InstanceAttribute instanceAttribute =
      describeInstanceAttribute(ec2InstanceId, InstanceAttributeName.BlockDeviceMapping);
  List<InstanceBlockDeviceMapping> blockDeviceMappings =
      instanceAttribute.getBlockDeviceMappings();

  List<String> volumeIds = Lists.newArrayList();
  for (InstanceBlockDeviceMapping mapping : blockDeviceMappings) {
    volumeIds.add(mapping.getEbs().getVolumeId());
  }

  DescribeVolumesResult volumeResults = client.describeVolumes(
      new DescribeVolumesRequest().withVolumeIds(volumeIds)
  );

  return volumeResults.getVolumes();
}
 
开发者ID:cloudera,项目名称:director-aws-plugin,代码行数:30,代码来源:EC2Provider.java

示例7: getEbsBlockDeviceMapping

import com.amazonaws.services.ec2.model.BlockDeviceMapping; //导入依赖的package包/类
private List<BlockDeviceMapping> getEbsBlockDeviceMapping(int count, String volumeType,
    int volumeSizeGib, boolean enableEncryption) {
  List<String> deviceNames = ebsAllocator.getEbsDeviceNames(count);
  List<BlockDeviceMapping> mappings = Lists.newArrayList();

  for (String deviceName : deviceNames) {
    EbsBlockDevice ebs = new EbsBlockDevice()
        .withVolumeType(volumeType)
        .withVolumeSize(volumeSizeGib)
        .withEncrypted(enableEncryption)
        .withDeleteOnTermination(true);

    BlockDeviceMapping mapping = new BlockDeviceMapping()
        .withDeviceName(deviceName)
        .withEbs(ebs);

    mappings.add(mapping);
  }
  return mappings;
}
 
开发者ID:cloudera,项目名称:director-aws-plugin,代码行数:21,代码来源:EC2Provider.java

示例8: parse

import com.amazonaws.services.ec2.model.BlockDeviceMapping; //导入依赖的package包/类
public static List<BlockDeviceMapping> parse(String customDeviceMapping) {

        List<BlockDeviceMapping> deviceMappings = new ArrayList<BlockDeviceMapping>();

        for (String mapping: customDeviceMapping.split(",")) {
            String[] mappingPair = mapping.split("=");
            String device = mappingPair[0];
            String blockDevice = mappingPair[1];

            BlockDeviceMapping deviceMapping = new BlockDeviceMapping().withDeviceName(device);

            if (blockDevice.equals("none")) {
                deviceMapping.setNoDevice("none");
            }
            else if (blockDevice.startsWith("ephemeral")) {
                deviceMapping.setVirtualName(blockDevice);
            }
            else {
                deviceMapping.setEbs(parseEbs(blockDevice));
            }

            deviceMappings.add(deviceMapping);
        }

        return deviceMappings;
    }
 
开发者ID:hudson3-plugins,项目名称:ec2-plugin,代码行数:27,代码来源:DeviceMappingParser.java

示例9: testParserWithTermination

import com.amazonaws.services.ec2.model.BlockDeviceMapping; //导入依赖的package包/类
public void testParserWithTermination() throws Exception {
    List<BlockDeviceMapping> expected = new ArrayList<BlockDeviceMapping>();
    expected.add(
            new BlockDeviceMapping().
                    withDeviceName("/dev/sdc").
                    withEbs(
                            new EbsBlockDevice().
                                    withSnapshotId("snap-7eb96d16").
                                    withVolumeSize(80).
                                    withDeleteOnTermination(false)
                    )
    );

    String customDeviceMappings = "/dev/sdc=snap-7eb96d16:80:false";
    List<BlockDeviceMapping> actual = DeviceMappingParser.parse(customDeviceMappings);
    assertEquals(expected, actual);
}
 
开发者ID:hudson3-plugins,项目名称:ec2-plugin,代码行数:18,代码来源:DeviceMappingParserTest.java

示例10: testParserWithIo

import com.amazonaws.services.ec2.model.BlockDeviceMapping; //导入依赖的package包/类
public void testParserWithIo() throws Exception {
    List<BlockDeviceMapping> expected = new ArrayList<BlockDeviceMapping>();
    expected.add(
            new BlockDeviceMapping().
                    withDeviceName("/dev/sdc").
                    withEbs(
                            new EbsBlockDevice().
                                    withSnapshotId("snap-7eb96d16").
                                    withVolumeSize(80).
                                    withDeleteOnTermination(false).
                                    withVolumeType("io1").
                                    withIops(100)
                    )
    );

    String customDeviceMappings = "/dev/sdc=snap-7eb96d16:80:false:io1:100";
    List<BlockDeviceMapping> actual = DeviceMappingParser.parse(customDeviceMappings);
    assertEquals(expected, actual);
}
 
开发者ID:hudson3-plugins,项目名称:ec2-plugin,代码行数:20,代码来源:DeviceMappingParserTest.java

示例11: testParserWithEncrypted

import com.amazonaws.services.ec2.model.BlockDeviceMapping; //导入依赖的package包/类
public void testParserWithEncrypted() throws Exception {
    List<BlockDeviceMapping> expected = new ArrayList<BlockDeviceMapping>();
    expected.add(
            new BlockDeviceMapping().
                    withDeviceName("/dev/sdd").
                    withEbs(
                            new EbsBlockDevice().
                                    withVolumeSize(120).
                                    withEncrypted(true)
                    )
    );

    String customDeviceMappings = "/dev/sdd=:120::::encrypted";
    List<BlockDeviceMapping> actual = DeviceMappingParser.parse(customDeviceMappings);
    assertEquals(expected, actual);
}
 
开发者ID:hudson3-plugins,项目名称:ec2-plugin,代码行数:17,代码来源:DeviceMappingParserTest.java

示例12: testParserWithMultiple

import com.amazonaws.services.ec2.model.BlockDeviceMapping; //导入依赖的package包/类
public void testParserWithMultiple() throws Exception {
    List<BlockDeviceMapping> expected = new ArrayList<BlockDeviceMapping>();
    expected.add(
            new BlockDeviceMapping().
                    withDeviceName("/dev/sdd").
                    withEbs(
                            new EbsBlockDevice().
                                    withVolumeSize(120).
                                    withEncrypted(true)
                    )
    );
    expected.add(
            new BlockDeviceMapping().
                    withDeviceName("/dev/sdc").
                    withEbs(
                            new EbsBlockDevice().
                                    withVolumeSize(120)
                    )
    );

    String customDeviceMappings = "/dev/sdd=:120::::encrypted,/dev/sdc=:120";
    List<BlockDeviceMapping> actual = DeviceMappingParser.parse(customDeviceMappings);
    assertEquals(expected, actual);
}
 
开发者ID:hudson3-plugins,项目名称:ec2-plugin,代码行数:25,代码来源:DeviceMappingParserTest.java

示例13: deleteImage

import com.amazonaws.services.ec2.model.BlockDeviceMapping; //导入依赖的package包/类
public void deleteImage(Image image) {
    String imageId = image.getImageId();
    logger.info("delete image, imageId={}", imageId);
    ec2.deregisterImage(new DeregisterImageRequest(imageId));

    // our image always uses EBS as first and only drive
    List<BlockDeviceMapping> mappings = image.getBlockDeviceMappings();
    if (!mappings.isEmpty()) {
        EbsBlockDevice ebs = mappings.get(0).getEbs();
        if (ebs != null) {
            String snapshotId = ebs.getSnapshotId();
            logger.info("delete snapshot, snapshotId={}", snapshotId);
            ec2.deleteSnapshot(new DeleteSnapshotRequest(snapshotId));
        }
    }
}
 
开发者ID:neowu,项目名称:cmn-project,代码行数:17,代码来源:EC2.java

示例14: compareBlockDeviceMappings

import com.amazonaws.services.ec2.model.BlockDeviceMapping; //导入依赖的package包/类
public CompareResult<BlockDeviceMapping> compareBlockDeviceMappings(List<BlockDeviceMapping> oldBlockDeviceMappings, List<BlockDeviceMapping> newBlockDeviceMappings) {
    Validate.noNullElements(new Object[]{oldBlockDeviceMappings, newBlockDeviceMappings});
    CompareResult<BlockDeviceMapping> result = new CompareResult<>();

    Map<String, BlockDeviceMapping> oldBlockDeviceMappingMap = generateBlockDeviceMapping(oldBlockDeviceMappings);
    Map<String, BlockDeviceMapping> newBlockDeviceMappingMap = generateBlockDeviceMapping(newBlockDeviceMappings);

    for (String newKey : newBlockDeviceMappingMap.keySet()) {
        BlockDeviceMapping newBDM = newBlockDeviceMappingMap.get(newKey);
        BlockDeviceMapping oldBDM = oldBlockDeviceMappingMap.get(newKey);
        if (oldBDM != null) {
            if (!oldBDM.equals(newBDM)) {
                result.getUpdate().add(Pair.of(oldBDM, newBDM));
            }
        } else {
            result.getAdd().add(newBDM);
        }
        oldBlockDeviceMappingMap.remove(newKey);
    }

    for (String oldKey : oldBlockDeviceMappingMap.keySet()) {
        BlockDeviceMapping oldBlockDeviceMapping = oldBlockDeviceMappingMap.get(oldKey);
        result.getDelete().add(oldBlockDeviceMapping);
    }
    return result;
}
 
开发者ID:veyronfei,项目名称:clouck,代码行数:27,代码来源:ResourceUtil.java

示例15: pargeImages

import com.amazonaws.services.ec2.model.BlockDeviceMapping; //导入依赖的package包/类
private void pargeImages(AmazonEC2 ec2, Image image) {
	String imageId = image.getImageId();
	ec2.deregisterImage(new DeregisterImageRequest(imageId));
	for (BlockDeviceMapping block : image.getBlockDeviceMappings()) {
		String snapshotId = block.getEbs().getSnapshotId();
		ec2.deleteSnapshot(new DeleteSnapshotRequest().withSnapshotId(snapshotId));
	}
}
 
开发者ID:uzresk,项目名称:aws-auto-operations-using-lambda,代码行数:9,代码来源:ImageStateCheckAndPargeFunction.java


注:本文中的com.amazonaws.services.ec2.model.BlockDeviceMapping类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。