本文整理汇总了Java中com.amazonaws.services.ec2.AmazonEC2.describeAvailabilityZones方法的典型用法代码示例。如果您正苦于以下问题:Java AmazonEC2.describeAvailabilityZones方法的具体用法?Java AmazonEC2.describeAvailabilityZones怎么用?Java AmazonEC2.describeAvailabilityZones使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.amazonaws.services.ec2.AmazonEC2
的用法示例。
在下文中一共展示了AmazonEC2.describeAvailabilityZones方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fillZoneItems
import com.amazonaws.services.ec2.AmazonEC2; //导入方法依赖的package包/类
public static ListBoxModel fillZoneItems(AWSCredentialsProvider credentialsProvider, String region) {
ListBoxModel model = new ListBoxModel();
if (AmazonEC2Cloud.testMode) {
model.add(TEST_ZONE);
return model;
}
if (!StringUtils.isEmpty(region)) {
AmazonEC2 client = EC2Cloud.connect(credentialsProvider, AmazonEC2Cloud.getEc2EndpointUrl(region));
DescribeAvailabilityZonesResult zones = client.describeAvailabilityZones();
List<AvailabilityZone> zoneList = zones.getAvailabilityZones();
model.add("<not specified>", "");
for (AvailabilityZone z : zoneList) {
model.add(z.getZoneName(), z.getZoneName());
}
}
return model;
}
示例2: setDefaultRACList
import com.amazonaws.services.ec2.AmazonEC2; //导入方法依赖的package包/类
/**
* Get the fist 3 available zones in the region
*/
public void setDefaultRACList(String region) {
AmazonEC2 client = new AmazonEC2Client(provider.getAwsCredentialProvider());
client.setEndpoint("ec2." + region + ".amazonaws.com");
DescribeAvailabilityZonesResult res = client.describeAvailabilityZones();
List<String> zone = Lists.newArrayList();
for (AvailabilityZone reg : res.getAvailabilityZones()) {
if (reg.getState().equals("available")) {
zone.add(reg.getZoneName());
}
if (zone.size() == 3) {
break;
}
}
DEFAULT_AVAILABILITY_ZONES = ImmutableList.copyOf(zone);
}
示例3: main
import com.amazonaws.services.ec2.AmazonEC2; //导入方法依赖的package包/类
public static void main(String[] args)
{
final AmazonEC2 ec2 = AmazonEC2ClientBuilder.defaultClient();
DescribeRegionsResult regions_response = ec2.describeRegions();
for(Region region : regions_response.getRegions()) {
System.out.printf(
"Found region %s " +
"with endpoint %s",
region.getRegionName(),
region.getEndpoint());
}
DescribeAvailabilityZonesResult zones_response =
ec2.describeAvailabilityZones();
for(AvailabilityZone zone : zones_response.getAvailabilityZones()) {
System.out.printf(
"Found availability zone %s " +
"with status %s " +
"in region %s",
zone.getZoneName(),
zone.getState(),
zone.getRegionName());
}
}
示例4: getAvailabilityZones
import com.amazonaws.services.ec2.AmazonEC2; //导入方法依赖的package包/类
private ArrayList<String> getAvailabilityZones(AmazonEC2 ec2) {
ArrayList<String> availabilityZones = new ArrayList<String>();
DescribeAvailabilityZonesResult zones = ec2.describeAvailabilityZones();
List<AvailabilityZone> zoneList = zones.getAvailabilityZones();
for (AvailabilityZone z : zoneList) {
availabilityZones.add(z.getZoneName());
}
return availabilityZones;
}
示例5: getAvailabilityZones
import com.amazonaws.services.ec2.AmazonEC2; //导入方法依赖的package包/类
/***
* Get availability zones in an Amazon AWS region
*
* @return List of availability zones
*/
public List<AvailabilityZone> getAvailabilityZones() {
final AmazonEC2 amazonEC2 = getEc2Client();
final DescribeAvailabilityZonesResult describeAvailabilityZonesResult = amazonEC2.describeAvailabilityZones();
final List<AvailabilityZone> availabilityZones = describeAvailabilityZonesResult.getAvailabilityZones();
LOGGER.info("Found: " + availabilityZones.size() + " availability zone");
return availabilityZones;
}