本文整理汇总了Java中com.amazonaws.services.ec2.model.InstanceType类的典型用法代码示例。如果您正苦于以下问题:Java InstanceType类的具体用法?Java InstanceType怎么用?Java InstanceType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
InstanceType类属于com.amazonaws.services.ec2.model包,在下文中一共展示了InstanceType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createAndRunInstancesWithSecurityGroupsTest
import com.amazonaws.services.ec2.model.InstanceType; //导入依赖的package包/类
@Test
public void createAndRunInstancesWithSecurityGroupsTest() {
template.send("direct:createAndRun", new Processor() {
public void process(Exchange exchange) throws Exception {
exchange.getIn().setHeader(EC2Constants.IMAGE_ID, "ami-fd65ba94");
exchange.getIn().setHeader(EC2Constants.INSTANCE_TYPE, InstanceType.T2Micro);
exchange.getIn().setHeader(EC2Constants.INSTANCE_MIN_COUNT, 1);
exchange.getIn().setHeader(EC2Constants.INSTANCE_MAX_COUNT, 1);
Collection<String> secGroups = new ArrayList<String>();
secGroups.add("secgroup-1");
secGroups.add("secgroup-2");
exchange.getIn().setHeader(EC2Constants.INSTANCE_SECURITY_GROUPS, secGroups);
}
});
}
示例2: testConfigRoundtrip
import com.amazonaws.services.ec2.model.InstanceType; //导入依赖的package包/类
public void testConfigRoundtrip() throws Exception {
String ami = "ami1";
String description = "foo ami";
EC2Tag tag1 = new EC2Tag( "name1", "value1" );
EC2Tag tag2 = new EC2Tag( "name2", "value2" );
List<EC2Tag> tags = new ArrayList<EC2Tag>();
tags.add( tag1 );
tags.add( tag2 );
SlaveTemplate orig = new SlaveTemplate(ami, EC2AbstractSlave.TEST_ZONE, null, "default", "foo", InstanceType.M1Large, "ttt", Node.Mode.NORMAL, description, "bar", "bbb", "aaa", "10", "fff", null, "-Xmx1g", false, "subnet 456", tags, null, false, null, "", true, false, "", false, "");
List<SlaveTemplate> templates = new ArrayList<SlaveTemplate>();
templates.add(orig);
AmazonEC2Cloud ac = new AmazonEC2Cloud("us-east-1", false, "abc", "def", "us-east-1", "ghi", "3", templates);
hudson.clouds.add(ac);
submit(createWebClient().goTo("configure").getFormByName("config"));
SlaveTemplate received = ((EC2Cloud)hudson.clouds.iterator().next()).getTemplate(description);
assertEqualBeans(orig, received, "ami,zone,description,remoteFS,type,jvmopts,stopOnTerminate,securityGroups,subnetId,usePrivateDnsName,useEphemeralDevices,useDedicatedTenancy");
}
示例3: testConfigRoundtripWithPrivateDns
import com.amazonaws.services.ec2.model.InstanceType; //导入依赖的package包/类
public void testConfigRoundtripWithPrivateDns() throws Exception {
String ami = "ami1";
String description = "foo ami";
EC2Tag tag1 = new EC2Tag( "name1", "value1" );
EC2Tag tag2 = new EC2Tag( "name2", "value2" );
List<EC2Tag> tags = new ArrayList<EC2Tag>();
tags.add( tag1 );
tags.add( tag2 );
SlaveTemplate orig = new SlaveTemplate(ami, EC2AbstractSlave.TEST_ZONE, null, "default", "foo", InstanceType.M1Large, "ttt", Node.Mode.NORMAL, description, "bar", "bbb", "aaa", "10", "fff", null, "-Xmx1g", false, "subnet 456", tags, null, true, null, "", false, false, "", false, "");
List<SlaveTemplate> templates = new ArrayList<SlaveTemplate>();
templates.add(orig);
AmazonEC2Cloud ac = new AmazonEC2Cloud("us-east-1", false, "abc", "def", "us-east-1", "ghi", "3", templates);
hudson.clouds.add(ac);
submit(createWebClient().goTo("configure").getFormByName("config"));
SlaveTemplate received = ((EC2Cloud)hudson.clouds.iterator().next()).getTemplate(description);
assertEqualBeans(orig, received, "ami,zone,description,remoteFS,type,jvmopts,stopOnTerminate,securityGroups,subnetId,tags,usePrivateDnsName");
}
示例4: testConfigWithSpotBidPrice
import com.amazonaws.services.ec2.model.InstanceType; //导入依赖的package包/类
/**
* Tests to make sure the slave created has been configured properly.
* Also tests to make sure the spot max bid price has been set properly.
* @throws Exception - Exception that can be thrown by the Jenkins test harness
*/
public void testConfigWithSpotBidPrice() throws Exception {
String ami = "ami1";
String description = "foo ami";
EC2Tag tag1 = new EC2Tag( "name1", "value1" );
EC2Tag tag2 = new EC2Tag( "name2", "value2" );
List<EC2Tag> tags = new ArrayList<EC2Tag>();
tags.add( tag1 );
tags.add( tag2 );
SpotConfiguration spotConfig = new SpotConfiguration(".05", SpotInstanceType.OneTime.toString());
SlaveTemplate orig = new SlaveTemplate(ami, EC2AbstractSlave.TEST_ZONE, spotConfig, "default", "foo", InstanceType.M1Large, "ttt", Node.Mode.NORMAL, "foo ami", "bar", "bbb", "aaa", "10", "fff", null, "-Xmx1g", false, "subnet 456", tags, null, true, null, "", false, false, "", false, "");
List<SlaveTemplate> templates = new ArrayList<SlaveTemplate>();
templates.add(orig);
AmazonEC2Cloud ac = new AmazonEC2Cloud("us-east-1", false, "abc", "def", "us-east-1", "ghi", "3", templates);
hudson.clouds.add(ac);
submit(createWebClient().goTo("configure").getFormByName("config"));
SlaveTemplate received = ((EC2Cloud)hudson.clouds.iterator().next()).getTemplate(description);
assertEqualBeans(orig, received, "ami,zone,spotConfig,description,remoteFS,type,jvmopts,stopOnTerminate,securityGroups,subnetId,tags,usePrivateDnsName");
}
示例5: testConfigRoundtripIamRole
import com.amazonaws.services.ec2.model.InstanceType; //导入依赖的package包/类
/**
* Test to make sure the IAM Role is set properly.
*
* @throws Exception
*/
public void testConfigRoundtripIamRole() throws Exception {
String ami = "ami1";
String description = "foo ami";
EC2Tag tag1 = new EC2Tag( "name1", "value1" );
EC2Tag tag2 = new EC2Tag( "name2", "value2" );
List<EC2Tag> tags = new ArrayList<EC2Tag>();
tags.add( tag1 );
tags.add( tag2 );
SlaveTemplate orig = new SlaveTemplate(ami, EC2AbstractSlave.TEST_ZONE, null, "default", "foo", InstanceType.M1Large, "ttt", Node.Mode.NORMAL, description, "bar", "bbb", "aaa", "10", "fff", null, "-Xmx1g", false, "subnet 456", tags, null, false, null, "iamInstanceProfile", false, false, "", false, "");
List<SlaveTemplate> templates = new ArrayList<SlaveTemplate>();
templates.add(orig);
AmazonEC2Cloud ac = new AmazonEC2Cloud("us-east-1", false, "abc", "def", "us-east-1", "ghi", "3", templates);
hudson.clouds.add(ac);
submit(createWebClient().goTo("configure").getFormByName("config"));
SlaveTemplate received = ((EC2Cloud)hudson.clouds.iterator().next()).getTemplate(description);
assertEqualBeans(orig, received, "ami,zone,description,remoteFS,type,jvmopts,stopOnTerminate,securityGroups,subnetId,usePrivateDnsName,iamInstanceProfile");
}
示例6: testWindowsConfigRoundTrip
import com.amazonaws.services.ec2.model.InstanceType; //导入依赖的package包/类
public void testWindowsConfigRoundTrip() throws Exception {
String ami = "ami1";
String description = "foo ami";
EC2Tag tag1 = new EC2Tag( "name1", "value1" );
EC2Tag tag2 = new EC2Tag( "name2", "value2" );
List<EC2Tag> tags = new ArrayList<EC2Tag>();
tags.add( tag1 );
tags.add( tag2 );
SlaveTemplate orig = new SlaveTemplate(ami, EC2AbstractSlave.TEST_ZONE, null, "default", "foo", InstanceType.M1Large, "ttt", Node.Mode.NORMAL, description, "bar", "bbb", "aaa", "10", "rrr", new WindowsData("password", false, ""), "-Xmx1g", false, "subnet 456", tags, null, false, null, "", true, false, "", false, "");
List<SlaveTemplate> templates = new ArrayList<SlaveTemplate>();
templates.add(orig);
AmazonEC2Cloud ac = new AmazonEC2Cloud("us-east-1", false, "abc", "def", "us-east-1", "ghi", "3", templates);
hudson.clouds.add(ac);
submit(createWebClient().goTo("configure").getFormByName("config"));
SlaveTemplate received = ((EC2Cloud)hudson.clouds.iterator().next()).getTemplate(description);
assertEqualBeans(orig, received, "amiType");
}
示例7: testUnixConfigRoundTrip
import com.amazonaws.services.ec2.model.InstanceType; //导入依赖的package包/类
public void testUnixConfigRoundTrip() throws Exception {
String ami = "ami1";
String description = "foo ami";
EC2Tag tag1 = new EC2Tag( "name1", "value1" );
EC2Tag tag2 = new EC2Tag( "name2", "value2" );
List<EC2Tag> tags = new ArrayList<EC2Tag>();
tags.add( tag1 );
tags.add( tag2 );
SlaveTemplate orig = new SlaveTemplate(ami, EC2AbstractSlave.TEST_ZONE, null, "default", "foo", InstanceType.M1Large, "ttt", Node.Mode.NORMAL, description, "bar", "bbb", "aaa", "10", "rrr", new UnixData("sudo", "22"), "-Xmx1g", false, "subnet 456", tags, null, false, null, "", true, false, "", false, "");
List<SlaveTemplate> templates = new ArrayList<SlaveTemplate>();
templates.add(orig);
AmazonEC2Cloud ac = new AmazonEC2Cloud("us-east-1", false, "abc", "def", "us-east-1", "ghi", "3", templates);
hudson.clouds.add(ac);
submit(createWebClient().goTo("configure").getFormByName("config"));
SlaveTemplate received = ((EC2Cloud)hudson.clouds.iterator().next()).getTemplate(description);
assertEqualBeans(orig, received, "amiType");
}
示例8: createInstance
import com.amazonaws.services.ec2.model.InstanceType; //导入依赖的package包/类
private com.amazonaws.services.ec2.model.Instance createInstance(KeyPair keyPair, String sgId) throws Exception {
RunInstancesRequest request = new RunInstancesRequest()
.withKeyName(keyPair.remoteKeyPair.getKeyName())
.withInstanceType(InstanceType.M4Large)
.withImageId(resource.baseAMI.imageId())
.withMinCount(1)
.withMaxCount(1)
.withSecurityGroupIds(sgId);
if (bakeSubnet != null) request.withSubnetId(bakeSubnet.getSubnetId());
return AWS.ec2.runInstances(request,
tagHelper.name(resourceId),
tagHelper.env(),
tagHelper.resourceId(resourceId),
tagHelper.type("ami"),
tagHelper.amiImageId(resource.id())).get(0);
}
示例9: basicSanity
import com.amazonaws.services.ec2.model.InstanceType; //导入依赖的package包/类
@Test
public void basicSanity() {
Ec2ProvisioningTemplate config = new Ec2ProvisioningTemplate(INSTANCE_TYPE, AMI, SUBNET_IDS, ASSIGN_PUBLIC_IP,
KEYPAIR, INSTANCE_PROFILE_ARN, SECURITY_GROUP_IDS, USER_DATA, EBS_OPTIMIZED, TAGS);
config.validate();
assertThat(config.getInstanceType(), is(InstanceType.fromValue(INSTANCE_TYPE)));
assertThat(config.getAmiId(), is(AMI));
assertThat(config.getSubnetIds(), is(SUBNET_IDS));
assertThat(config.isAssignPublicIp(), is(ASSIGN_PUBLIC_IP));
assertThat(config.getKeyPair(), is(KEYPAIR));
assertThat(config.getIamInstanceProfileARN(), is(INSTANCE_PROFILE_ARN));
assertThat(config.getSecurityGroupIds(), is(SECURITY_GROUP_IDS));
assertThat(config.getEncodedUserData(), is(USER_DATA));
assertThat(config.isEbsOptimized(), is(EBS_OPTIMIZED));
assertThat(config.getTags(), is(TAGS));
}
示例10: onlyMandatoryArguments
import com.amazonaws.services.ec2.model.InstanceType; //导入依赖的package包/类
/**
* Only instanceType, amiId, and subnetIds are mandatory.
*/
@Test
public void onlyMandatoryArguments() {
Ec2ProvisioningTemplate config = new Ec2ProvisioningTemplate(INSTANCE_TYPE, AMI, SUBNET_IDS, null, null, null,
null, null, null, null);
config.validate();
assertThat(config.getInstanceType(), is(InstanceType.fromValue(INSTANCE_TYPE)));
assertThat(config.getAmiId(), is(AMI));
assertThat(config.getSubnetIds(), is(SUBNET_IDS));
assertThat(config.isAssignPublicIp(), is(false));
assertThat(config.getKeyPair(), is(nullValue()));
assertThat(config.getIamInstanceProfileARN(), is(nullValue()));
assertThat(config.getSecurityGroupIds(), is(Collections.emptyList()));
assertThat(config.getEncodedUserData(), is(nullValue()));
assertThat(config.isEbsOptimized(), is(false));
assertThat(config.getTags(), is(Collections.emptyMap()));
}
示例11: convertCompleteInstance
import com.amazonaws.services.ec2.model.InstanceType; //导入依赖的package包/类
@Test
public void convertCompleteInstance() {
DateTime launchTime = UtcTime.now();
Instance instance = new Instance().withInstanceId("i-1")
.withState(new InstanceState().withName(InstanceStateName.Running)).withPublicIpAddress("1.2.3.4")
.withPrivateIpAddress("1.2.3.5").withInstanceType(InstanceType.M1Small)
.withLaunchTime(launchTime.toDate())
.withMonitoring(new Monitoring().withState(MonitoringState.Disabled)).withHypervisor(HypervisorType.Xen)
.withPlacement(new Placement("us-east-1c"));
Machine machine = convert(instance);
assertThat(machine.getId(), is(instance.getInstanceId()));
assertThat(machine.getLaunchTime(), is(launchTime));
assertThat(machine.getMachineState(), is(MachineState.RUNNING));
assertThat(machine.getCloudProvider(), is(CloudProviders.AWS_EC2));
assertThat(machine.getRegion(), is("us-east-1"));
assertThat(machine.getMachineSize(), is("m1.small"));
assertThat(machine.getMembershipStatus(), is(MembershipStatus.defaultStatus()));
assertThat(machine.getServiceState(), is(ServiceState.UNKNOWN));
assertThat(machine.getPublicIps().size(), is(1));
assertThat(machine.getPublicIps().get(0), is(instance.getPublicIpAddress()));
assertThat(machine.getPrivateIps().size(), is(1));
assertThat(machine.getPrivateIps().get(0), is(instance.getPrivateIpAddress()));
assertThat(machine.getMetadata(), is(JsonUtils.toJson(instance)));
}
示例12: convertInstanceMissingPublicIp
import com.amazonaws.services.ec2.model.InstanceType; //导入依赖的package包/类
@Test
public void convertInstanceMissingPublicIp() {
DateTime launchTime = UtcTime.now();
Instance instance = new Instance().withInstanceId("i-1")
.withState(new InstanceState().withName(InstanceStateName.Running)).withPrivateIpAddress("1.2.3.5")
.withInstanceType(InstanceType.M1Small).withLaunchTime(launchTime.toDate())
.withMonitoring(new Monitoring().withState(MonitoringState.Disabled)).withHypervisor(HypervisorType.Xen)
.withPlacement(new Placement("us-east-1a"));
Machine machine = convert(instance);
assertThat(machine.getId(), is(instance.getInstanceId()));
assertThat(machine.getCloudProvider(), is(CloudProviders.AWS_EC2));
assertThat(machine.getRegion(), is("us-east-1"));
assertThat(machine.getMachineSize(), is("m1.small"));
assertThat(machine.getLaunchTime(), is(launchTime));
assertThat(machine.getMachineState(), is(MachineState.RUNNING));
assertThat(machine.getMembershipStatus(), is(MembershipStatus.defaultStatus()));
assertThat(machine.getServiceState(), is(ServiceState.UNKNOWN));
assertThat(machine.getPublicIps().size(), is(0));
assertThat(machine.getPrivateIps().size(), is(1));
assertThat(machine.getPrivateIps().get(0), is(instance.getPrivateIpAddress()));
assertThat(machine.getMetadata(), is(JsonUtils.toJson(instance)));
}
示例13: convertInstanceMissingPrivateIp
import com.amazonaws.services.ec2.model.InstanceType; //导入依赖的package包/类
@Test
public void convertInstanceMissingPrivateIp() {
DateTime launchTime = UtcTime.now();
Instance instance = new Instance().withInstanceId("i-1")
.withState(new InstanceState().withName(InstanceStateName.Running)).withPublicIpAddress("1.2.3.4")
.withInstanceType(InstanceType.M1Medium).withLaunchTime(launchTime.toDate())
.withMonitoring(new Monitoring().withState(MonitoringState.Disabled)).withHypervisor(HypervisorType.Xen)
.withPlacement(new Placement("us-east-1b"));
Machine machine = convert(instance);
assertThat(machine.getId(), is(instance.getInstanceId()));
assertThat(machine.getCloudProvider(), is(CloudProviders.AWS_EC2));
assertThat(machine.getRegion(), is("us-east-1"));
assertThat(machine.getMachineSize(), is("m1.medium"));
assertThat(machine.getLaunchTime(), is(launchTime));
assertThat(machine.getMachineState(), is(MachineState.RUNNING));
assertThat(machine.getMembershipStatus(), is(MembershipStatus.defaultStatus()));
assertThat(machine.getServiceState(), is(ServiceState.UNKNOWN));
assertThat(machine.getPublicIps().size(), is(1));
assertThat(machine.getPublicIps().get(0), is(instance.getPublicIpAddress()));
assertThat(machine.getPrivateIps().size(), is(0));
assertThat(machine.getMetadata(), is(JsonUtils.toJson(instance)));
}
示例14: convertSpotInstance
import com.amazonaws.services.ec2.model.InstanceType; //导入依赖的package包/类
/**
* A converted spot instance {@link Machine} should have a cloud provider
* value of {@link CloudProviders#AWS_SPOT} to distinguish it from a regular
* EC2 on-demand instance.
*/
@Test
public void convertSpotInstance() {
// convert on-demand instance: cloud provider should be AWS_EC2
Instance onDemandInstance = new Instance().withInstanceId("i-1").withInstanceType(InstanceType.M1Medium)
.withState(new InstanceState().withName(InstanceStateName.Running))
.withPlacement(new Placement("us-east-1b"));
Machine onDemandMachine = convert(onDemandInstance);
assertThat(onDemandMachine.getCloudProvider(), is(CloudProviders.AWS_EC2));
// convert spot instance: cloud provider should be AWS_EC2
Instance spotInstance = new Instance().withInstanceId("i-1").withInstanceType(InstanceType.M1Medium)
.withState(new InstanceState().withName(InstanceStateName.Running)).withSpotInstanceRequestId("sir-123")
.withPlacement(new Placement("us-east-1b"));
Machine spotMachine = convert(spotInstance);
assertThat(spotMachine.getCloudProvider(), is(CloudProviders.AWS_SPOT));
}
示例15: listMachinesOnGroupThatHasNotReachedDesiredCapacity
import com.amazonaws.services.ec2.model.InstanceType; //导入依赖的package包/类
/**
* If the actual size of the Auto Scaling Group is less than desired
* capacity (for example, when there is a shortage in supply of instances)
* the {@link AwsAsPoolDriver} should report the missing instances as being
* pseudo instances in state {@link MachineState#REQUESTED}, to not fool the
* {@link BaseCloudPool} from believing that the {@link CloudPoolDriver} is
* too small and order new machines to be started (and increase the desired
* capacity even more).
*/
@Test
public void listMachinesOnGroupThatHasNotReachedDesiredCapacity() throws CloudPoolDriverException {
// two missing instances: desired capacity: 3, actual capacity: 1
int desiredCapacity = 3;
setUpMockedAutoScalingGroup(GROUP_NAME, ONDEMAND_LAUNCH_CONFIG, desiredCapacity,
ec2Instances(ec2Instance("i-1", "running")));
List<Machine> groupMembers = this.driver.listMachines();
assertThat(groupMembers, is(MachinesMatcher.machines("i-1", "i-requested1", "i-requested2")));
assertThat(groupMembers.get(0).getMachineState(), is(MachineState.RUNNING));
assertThat(groupMembers.get(0).getCloudProvider(), is(CloudProviders.AWS_EC2));
assertThat(groupMembers.get(0).getMachineSize(), is(InstanceType.M1Medium.toString()));
assertThat(groupMembers.get(1).getMachineState(), is(MachineState.REQUESTED));
assertThat(groupMembers.get(1).getCloudProvider(), is(CloudProviders.AWS_EC2));
assertThat(groupMembers.get(1).getMachineSize(), is(InstanceType.M1Medium.toString()));
assertThat(groupMembers.get(2).getMachineState(), is(MachineState.REQUESTED));
assertThat(groupMembers.get(2).getCloudProvider(), is(CloudProviders.AWS_EC2));
assertThat(groupMembers.get(2).getMachineSize(), is(InstanceType.M1Medium.toString()));
}