com.amazonaws.services.ec2.model.Region Java Examples
The following examples show how to use
com.amazonaws.services.ec2.model.Region.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EC2FleetCloudTest.java From ec2-spot-jenkins-plugin with Apache License 2.0 | 5 votes |
@Test public void descriptorImpl_doFillRegionItems_returnStaticRegionsAndDynamic() { AmazonEC2Client amazonEC2Client = mock(AmazonEC2Client.class); when(ec2Api.connect(anyString(), nullable(String.class), nullable(String.class))).thenReturn(amazonEC2Client); when(amazonEC2Client.describeRegions()).thenReturn(new DescribeRegionsResult().withRegions(new Region().withRegionName("dynamic-region"))); ListBoxModel r = new EC2FleetCloud.DescriptorImpl().doFillRegionItems(""); Assert.assertThat(r.size(), Matchers.greaterThan(0)); Assert.assertThat(r.toString(), Matchers.containsString("dynamic-region")); assertEquals(RegionUtils.getRegions().size() + 1, r.size()); }
Example #2
Source File: EC2FleetCloudTest.java From ec2-spot-jenkins-plugin with Apache License 2.0 | 5 votes |
@Test public void descriptorImpl_doFillRegionItems_returnConsistOrderBetweenCalls() { AmazonEC2Client amazonEC2Client = mock(AmazonEC2Client.class); when(ec2Api.connect(anyString(), nullable(String.class), nullable(String.class))).thenReturn(amazonEC2Client); when(amazonEC2Client.describeRegions()).thenReturn(new DescribeRegionsResult().withRegions(new Region().withRegionName("dynamic-region"))); ListBoxModel r1 = new EC2FleetCloud.DescriptorImpl().doFillRegionItems(""); ListBoxModel r2 = new EC2FleetCloud.DescriptorImpl().doFillRegionItems(""); ListBoxModel r3 = new EC2FleetCloud.DescriptorImpl().doFillRegionItems(""); assertEquals(r1.toString(), r2.toString()); assertEquals(r2.toString(), r3.toString()); }
Example #3
Source File: DescribeRegionsAndZones.java From aws-doc-sdk-examples with Apache License 2.0 | 5 votes |
public static void main(String[] args) { final AmazonEC2 ec2 = AmazonEC2ClientBuilder.defaultClient(); // snippet-start:[ec2.java1.describe_region_and_zones.regions] DescribeRegionsResult regions_response = ec2.describeRegions(); for(Region region : regions_response.getRegions()) { System.out.printf( "Found region %s " + "with endpoint %s", region.getRegionName(), region.getEndpoint()); } // snippet-end:[ec2.java1.describe_region_and_zones.regions] // snippet-start:[ec2.java1.describe_region_and_zones.zones] 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()); } // snippet-end:[ec2.java1.describe_region_and_zones.zones] }
Example #4
Source File: RegionConverter.java From primecloud-controller with GNU General Public License v2.0 | 5 votes |
@Override protected Region convertObject(RegionInfo from) { Region to = new Region(); to.setRegionName(from.getName()); to.setEndpoint(from.getUrl()); return to; }
Example #5
Source File: ServerInstanceContext.java From chassis with Apache License 2.0 | 5 votes |
private String findRegion() { for (Region region : amazonEC2.describeRegions().getRegions()) { if (this.availabilityZone.startsWith(region.getRegionName())) { return region.getRegionName(); } } throw new BootstrapException("Unable to determine region"); }
Example #6
Source File: ServerInstanceContextTest.java From chassis with Apache License 2.0 | 5 votes |
private static com.amazonaws.regions.Region eqRegion(final com.amazonaws.regions.Region region) { EasyMock.reportMatcher(new IArgumentMatcher() { @Override public boolean matches(Object o) { com.amazonaws.regions.Region givenRegion = (com.amazonaws.regions.Region) o; return givenRegion.getName().equals(region.getName()); } @Override public void appendTo(StringBuffer stringBuffer) { stringBuffer.append("eqReqion for ").append(region.getName()); } }); return region; }
Example #7
Source File: ServerInstanceContext.java From chassis with Apache License 2.0 | 4 votes |
private void initAmazonClients() { amazonEC2.setRegion(com.amazonaws.regions.Region.getRegion(Regions.fromName(this.region))); amazonElasticLoadBalancing.setRegion(com.amazonaws.regions.Region.getRegion(Regions.fromName(this.region))); }
Example #8
Source File: AWSDatabaseHolder.java From billow with Apache License 2.0 | 4 votes |
public AWSDatabaseHolder(Config config) { maxAgeInMs = config.getDuration("maxAge", TimeUnit.MILLISECONDS); final DefaultAWSCredentialsProviderChain awsCredentialsProviderChain = new DefaultAWSCredentialsProviderChain(); final ClientConfiguration clientConfig = new ClientConfiguration(); clientConfig.setRetryPolicy(new RetryPolicy(null, null, config.getInt("maxErrorRetry"), true)); clientConfig.setSocketTimeout(config.getInt("socketTimeout") * 1000); final AmazonEC2 bootstrapEC2Client = AmazonEC2ClientBuilder.standard().withCredentials(awsCredentialsProviderChain).build(); ec2Clients = Maps.newHashMap(); rdsClients = Maps.newHashMap(); sqsClients = Maps.newHashMap(); dynamoDBClients = Maps.newHashMap(); elasticacheClients = Maps.newHashMap(); elasticsearchClients = Maps.newHashMap(); final List<Region> ec2Regions = bootstrapEC2Client.describeRegions().getRegions(); for (Region region : ec2Regions) { final String regionName = region.getRegionName(); final String endpoint = region.getEndpoint(); log.debug("Adding ec2 region {}", region); if (config.getBoolean("ec2Enabled")) { final AmazonEC2Client ec2Client = new AmazonEC2Client(awsCredentialsProviderChain, clientConfig); ec2Client.setEndpoint(endpoint); ec2Clients.put(regionName, ec2Client); } if (config.getBoolean("rdsEnabled")) { final AmazonRDSClient rdsClient = new AmazonRDSClient(awsCredentialsProviderChain, clientConfig); rdsClient.setEndpoint(endpoint.replaceFirst("ec2\\.", "rds.")); rdsClients.put(regionName, rdsClient); } if (config.getBoolean("dynamodbEnabled")) { final AmazonDynamoDBClient dynamoDBClient = new AmazonDynamoDBClient(awsCredentialsProviderChain, clientConfig); dynamoDBClient.setEndpoint(endpoint.replaceFirst("ec2\\.", "dynamodb.")); dynamoDBClients.put(regionName, dynamoDBClient); } if (config.getBoolean("sqsEnabled")) { final AmazonSQSClient sqsClient = new AmazonSQSClient(awsCredentialsProviderChain, clientConfig); sqsClient.setEndpoint(endpoint.replaceFirst("ec2\\.", "sqs.")); sqsClients.put(regionName, sqsClient); } if (config.getBoolean("elasticacheEnabled")) { final AmazonElastiCacheClient elastiCacheClient = new AmazonElastiCacheClient (awsCredentialsProviderChain, clientConfig); elastiCacheClient.setEndpoint(endpoint.replaceFirst("ec2\\.", "elasticache.")); elasticacheClients.put(regionName, elastiCacheClient); } if (config.getBoolean("elasticsearchEnabled")) { final AWSElasticsearchClient elasticsearchClient = new AWSElasticsearchClient (awsCredentialsProviderChain, clientConfig); elasticsearchClient.setEndpoint(endpoint.replaceFirst("ec2\\.", "es.")); elasticsearchClients.put(regionName, elasticsearchClient); } } this.iamClient = AmazonIdentityManagementClientBuilder.standard() .withCredentials(awsCredentialsProviderChain) .withClientConfiguration(clientConfig) .build(); if (config.hasPath("accountNumber")) { this.awsAccountNumber = config.getString("accountNumber"); } else { this.awsAccountNumber = null; } if (config.hasPath("arnPartition")) { this.awsARNPartition = config.getString("arnPartition"); } else { this.awsARNPartition = "aws"; } rebuild(); }