• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java DescribeRegionsResult类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;
}
 
开发者ID:awslabs,项目名称:ec2-spot-jenkins-plugin,代码行数:21,代码来源:EC2FleetCloud.java


示例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)));
}
 
开发者ID:cloudera,项目名称:director-aws-plugin,代码行数:23,代码来源:AmazonEC2ClientProvider.java


示例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;
}
 
开发者ID:hudson3-plugins,项目名称:ec2-plugin,代码行数:22,代码来源:AmazonEC2Cloud.java


示例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());
    }
}
 
开发者ID:awsdocs,项目名称:aws-doc-sdk-examples,代码行数:28,代码来源:DescribeRegionsAndZones.java


示例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;
    }
}
 
开发者ID:alessandroleite,项目名称:dohko,代码行数:16,代码来源:EC2.java


示例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;
  }
 
开发者ID:vinayselvaraj,项目名称:vpc2vpc,代码行数:31,代码来源:EC2Helper.java


示例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;
  }
 
开发者ID:vinayselvaraj,项目名称:vpc2vpc,代码行数:31,代码来源:VPCHelper.java


示例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;
}
 
开发者ID:vinayselvaraj,项目名称:vpc2vpc,代码行数:30,代码来源:VPCHelper.java


示例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;
}
 
开发者ID:vinayselvaraj,项目名称:vpc2vpc,代码行数:30,代码来源:VPCHelper.java


示例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();
  }

}
 
开发者ID:vinayselvaraj,项目名称:vpc2vpc,代码行数:12,代码来源:BaseAction.java


示例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;

}
 
开发者ID:apache,项目名称:incubator-provisionr,代码行数:29,代码来源:ProviderClientCacheSupplier.java


示例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");
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:AmazonEC2Mock.java


示例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);
}
 
开发者ID:hortonworks,项目名称:cloudbreak,代码行数:45,代码来源:AwsPlatformResources.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ServiceHost类代码示例发布时间:2022-05-22
下一篇:
Java CompressedRandomAccessReader类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap