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


Java EbsBlockDevice类代码示例

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


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

示例1: addMandatoryProperties

import com.amazonaws.services.ec2.model.EbsBlockDevice; //导入依赖的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

示例2: customizeBootDiskProperties

import com.amazonaws.services.ec2.model.EbsBlockDevice; //导入依赖的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

示例3: getEbsBlockDeviceMapping

import com.amazonaws.services.ec2.model.EbsBlockDevice; //导入依赖的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

示例4: parseEbs

import com.amazonaws.services.ec2.model.EbsBlockDevice; //导入依赖的package包/类
private static EbsBlockDevice parseEbs(String blockDevice) {

        String[] parts = blockDevice.split(":");

        EbsBlockDevice ebs = new EbsBlockDevice();
        if (StringUtils.isNotBlank(getOrEmpty(parts, 0))) {
            ebs.setSnapshotId(parts[0]);
        }
        if (StringUtils.isNotBlank(getOrEmpty(parts, 1))) {
            ebs.setVolumeSize(Integer.valueOf(parts[1]));
        }
        if (StringUtils.isNotBlank(getOrEmpty(parts, 2))) {
            ebs.setDeleteOnTermination(Boolean.valueOf(parts[2]));
        }
        if (StringUtils.isNotBlank(getOrEmpty(parts, 3))) {
            ebs.setVolumeType(parts[3]);
        }
        if (StringUtils.isNotBlank(getOrEmpty(parts, 4))) {
            ebs.setIops(Integer.valueOf(parts[4]));
        }
        if (StringUtils.isNotBlank(getOrEmpty(parts, 5))) {
            ebs.setEncrypted(parts[5].equals("encrypted"));
        }

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

示例5: testParserWithTermination

import com.amazonaws.services.ec2.model.EbsBlockDevice; //导入依赖的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

示例6: testParserWithIo

import com.amazonaws.services.ec2.model.EbsBlockDevice; //导入依赖的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

示例7: testParserWithEncrypted

import com.amazonaws.services.ec2.model.EbsBlockDevice; //导入依赖的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

示例8: testParserWithMultiple

import com.amazonaws.services.ec2.model.EbsBlockDevice; //导入依赖的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

示例9: deleteImage

import com.amazonaws.services.ec2.model.EbsBlockDevice; //导入依赖的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

示例10: testParserWithAmi

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

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

示例11: testParserWithSize

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

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

示例12: apply

import com.amazonaws.services.ec2.model.EbsBlockDevice; //导入依赖的package包/类
@Override
@Nullable
public List<VirtualMachineImage> apply(@Nullable List<Image> input)
{
    List<VirtualMachineImage> images = newArrayList();
    
    for (Image image: input)
    {
        VirtualMachineImage vmi = new VirtualMachineImage()
                .setArchitecture(OsArchitectureType.valueOfFromValue(image.getArchitecture()))
                .setDefaultUsername(DEFAULT_PLATFORM_USER_NAME)
                .setHypervisor(HypervisorType.valueOfFromValue(image.getHypervisor()))
                .setName(image.getImageId())
                .setPlatform(image.getPlatform() == null ? Platform.LINUX : Platform.valueOfFromValue(image.getPlatform()))
                .setRegion(credentials_.getRegion())
                .setVirtualizationType(VirtualizationType.valueOfFromValue(image.getVirtualizationType()));
        
        if ("ebs".equals(image.getRootDeviceType()))
        {

            EbsBlockDevice ebs = image.getBlockDeviceMappings().get(0).getEbs();

            org.excalibur.core.cloud.api.Volume volume = new org.excalibur.core.cloud.api.Volume()
                    .setName(image.getRootDeviceName())
                    .setType(new VolumeType().setName(ebs.getVolumeType()))
                    .setSizeGb(ebs.getVolumeSize());
            
            vmi.setRootVolume(volume);
        }                
        
        images.add(vmi);
    }
    return images;
}
 
开发者ID:alessandroleite,项目名称:dohko,代码行数:35,代码来源:EC2.java

示例13: getDeviceType

import com.amazonaws.services.ec2.model.EbsBlockDevice; //导入依赖的package包/类
private String getDeviceType(EbsBlockDevice ebs) {
    return ebs != null ? AWSStorageType.EBS.getName() : AWSStorageType.INSTANCE_STORE.getName();
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:4,代码来源:AWSInstanceService.java

示例14: buildLocalResourceState

import com.amazonaws.services.ec2.model.EbsBlockDevice; //导入依赖的package包/类
@Override
protected DeferredResult<LocalStateHolder> buildLocalResourceState(
        Image remoteImage, ImageState existingImageState) {

    LocalStateHolder holder = new LocalStateHolder();

    holder.localState = new ImageState();

    if (existingImageState == null) {
        // Create flow
        if (this.request.requestType == ImageEnumerateRequestType.PUBLIC) {
            holder.localState.endpointType = this.endpointState.endpointType;
        }
    } else {
        // Update flow: do nothing
    }

    // Both flows - populate from remote Image
    holder.localState.name = remoteImage.getName();
    holder.localState.description = remoteImage.getDescription();
    holder.localState.osFamily = remoteImage.getPlatform();

    holder.localState.diskConfigs = new ArrayList<>();
    if (DeviceType.Ebs == DeviceType.fromValue(remoteImage.getRootDeviceType())) {
        for (BlockDeviceMapping blockDeviceMapping : remoteImage.getBlockDeviceMappings()) {
            // blockDeviceMapping can be with noDevice
            EbsBlockDevice ebs = blockDeviceMapping.getEbs();
            if (ebs != null) {
                DiskConfiguration diskConfig = new DiskConfiguration();
                diskConfig.id = blockDeviceMapping.getDeviceName();
                diskConfig.encrypted = ebs.getEncrypted();
                diskConfig.persistent = true;
                if (ebs.getVolumeSize() != null) {
                    diskConfig.capacityMBytes = ebs.getVolumeSize() * 1024;
                }
                diskConfig.properties = Collections.singletonMap(
                        VOLUME_TYPE, ebs.getVolumeType());

                holder.localState.diskConfigs.add(diskConfig);
            }
        }
    }

    for (Tag remoteImageTag : remoteImage.getTags()) {
        holder.remoteTags.put(remoteImageTag.getKey(), remoteImageTag.getValue());
    }

    return DeferredResult.completed(holder);
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:50,代码来源:AWSImageEnumerationAdapterService.java

示例15: spotRequest

import com.amazonaws.services.ec2.model.EbsBlockDevice; //导入依赖的package包/类
public void spotRequest() {
		if (instances <= instancesSet.size()) {
			logger.info("No more instances will be launched because there are already enough.");
			return;
		}

		com.amazonaws.services.ec2.AmazonEC2 client = AmazonEC2.connect();

		RequestSpotInstancesRequest requestRequest = new RequestSpotInstancesRequest();

		requestRequest.setSpotPrice(Double.valueOf(maxPrice).toString());
//		requestRequest.setInstanceCount(instances);
		requestRequest.setInstanceCount(instances - instancesSet.size());

		LaunchSpecification launchSpecification = new LaunchSpecification();
		launchSpecification.setImageId(ami);
		launchSpecification.setInstanceType(size);
		if (userData != null)
			launchSpecification.setUserData(Base64.encodeAsString(userData
					.getBytes()));

		BlockDeviceMapping blockDeviceMapping = new BlockDeviceMapping();
		blockDeviceMapping.setDeviceName("/dev/sda1");

		EbsBlockDevice ebs = new EbsBlockDevice();
		ebs.setDeleteOnTermination(Boolean.TRUE);
		ebs.setVolumeSize(diskSize);
		blockDeviceMapping.setEbs(ebs);

		ArrayList<BlockDeviceMapping> blockList = new ArrayList<BlockDeviceMapping>();
		blockList.add(blockDeviceMapping);

		launchSpecification.setBlockDeviceMappings(blockList);

		ArrayList<String> securityGroups = new ArrayList<String>();
		securityGroups.add(Configuration.SECURITY_GROUP_NAME);
		launchSpecification.setSecurityGroups(securityGroups);

		launchSpecification.setKeyName(keyName);

		requestRequest.setLaunchSpecification(launchSpecification);

		RequestSpotInstancesResult requestResult = client
				.requestSpotInstances(requestRequest);

		List<SpotInstanceRequest> reqs = requestResult
				.getSpotInstanceRequests();
		for (SpotInstanceRequest req : reqs)
			instancesSet.add(new Instance(this, req.getInstanceId(), req
					.getSpotInstanceRequestId()));
	}
 
开发者ID:rickdesantis,项目名称:cloud-runner,代码行数:52,代码来源:VirtualMachine.java


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