本文整理汇总了Java中com.xerox.amazonws.ec2.RegionInfo类的典型用法代码示例。如果您正苦于以下问题:Java RegionInfo类的具体用法?Java RegionInfo怎么用?Java RegionInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RegionInfo类属于com.xerox.amazonws.ec2包,在下文中一共展示了RegionInfo类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convertObject
import com.xerox.amazonws.ec2.RegionInfo; //导入依赖的package包/类
@Override
protected Region convertObject(RegionInfo from) {
Region to = new Region();
to.setRegionName(from.getName());
to.setEndpoint(from.getUrl());
return to;
}
示例2: describeRegions
import com.xerox.amazonws.ec2.RegionInfo; //导入依赖的package包/类
@Override
public DescribeRegionsResult describeRegions(DescribeRegionsRequest describeRegionsRequest) {
try {
List<RegionInfo> infos = jec2.describeRegions(describeRegionsRequest.getRegionNames());
List<Region> regions = new RegionConverter().convert(infos);
return new DescribeRegionsResult().withRegions(regions);
} catch (EC2Exception e) {
throw new AmazonClientException(e);
}
}
示例3: testEc2DescribeRegionsSingle
import com.xerox.amazonws.ec2.RegionInfo; //导入依赖的package包/类
@Override
public void testEc2DescribeRegionsSingle() throws Exception {
// act
List<RegionInfo> regionInfos = ec2.describeRegions(Arrays.asList(new String[] { "US_EAST" }));
// assert
assertEquals(1, regionInfos.size());
assertEquals("US_EAST", regionInfos.get(0).getName());
}
示例4: testEc2DescribeRegionsEmpty
import com.xerox.amazonws.ec2.RegionInfo; //导入依赖的package包/类
@Override
public void testEc2DescribeRegionsEmpty() throws Exception {
// act
List<RegionInfo> regionInfos = ec2.describeRegions(new ArrayList<String>());
// assert
assertEquals(3, regionInfos.size());
assertEquals("US_EAST", regionInfos.get(0).getName());
assertEquals("US_WEST", regionInfos.get(1).getName());
assertEquals("UK", regionInfos.get(2).getName());
}
示例5: testEc2DescribeRegions
import com.xerox.amazonws.ec2.RegionInfo; //导入依赖的package包/类
@Test
public void testEc2DescribeRegions() throws Exception {
// act
List<RegionInfo> regions = ec2.describeRegions(null);
// assert
assertEquals(2, regions.size());
assertThatRegionsContainsRegion(regions, US_REGION_NAME, US_REGION_ENDPOINT);
assertThatRegionsContainsRegion(regions, UK_REGION_NAME, UK_REGION_ENDPOINT);
}
示例6: assertThatRegionsContainsRegion
import com.xerox.amazonws.ec2.RegionInfo; //导入依赖的package包/类
private void assertThatRegionsContainsRegion(List<RegionInfo> regions, String regionName, String regionEndpoint) {
for (RegionInfo region : regions) {
if (region.getName().equals(regionName) && region.getUrl().equals(regionEndpoint))
return;
}
fail(String.format("%s with endpoint %s not found in %s", regionName, regionEndpoint, regions));
}
示例7: getRegionUrl
import com.xerox.amazonws.ec2.RegionInfo; //导入依赖的package包/类
protected String getRegionUrl(OptionSet options) throws Exception {
if(options.has("region")) {
return CmdUtils.valueOf(options, "region", RegionInfo.REGIONURL_US_EAST);
} else {
return RegionInfo.REGIONURL_US_EAST;
}
}
示例8: run
import com.xerox.amazonws.ec2.RegionInfo; //导入依赖的package包/类
@Override
public void run(String[] args) throws Exception {
parser.accepts("help", "Prints this help");
parser.accepts("logging",
"Options are \"debug\", \"info\" (default), \"warn\", \"error\", or \"off\"")
.withRequiredArg();
parser.accepts("accessid", "Access ID (used instead of accessidfile)").withRequiredArg();
parser.accepts("accessidfile", "Access ID file (used instead of accessid)")
.withRequiredArg();
parser.accepts("secretkey", "Secret key (used instead of secretkeyfile)").withRequiredArg();
parser.accepts("secretkeyfile", "Secret key file (used instead of secretkey)")
.withRequiredArg();
parser.accepts("securitygroups", "Security groups to allow on instances (optional)")
.withRequiredArg();
parser.accepts("ami", "AMI").withRequiredArg();
parser.accepts("keypairid", "KeyPairID").withRequiredArg();
parser.accepts("instances", "Number of instances (default 1)")
.withRequiredArg()
.ofType(Integer.class);
parser.accepts("instancetype",
"Instance type; options are " + Ec2Connection.Ec2InstanceType.DEFAULT
+ " (default), " + Ec2Connection.Ec2InstanceType.LARGE + ", "
+ Ec2Connection.Ec2InstanceType.XLARGE + ", "
+ Ec2Connection.Ec2InstanceType.MEDIUM_HCPU + ", and "
+ Ec2Connection.Ec2InstanceType.XLARGE_HCPU).withRequiredArg();
parser.accepts("region",
"Region type; options are " + RegionInfo.REGIONURL_AP_SOUTHEAST + ", "
+ RegionInfo.REGIONURL_EU_WEST + ", " + RegionInfo.REGIONURL_US_WEST
+ ", " + RegionInfo.REGIONURL_US_EAST + " (default) ")
.withRequiredArg();
OptionSet options = parse(args);
String accessId = getAccessId(options);
String secretKey = getSecretKey(options);
String ami = getRequiredString(options, "ami");
String keypairId = getRequiredString(options, "keypairid");
String regionUrl = getRegionUrl(options);
int instanceCount = CmdUtils.valueOf(options, "instances", 1);
String securityGroups = CmdUtils.valueOf(options, "securitygroups", null);
List<String> securityGroupsList = (securityGroups != null) ? Arrays.asList(securityGroups.split(","))
: null;
Ec2Connection.Ec2InstanceType instanceType = null;
try {
instanceType = Ec2Connection.Ec2InstanceType.valueOf(CmdUtils.valueOf(options,
"instancetype",
"DEFAULT"));
} catch(Exception e) {
printUsage();
}
Ec2Connection ec2Connection = new TypicaEc2Connection(accessId, secretKey, null, regionUrl);
List<HostNamePair> hostNamePairs = ec2Connection.createInstances(ami,
keypairId,
instanceType,
instanceCount,
securityGroupsList);
StringBuilder s = new StringBuilder();
for(HostNamePair hostNamePair: hostNamePairs) {
s.append(hostNamePair.getExternalHostName());
s.append('=');
s.append(hostNamePair.getInternalHostName());
s.append(Utils.NEWLINE);
}
System.out.print(s);
}
示例9: run
import com.xerox.amazonws.ec2.RegionInfo; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void run(String[] args) throws Exception {
parser.accepts("help", "Prints this help");
parser.accepts("logging",
"Options are \"debug\", \"info\" (default), \"warn\", \"error\", or \"off\"")
.withRequiredArg();
parser.accepts("accessid", "Access ID (used instead of accessidfile)").withRequiredArg();
parser.accepts("accessidfile", "Access ID file (used instead of accessid)")
.withRequiredArg();
parser.accepts("secretkey", "Secret key (used instead of secretkeyfile)").withRequiredArg();
parser.accepts("secretkeyfile", "Secret key file (used instead of secretkey)")
.withRequiredArg();
parser.accepts("hostnames", "File containing host names").withRequiredArg();
parser.accepts("instances", "File containing instance IDs").withRequiredArg();
parser.accepts("region",
"Region type; options are " + RegionInfo.REGIONURL_AP_SOUTHEAST + ", "
+ RegionInfo.REGIONURL_EU_WEST + ", " + RegionInfo.REGIONURL_US_WEST
+ ", " + RegionInfo.REGIONURL_US_EAST + " (default) ")
.withRequiredArg();
OptionSet options = parse(args);
String accessId = getAccessId(options);
String secretKey = getSecretKey(options);
String regionUrl = getRegionUrl(options);
Ec2Connection ec2Connection = new TypicaEc2Connection(accessId, secretKey, null, regionUrl);
List<String> hostNames = new ArrayList<String>();
File hostNamesFile = getInputFile(options, "hostnames");
File instancesFile = getInputFile(options, "instances");
if(hostNamesFile == null && instancesFile == null)
printUsage();
if(hostNamesFile != null) {
List<HostNamePair> hostNamePairs = getHostNamesPairsFromFile(hostNamesFile);
for(HostNamePair hostNamePair: hostNamePairs)
hostNames.add(hostNamePair.getExternalHostName());
ec2Connection.deleteInstancesByHostName(hostNames);
}
if(instancesFile != null) {
List<String> instanceIds = FileUtils.readLines(instancesFile);
ec2Connection.deleteInstancesByInstanceId(instanceIds);
}
}