本文整理汇总了Java中com.amazonaws.services.ec2.model.DescribeRegionsResult类的典型用法代码示例。如果您正苦于以下问题:Java DescribeRegionsResult类的具体用法?Java DescribeRegionsResult怎么用?Java DescribeRegionsResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DescribeRegionsResult类属于com.amazonaws.services.ec2.model包,在下文中一共展示了DescribeRegionsResult类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doFillRegionItems
import com.amazonaws.services.ec2.model.DescribeRegionsResult; //导入依赖的package包/类
public ListBoxModel doFillRegionItems(@QueryParameter final String credentialsId,
@QueryParameter final String region)
throws IOException, ServletException {
final List<Region> regionList;
try {
final AmazonEC2 client = connect(credentialsId, null);
final DescribeRegionsResult regions=client.describeRegions();
regionList=regions.getRegions();
} catch(final Exception ex) {
//Ignore bad exceptions
return new ListBoxModel();
}
final ListBoxModel model = new ListBoxModel();
for(final Region reg : regionList) {
model.add(new ListBoxModel.Option(reg.getRegionName(), reg.getRegionName()));
}
return model;
}
示例2: getEndpointForRegion
import com.amazonaws.services.ec2.model.DescribeRegionsResult; //导入依赖的package包/类
private static String getEndpointForRegion(AmazonEC2Client client, String regionName) {
requireNonNull(client, "client is null");
requireNonNull(regionName, "regionName is null");
LOG.info(">> Describing all regions to find endpoint for '{}'", regionName);
DescribeRegionsResult result = client.describeRegions();
List<String> regions = Lists.newArrayListWithExpectedSize(result.getRegions().size());
for (Region candidate : result.getRegions()) {
regions.add(candidate.getRegionName());
if (candidate.getRegionName().equals(regionName)) {
LOG.info("<< Found endpoint '{}' for region '{}'", candidate.getEndpoint(), regionName);
return candidate.getEndpoint();
}
}
throw new IllegalArgumentException(String.format("Unable to find an endpoint for region '%s'. "
+ "Choose one of the following regions: %s", regionName, Joiner.on(", ").join(regions)));
}
示例3: doFillRegionItems
import com.amazonaws.services.ec2.model.DescribeRegionsResult; //导入依赖的package包/类
public ListBoxModel doFillRegionItems(@QueryParameter boolean useInstanceProfileForCredentials,
@QueryParameter String accessId, @QueryParameter String secretKey,
@QueryParameter String region) throws IOException, ServletException {
ListBoxModel model = new ListBoxModel();
if (testMode) {
model.add(DEFAULT_EC2_HOST);
return model;
}
if (useInstanceProfileForCredentials || (!StringUtils.isEmpty(accessId) && !StringUtils.isEmpty(secretKey))) {
AWSCredentialsProvider credentialsProvider = createCredentialsProvider(useInstanceProfileForCredentials, accessId, secretKey);
AmazonEC2 client = connect(credentialsProvider, new URL("http://ec2.amazonaws.com"));
DescribeRegionsResult regions = client.describeRegions();
List<Region> regionList = regions.getRegions();
for (Region r : regionList) {
String name = r.getRegionName();
model.add(name, name);
}
}
return model;
}
示例4: main
import com.amazonaws.services.ec2.model.DescribeRegionsResult; //导入依赖的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());
}
}
示例5: getRegionByName
import com.amazonaws.services.ec2.model.DescribeRegionsResult; //导入依赖的package包/类
public Region getRegionByName(String regionName)
{
try
{
DescribeRegionsResult regionResult = ec2_.describeRegions(new DescribeRegionsRequest().withRegionNames(regionName));
com.amazonaws.services.ec2.model.Region region = org.excalibur.core.util.Lists2.first(regionResult.getRegions());
return new Region().setEndpoint(region.getEndpoint()).setName(region.getRegionName());
}
catch (AmazonClientException exception)
{
LOG.error("Invalid region name [{}]. Message error: [{}]", regionName, exception.getMessage());
return null;
}
}
示例6: listRegionInstances
import com.amazonaws.services.ec2.model.DescribeRegionsResult; //导入依赖的package包/类
public HashMap<Region, List> listRegionInstances(AWSCredentials awsCreds) {
AmazonEC2Client ec2Client = new AmazonEC2Client(awsCreds);
List<Region> regions = new ArrayList();
DescribeRegionsResult descRegionsResult = ec2Client.describeRegions();
if (descRegionsResult != null) {
regions = descRegionsResult.getRegions();
}
HashMap<Region, List> regionInstances = new HashMap();
ExecutorService listInstanceExecutor = Executors.newFixedThreadPool(8);
for (Region region : regions) {
List<Instance> instances = new ArrayList();
regionInstances.put(region, instances);
Runnable worker = new ListInstanceRunnable(awsCreds, region, instances);
listInstanceExecutor.execute(worker);
}
listInstanceExecutor.shutdown();
try {
listInstanceExecutor.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS);
} catch (InterruptedException e) {
LOG.error("Caught InterruptedException: " + e.getMessage());
}
return regionInstances;
}
示例7: listRegionVpcs
import com.amazonaws.services.ec2.model.DescribeRegionsResult; //导入依赖的package包/类
public HashMap<Region, List> listRegionVpcs(AWSCredentials awsCreds) {
AmazonEC2Client ec2Client = new AmazonEC2Client(awsCreds);
List<Region> regions = new ArrayList();
DescribeRegionsResult descRegionsResult = ec2Client.describeRegions();
if (descRegionsResult != null) {
regions = descRegionsResult.getRegions();
}
HashMap<Region, List> regionVpcs = new HashMap();
ExecutorService listVPCExecutor = Executors.newFixedThreadPool(8);
for (Region region : regions) {
List<Vpc> vpcs = new ArrayList();
regionVpcs.put(region, vpcs);
Runnable worker = new ListVPCRunnable(awsCreds, region, vpcs);
listVPCExecutor.execute(worker);
}
listVPCExecutor.shutdown();
try {
listVPCExecutor.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS);
} catch (InterruptedException e) {
LOG.error("Caught InterruptedException: " + e.getMessage());
}
return regionVpcs;
}
示例8: listRegionSubnets
import com.amazonaws.services.ec2.model.DescribeRegionsResult; //导入依赖的package包/类
public HashMap<Region, List> listRegionSubnets(AWSCredentials awsCreds) {
AmazonEC2Client ec2Client = new AmazonEC2Client(awsCreds);
List<Region> regions = new ArrayList();
DescribeRegionsResult descRegionsResult = ec2Client.describeRegions();
if (descRegionsResult != null) {
regions = descRegionsResult.getRegions();
}
HashMap<Region, List> regionSubnetsMap = new HashMap();
ExecutorService listSubnetExecutor = Executors.newFixedThreadPool(8);
for (Region region : regions) {
List<Subnet> subnets = new ArrayList();
regionSubnetsMap.put(region, subnets);
Runnable worker = new ListSubnetRunnable(awsCreds, region, subnets);
listSubnetExecutor.execute(worker);
}
listSubnetExecutor.shutdown();
try {
listSubnetExecutor.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS);
} catch (InterruptedException e) {
LOG.error("Caught InterruptedException: " + e.getMessage());
}
return regionSubnetsMap;
}
示例9: listRegionRouteTables
import com.amazonaws.services.ec2.model.DescribeRegionsResult; //导入依赖的package包/类
public HashMap<Region, List> listRegionRouteTables(AWSCredentials awsCreds) {
AmazonEC2Client ec2Client = new AmazonEC2Client(awsCreds);
List<Region> regions = new ArrayList();
DescribeRegionsResult descRegionsResult = ec2Client.describeRegions();
if (descRegionsResult != null) {
regions = descRegionsResult.getRegions();
}
HashMap<Region, List> regionRouteTablesMap = new HashMap();
ExecutorService listRouteTablesExecutor = Executors.newFixedThreadPool(8);
for (Region region : regions) {
List<RouteTable> routeTables = new ArrayList();
regionRouteTablesMap.put(region, routeTables);
Runnable worker = new ListRouteTableRunnable(awsCreds, region, routeTables);
listRouteTablesExecutor.execute(worker);
}
listRouteTablesExecutor.shutdown();
try {
listRouteTablesExecutor.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS);
} catch (InterruptedException e) {
LOG.error("Caught InterruptedException: " + e.getMessage());
}
return regionRouteTablesMap;
}
示例10: BaseAction
import com.amazonaws.services.ec2.model.DescribeRegionsResult; //导入依赖的package包/类
public BaseAction(String[] args, AWSCredentials awsCreds) {
this.args = args;
this.awsCreds = awsCreds;
ec2Client = new AmazonEC2Client(awsCreds);
DescribeRegionsResult descRegionsResult = ec2Client.describeRegions();
if (descRegionsResult != null) {
regions = descRegionsResult.getRegions();
}
}
示例11: load
import com.amazonaws.services.ec2.model.DescribeRegionsResult; //导入依赖的package包/类
@Override
public AmazonEC2 load(Provider provider) {
String region = Optional.fromNullable(provider.getOptions().get(ProviderOptions.REGION))
.or(ProviderOptions.DEFAULT_REGION);
AWSCredentials credentials = new BasicAWSCredentials(provider.getAccessKey(), provider.getSecretKey());
AmazonEC2 client = new AmazonEC2Client(credentials, new ClientConfiguration()
.withUserAgent(PROVISIONR_USER_AGENT));
if (provider.getEndpoint().isPresent()) {
LOG.info("Using endpoint {} as configured", provider.getEndpoint().get());
client.setEndpoint(provider.getEndpoint().get());
} else {
LOG.info(">> Searching endpoint for region {}", region);
DescribeRegionsRequest request = new DescribeRegionsRequest().withRegionNames(region);
DescribeRegionsResult result = client.describeRegions(request);
checkArgument(result.getRegions().size() == 1, "Invalid region name %s. Expected one result found %s",
region, result.getRegions());
LOG.info("<< Using endpoint {} for region {}", result.getRegions().get(0).getEndpoint(), region);
client.setEndpoint(result.getRegions().get(0).getEndpoint());
}
return client;
}
示例12: describeRegions
import com.amazonaws.services.ec2.model.DescribeRegionsResult; //导入依赖的package包/类
@Override
public DescribeRegionsResult describeRegions(DescribeRegionsRequest describeRegionsRequest) throws AmazonServiceException, AmazonClientException {
throw new UnsupportedOperationException("Not supported in mock");
}
示例13: regions
import com.amazonaws.services.ec2.model.DescribeRegionsResult; //导入依赖的package包/类
@Override
@Cacheable(cacheNames = "cloudResourceRegionCache", key = "#cloudCredential?.id")
public CloudRegions regions(CloudCredential cloudCredential, Region region, Map<String, String> filters) throws Exception {
AmazonEC2Client ec2Client = awsClient.createAccess(cloudCredential);
Map<Region, List<AvailabilityZone>> regionListMap = new HashMap<>();
Map<Region, String> displayNames = new HashMap<>();
DescribeRegionsRequest describeRegionsRequest = new DescribeRegionsRequest();
DescribeRegionsResult describeRegionsResult = ec2Client.describeRegions(describeRegionsRequest);
String defaultRegion = awsZoneParameterDefault;
for (com.amazonaws.services.ec2.model.Region awsRegion : describeRegionsResult.getRegions()) {
if (region == null || Strings.isNullOrEmpty(region.value()) || awsRegion.getRegionName().equals(region.value())) {
DescribeAvailabilityZonesRequest describeAvailabilityZonesRequest = new DescribeAvailabilityZonesRequest();
ec2Client.setRegion(RegionUtils.getRegion(awsRegion.getRegionName()));
Filter filter = new Filter();
filter.setName("region-name");
List<String> list = new ArrayList<>();
list.add(awsRegion.getRegionName());
filter.setValues(list);
describeAvailabilityZonesRequest.withFilters(filter);
DescribeAvailabilityZonesResult describeAvailabilityZonesResult = ec2Client.describeAvailabilityZones(describeAvailabilityZonesRequest);
List<AvailabilityZone> tmpAz = new ArrayList<>();
for (com.amazonaws.services.ec2.model.AvailabilityZone availabilityZone : describeAvailabilityZonesResult.getAvailabilityZones()) {
tmpAz.add(availabilityZone(availabilityZone.getZoneName()));
}
regionListMap.put(region(awsRegion.getRegionName()), tmpAz);
DisplayName displayName = regionDisplayNames.get(region(awsRegion.getRegionName()));
if (displayName == null || Strings.isNullOrEmpty(displayName.value())) {
displayNames.put(region(awsRegion.getRegionName()), awsRegion.getRegionName());
} else {
displayNames.put(region(awsRegion.getRegionName()), displayName.value());
}
}
}
if (region != null && !Strings.isNullOrEmpty(region.value())) {
defaultRegion = region.value();
}
return new CloudRegions(regionListMap, displayNames, defaultRegion);
}