當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。