本文整理汇总了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;
}
示例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;
}
示例3: getPropertyValue
import com.amazonaws.services.ec2.model.Instance; //导入方法依赖的package包/类
@Override
protected String getPropertyValue(Instance instance) {
return instance.getInstanceType();
}