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


Java Instance.getInstanceType方法代码示例

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


在下文中一共展示了Instance.getInstanceType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkInstanceIsManagedByDirector

import com.amazonaws.services.ec2.model.Instance; //导入方法依赖的package包/类
/**
 * Performs a sequence of strict instance ownership checks to avoid any potential harmful
 * accidents.
 *
 * @param instance the instance
 * @param template the template from which the instance was created, or <code>null</code>
 *                 if it is unknown (such as during a delete call)
 * @return the virtual instance ID
 * @throws IllegalStateException if the instance fails an ownership check
 */
private String checkInstanceIsManagedByDirector(Instance instance, EC2InstanceTemplate template) {
  String virtualInstanceId = getVirtualInstanceId(instance.getTags(), "instance");
  String instanceIds = instance.getInstanceId() + " / " + virtualInstanceId;
  String instanceKeyName = instance.getKeyName();

  if (template != null) {
    if (!template.getKeyName().equals(Optional.fromNullable(instanceKeyName))) {
      LOG.warn("Found unexpected key name: {} for instance: {}", instanceKeyName, instanceIds);
    }
    String instanceType = instance.getInstanceType();
    if (!template.getType().equals(instanceType)) {
      LOG.warn("Found unexpected type: {} for instance: {}", instanceType, instanceIds);
    }
    String instanceImageId = instance.getImageId();
    if (!template.getImage().equals(instanceImageId)) {
      LOG.warn("Found unexpected image: {} for instance: {}", instanceImageId, instanceIds);
    }
  }
  return virtualInstanceId;
}
 
开发者ID:cloudera,项目名称:director-aws-plugin,代码行数:31,代码来源:EC2Provider.java

示例2: getAvailableDeviceName

import com.amazonaws.services.ec2.model.Instance; //导入方法依赖的package包/类
private String getAvailableDeviceName(DiskContext context, String instanceId) {
    DescribeInstancesRequest describeInstancesRequest = new DescribeInstancesRequest()
            .withInstanceIds(instanceId);
    DescribeInstancesResult instancesResult = context.amazonEC2Client
            .describeInstances(describeInstancesRequest);

    List<InstanceBlockDeviceMapping> blockDeviceMappings = null;
    AWSSupportedOS platform = null;
    AWSSupportedVirtualizationTypes virtualizationTypes = null;
    String instanceType = null;
    for (Reservation reservation : instancesResult.getReservations()) {
        for (Instance instance : reservation.getInstances()) {
            if (instance.getInstanceId().equals(instanceId)) {
                blockDeviceMappings = instance.getBlockDeviceMappings();
                platform = AWSSupportedOS.get(instance.getPlatform());
                virtualizationTypes = AWSSupportedVirtualizationTypes.get(instance.getVirtualizationType());
                instanceType = instance.getInstanceType();
                break;
            }
        }
    }

    String deviceName = null;
    if (blockDeviceMappings != null) {
        List<String> usedDeviceNames = getUsedDeviceNames(blockDeviceMappings);
        List<String> availableDiskNames = AWSBlockDeviceNameMapper.getAvailableNames(
                platform, virtualizationTypes, AWSStorageType.EBS, instanceType, usedDeviceNames);
        deviceName = availableDiskNames.get(0);
    }
    return deviceName;
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:32,代码来源:AWSComputeDiskDay2Service.java

示例3: getPropertyValue

import com.amazonaws.services.ec2.model.Instance; //导入方法依赖的package包/类
@Override
protected String getPropertyValue(Instance instance) {
  return instance.getInstanceType();
}
 
开发者ID:cloudera,项目名称:director-aws-plugin,代码行数:5,代码来源:EC2Instance.java


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