本文整理汇总了Java中org.jclouds.compute.domain.Template类的典型用法代码示例。如果您正苦于以下问题:Java Template类的具体用法?Java Template怎么用?Java Template使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Template类属于org.jclouds.compute.domain包,在下文中一共展示了Template类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: execute
import org.jclouds.compute.domain.Template; //导入依赖的package包/类
@Override
public Map<?, ListenableFuture<Void>> execute(
final String group, final int count, final Template template,
final Set<NodeMetadata> goodNodes, final Map<NodeMetadata, Exception> badNodes,
final Multimap<NodeMetadata, CustomizationResponse> customizationResponses) {
final DimensionDataCloudControllerTemplateOptions templateOptions = template.getOptions().as(DimensionDataCloudControllerTemplateOptions.class);
String networkDomainName = firstNonNull(templateOptions.getNetworkDomainName(), DEFAULT_NETWORK_DOMAIN_NAME);
String vlanName = firstNonNull(templateOptions.getVlanName(), DEFAULT_VLAN_NAME);
String defaultPrivateIPv4BaseAddress = firstNonNull(templateOptions.getDefaultPrivateIPv4BaseAddress(), DEFAULT_PRIVATE_IPV4_BASE_ADDRESS);
Integer defaultPrivateIPv4PrefixSize = firstNonNull(templateOptions.getDefaultPrivateIPv4PrefixSize(), DEFAULT_PRIVATE_IPV4_PREFIX_SIZE);
String location = template.getLocation().getId();
// If networkDomain and vlanId overrides are supplied in TemplateOptions, always prefer those.
if (templateOptions.getNetworkDomainId() == null && templateOptions.getVlanId() == null) {
String networkDomainId = tryCreateOrGetExistingNetworkDomain(api, location, networkDomainName);
templateOptions.networkDomainId(networkDomainId);
String vlanId = tryCreateOrGetExistingVlan(api, templateOptions.getNetworkDomainId(), vlanName, defaultPrivateIPv4BaseAddress, defaultPrivateIPv4PrefixSize);
templateOptions.vlanId(vlanId);
}
return super.execute(group, count, template, goodNodes, badNodes, customizationResponses);
}
开发者ID:cloudsoft,项目名称:amp-dimensiondata,代码行数:24,代码来源:GetOrCreateNetworkDomainThenCreateNodes.java
示例2: apply
import org.jclouds.compute.domain.Template; //导入依赖的package包/类
public LoginCredentials apply(final Template template, final LoginCredentials fromNode) {
RunScriptOptions options = checkNotNull(template.getOptions(), "template options are required");
LoginCredentials.Builder builder = LoginCredentials.builder(fromNode);
if (options.getLoginUser() != null) {
builder.user(template.getOptions().getLoginUser());
}
if (options.getLoginPassword() != null) {
builder.password(options.getLoginPassword());
}
if (options.getLoginPrivateKey() != null) {
builder.privateKey(options.getLoginPrivateKey());
}
if (options.shouldAuthenticateSudo() != null && options.shouldAuthenticateSudo()) {
builder.authenticateSudo(true);
}
return builder.build();
}
开发者ID:cloudsoft,项目名称:amp-dimensiondata,代码行数:18,代码来源:UseNodeCredentialsButOverrideFromTemplate.java
示例3: provisionNodes
import org.jclouds.compute.domain.Template; //导入依赖的package包/类
public void provisionNodes() {
Map<String, String> singleTagConfig = new HashMap<String, String>();
singleTagConfig.put(TAG_1.getKey(), TAG_1.getValue());
Map<String, String> multiTagConfig = new HashMap<String, String>();
multiTagConfig.put(TAG_2.getKey(), TAG_2.getValue());
multiTagConfig.put(TAG_3.getKey(), TAG_3.getValue());
Template region1Template = getTemplateInRegion1(singleTagConfig);
Template region2Template = getTemplateInRegion2(multiTagConfig);
try {
createNode(GROUP_NAME_1, region1Template);
createNode(GROUP_NAME_1, region1Template);
createNode(GROUP_NAME_1, region2Template);
createNode(GROUP_NAME_2, region2Template);
createNode(GROUP_NAME_2, region1Template);
} catch (Exception e) {
e.printStackTrace();
}
}
开发者ID:hazelcast,项目名称:hazelcast-jclouds,代码行数:22,代码来源:LiveComputeServiceUtil.java
示例4: createNodesInRegionAndZone
import org.jclouds.compute.domain.Template; //导入依赖的package包/类
@Override
protected Set<RunningInstance> createNodesInRegionAndZone(String region, String zone, String group,
int count, Template template, RunInstancesOptions instanceOptions) {
Float spotPrice = getSpotPriceOrNull(template.getOptions());
if (spotPrice != null) {
AWSEC2TemplateOptions awsOptions = AWSEC2TemplateOptions.class.cast(template.getOptions());
LaunchSpecification spec = AWSRunInstancesOptions.class.cast(instanceOptions).getLaunchSpecificationBuilder()
.imageId(template.getImage().getProviderId()).availabilityZone(zone).subnetId(awsOptions.getSubnetId())
.publicIpAddressAssociated(awsOptions.isPublicIpAddressAssociated())
.iamInstanceProfileArn(awsOptions.getIAMInstanceProfileArn())
.iamInstanceProfileName(awsOptions.getIAMInstanceProfileName()).build();
RequestSpotInstancesOptions options = awsOptions.getSpotOptions();
if (logger.isDebugEnabled())
logger.debug(">> requesting %d spot instances region(%s) price(%f) spec(%s) options(%s)", count, region,
spotPrice, spec, options);
return ImmutableSet.<RunningInstance> copyOf(transform(client.getSpotInstanceApi().get()
.requestSpotInstancesInRegion(region, spotPrice, count, spec, options), spotConverter));
}
return super.createNodesInRegionAndZone(region, zone, group, count, template, instanceOptions);
}
开发者ID:apache,项目名称:stratos,代码行数:21,代码来源:AWSEC2CreateNodesInGroupThenAddToSet.java
示例5: execute
import org.jclouds.compute.domain.Template; //导入依赖的package包/类
public AWSRunInstancesOptions execute(String region, String group, Template template) {
AWSRunInstancesOptions instanceOptions = AWSRunInstancesOptions.class
.cast(super.execute(region, group, template));
String placementGroupName = template.getHardware().getId().startsWith("cc") ? createNewPlacementGroupUnlessUserSpecifiedOtherwise(
region, group, template.getOptions()) : null;
if (placementGroupName != null)
instanceOptions.inPlacementGroup(placementGroupName);
AWSEC2TemplateOptions awsTemplateOptions = AWSEC2TemplateOptions.class.cast(template.getOptions());
if (awsTemplateOptions.isMonitoringEnabled())
instanceOptions.enableMonitoring();
if (awsTemplateOptions.getIAMInstanceProfileArn() != null)
instanceOptions.withIAMInstanceProfileArn(awsTemplateOptions.getIAMInstanceProfileArn());
if (awsTemplateOptions.getIAMInstanceProfileName() != null)
instanceOptions.withIAMInstanceProfileName(awsTemplateOptions.getIAMInstanceProfileName());
if (awsTemplateOptions.getPrivateIpAddress() != null)
instanceOptions.withPrivateIpAddress(awsTemplateOptions.getPrivateIpAddress());
return instanceOptions;
}
开发者ID:apache,项目名称:stratos,代码行数:23,代码来源:CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.java
示例6: addSecurityGroups
import org.jclouds.compute.domain.Template; //导入依赖的package包/类
@Override
protected void addSecurityGroups(String region, String group, Template template, RunInstancesOptions instanceOptions) {
AWSEC2TemplateOptions awsTemplateOptions = AWSEC2TemplateOptions.class.cast(template.getOptions());
AWSRunInstancesOptions awsInstanceOptions = AWSRunInstancesOptions.class.cast(instanceOptions);
if (!awsTemplateOptions.getGroupIds().isEmpty())
awsInstanceOptions.withSecurityGroupIds(awsTemplateOptions.getGroupIds());
String subnetId = awsTemplateOptions.getSubnetId();
boolean associatePublicIpAddress = awsTemplateOptions.isPublicIpAddressAssociated();
if (subnetId != null) {
if (associatePublicIpAddress){
AWSRunInstancesOptions.class.cast(instanceOptions).associatePublicIpAddressAndSubnetId(subnetId);
if (awsTemplateOptions.getGroupIds().size() > 0)
awsInstanceOptions.withSecurityGroupIdsForNetworkInterface(awsTemplateOptions.getGroupIds());
} else {
AWSRunInstancesOptions.class.cast(instanceOptions).withSubnetId(subnetId);
if (awsTemplateOptions.getGroupIds().size() > 0)
awsInstanceOptions.withSecurityGroupIds(awsTemplateOptions.getGroupIds());
}
} else {
if (!awsTemplateOptions.getGroupIds().isEmpty())
awsInstanceOptions.withSecurityGroupIds(awsTemplateOptions.getGroupIds());
super.addSecurityGroups(region, group, template, instanceOptions);
}
}
开发者ID:apache,项目名称:stratos,代码行数:25,代码来源:CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.java
示例7: createServer
import org.jclouds.compute.domain.Template; //导入依赖的package包/类
/**
* Create a server based on a Template. This method uses Template.fromHardware() and Template.fromImage() to
* also demonstrate iterating through Hardware and Images. Alternatively you do the same without iterating
* using the following Template.
*
* Template template = computeService.templateBuilder()
* .locationId(getLocationId())
* .osFamily(OsFamily.UBUNTU)
* .osVersionMatches("14.04")
* .minRam(1024)
* .build();
*/
private void createServer() throws RunNodesException, TimeoutException {
System.out.format("Create Server%n");
Template template = computeService.templateBuilder()
.locationId(REGION)
.fromHardware(getHardware())
.fromImage(getImage())
.build();
// This method will continue to poll for the server status and won't return until this server is ACTIVE
// If you want to know what's happening during the polling, enable logging. See
// /jclouds-example/rackspace/src/main/java/org/jclouds/examples/rackspace/Logging.java
Set<? extends NodeMetadata> nodes = computeService.createNodesInGroup(NAME, 1, template);
NodeMetadata nodeMetadata = nodes.iterator().next();
String publicAddress = nodeMetadata.getPublicAddresses().iterator().next();
System.out.format(" %s%n", nodeMetadata);
System.out.format(" Login: ssh %[email protected]%s%n", nodeMetadata.getCredentials().getUser(), publicAddress);
System.out.format(" Password: %s%n", nodeMetadata.getCredentials().getOptionalPassword().get());
}
开发者ID:jclouds,项目名称:jclouds-examples,代码行数:34,代码来源:CreateServer.java
示例8: createServer
import org.jclouds.compute.domain.Template; //导入依赖的package包/类
private Set<? extends NodeMetadata> createServer() throws RunNodesException, TimeoutException {
System.out.format("Create Server%n");
RegionAndId regionAndId = RegionAndId.fromRegionAndId(REGION, "performance1-1");
Template template = computeService.templateBuilder()
.locationId(REGION)
.osDescriptionMatches(".*Ubuntu 14.04.*")
.hardwareId(regionAndId.slashEncode())
.build();
// This method will continue to poll for the server status and won't return until this server is ACTIVE
// If you want to know what's happening during the polling, enable logging.
// See /jclouds-example/rackspace/src/main/java/org/jclouds/examples/rackspace/Logging.java
Set<? extends NodeMetadata> nodes = computeService.createNodesInGroup(NAME, numServers, template);
for (NodeMetadata nodeMetadata: nodes) {
System.out.format(" %s%n", nodeMetadata);
}
return nodes;
}
开发者ID:jclouds,项目名称:jclouds-examples,代码行数:22,代码来源:CloudServersPublish.java
示例9: createServer
import org.jclouds.compute.domain.Template; //导入依赖的package包/类
/**
* Create a server with the key pair.
*/
private NodeMetadata createServer(KeyPair keyPair) throws RunNodesException, TimeoutException {
System.out.format(" Create Server%n");
NovaTemplateOptions options = NovaTemplateOptions.Builder.keyPairName(keyPair.getName());
RegionAndId regionAndId = RegionAndId.fromRegionAndId(REGION, "performance1-1");
Template template = computeService.templateBuilder()
.locationId(REGION)
.osDescriptionMatches(".*Ubuntu 14.04.*")
.hardwareId(regionAndId.slashEncode())
.options(options)
.build();
// This method will continue to poll for the server status and won't return until this server is ACTIVE
// If you want to know what's happening during the polling, enable logging.
// See /jclouds-example/rackspace/src/main/java/org/jclouds/examples/rackspace/Logging.java
Set<? extends NodeMetadata> nodes = computeService.createNodesInGroup(NAME, 1, template);
NodeMetadata node = Iterables.getOnlyElement(nodes);
System.out.format(" %s%n", node);
return node;
}
开发者ID:jclouds,项目名称:jclouds-examples,代码行数:27,代码来源:CreateServerWithKeyPair.java
示例10: createServer
import org.jclouds.compute.domain.Template; //导入依赖的package包/类
private NodeMetadata createServer() throws RunNodesException, TimeoutException {
System.out.format("Create Server%n");
RegionAndId regionAndId = RegionAndId.fromRegionAndId(REGION, "performance1-1");
Template template = computeService.templateBuilder()
.locationId(REGION)
.osDescriptionMatches(".*Ubuntu 12.04.*")
.hardwareId(regionAndId.slashEncode())
.build();
Set<? extends NodeMetadata> nodes = computeService.createNodesInGroup(NAME, 1, template);
NodeMetadata nodeMetadata = nodes.iterator().next();
String publicAddress = nodeMetadata.getPublicAddresses().iterator().next();
// We set the password to something we know so we can login in the DetachVolume example
novaApi.getServerApi(REGION).changeAdminPass(nodeMetadata.getProviderId(), PASSWORD);
System.out.format(" %s%n", nodeMetadata);
System.out.format(" Login: ssh %[email protected]%s%n", nodeMetadata.getCredentials().getUser(), publicAddress);
System.out.format(" Password: %s%n", PASSWORD);
return nodeMetadata;
}
开发者ID:jclouds,项目名称:jclouds-examples,代码行数:24,代码来源:CreateVolumeAndAttach.java
示例11: testLaunchClusterWithDomainName
import org.jclouds.compute.domain.Template; //导入依赖的package包/类
@Test
public void testLaunchClusterWithDomainName() throws RunNodesException {
final String name = "test";
Template template = view.getComputeService().templateBuilder()
.osFamily(OsFamily.UBUNTU)
.locationId("NA9")
//.minRam(8192)
//.locationId("NA12")
.build();
DimensionDataCloudControllerTemplateOptions options = template.getOptions().as(DimensionDataCloudControllerTemplateOptions.class);
options
.inboundPorts(22, 8080, 8081)
.runScript(AdminAccess.standard())
.networkDomainId("91f577d2-5812-4e39-a79f-a35e42eb78a6")
.vlanId("025c59d7-b7e5-4261-95b8-4af067233ee7");
try {
Set<? extends NodeMetadata> nodes = view.getComputeService().createNodesInGroup(name, NUM_NODES, template);
assertThat(nodes).hasSize(NUM_NODES);
Map<? extends NodeMetadata, ExecResponse> responses = view.getComputeService().runScriptOnNodesMatching(runningInGroup(name), "echo hello");
assertThat(responses).hasSize(NUM_NODES);
for (ExecResponse execResponse : responses.values()) {
assertThat(execResponse.getOutput().trim()).isEqualTo("hello");
}
} catch (RunScriptOnNodesException e) {
Assert.fail();
} finally {
view.getComputeService().destroyNodesMatching(inGroup(name));
}
}
开发者ID:cloudsoft,项目名称:amp-dimensiondata,代码行数:35,代码来源:DimensionDataCloudControllerComputeServiceContextLiveTest.java
示例12: getTemplateInRegion1
import org.jclouds.compute.domain.Template; //导入依赖的package包/类
public Template getTemplateInRegion1(Map<String, String> tags) {
TemplateBuilder templateBuilder = computeService.templateBuilder();
templateBuilder.locationId(AWS_REGION_1);
templateBuilder.smallest();
templateBuilder.options(userMetadata(tags));
return templateBuilder.build();
}
开发者ID:hazelcast,项目名称:hazelcast-jclouds,代码行数:8,代码来源:LiveComputeServiceUtil.java
示例13: getTemplateInRegion2
import org.jclouds.compute.domain.Template; //导入依赖的package包/类
public Template getTemplateInRegion2(Map<String, String> tags) {
TemplateBuilder templateBuilder = computeService.templateBuilder();
templateBuilder.locationId(AWS_REGION_2);
templateBuilder.smallest();
templateBuilder.options(userMetadata(tags));
return templateBuilder.build();
}
开发者ID:hazelcast,项目名称:hazelcast-jclouds,代码行数:8,代码来源:LiveComputeServiceUtil.java
示例14: createNode
import org.jclouds.compute.domain.Template; //导入依赖的package包/类
public NodeMetadata createNode(String groupName, Template template) throws Exception {
NodeMetadata node = getOnlyElement(computeService.createNodesInGroup(groupName, 1, template));
LOGGER.info(MessageFormat.format("<< node created {0}: {1}", node.getId(),
concat(node.getPrivateAddresses(), node.getPublicAddresses())));
nodes.add(node);
return node;
}
开发者ID:hazelcast,项目名称:hazelcast-jclouds,代码行数:8,代码来源:LiveComputeServiceUtil.java
示例15: createNode
import org.jclouds.compute.domain.Template; //导入依赖的package包/类
@Override
public NodeMetadata createNode(Template template) {
try {
Set<? extends NodeMetadata> nodesInGroup =
this.computeServiceContext.getComputeService()
.createNodesInGroup(cloud.configuration().nodeGroup(), 1, template);
checkElementIndex(0, nodesInGroup.size());
checkState(nodesInGroup.size() == 1);
return nodesInGroup.iterator().next();
} catch (RunNodesException e) {
throw new RuntimeException(e);
}
}
开发者ID:cloudiator,项目名称:sword,代码行数:14,代码来源:JCloudsComputeClientImpl.java
示例16: apply
import org.jclouds.compute.domain.Template; //导入依赖的package包/类
@Override
public final VirtualMachine apply(final VirtualMachineTemplate virtualMachineTemplate) {
final VirtualMachineTemplate virtualMachineTemplateToUse =
modifyVirtualMachineTemplate(virtualMachineTemplate);
final TemplateBuilder templateBuilder = jCloudsComputeClient.templateBuilder();
templateBuilder.hardwareId(virtualMachineTemplateToUse.hardwareFlavorId())
.imageId(virtualMachineTemplateToUse.imageId())
.locationId(virtualMachineTemplateToUse.locationId());
final org.jclouds.compute.options.TemplateOptions jcloudsTemplateOptions;
if (virtualMachineTemplate.templateOptions().isPresent()) {
//convert the template options
jcloudsTemplateOptions =
templateOptionsConverter.apply(virtualMachineTemplateToUse.templateOptions().get());
} else {
//create a template options object for setting the name
jcloudsTemplateOptions = this.newTemplateOptions();
templateBuilder.options(jcloudsTemplateOptions);
}
//set the name
jcloudsTemplateOptions.nodeNames(Collections
.singleton(namingStrategy.generateUniqueNameBasedOnName(virtualMachineTemplate.name())));
//call extension point
templateBuilder
.options(modifyTemplateOptions(virtualMachineTemplate, jcloudsTemplateOptions));
final Template template = templateBuilder.build();
return this.computeMetadataVirtualMachineConverter
.apply(this.jCloudsComputeClient.createNode(template));
}
开发者ID:cloudiator,项目名称:sword,代码行数:39,代码来源:JCloudsCreateVirtualMachineStrategy.java
示例17: launchVPCSpotInstanceSubnetId
import org.jclouds.compute.domain.Template; //导入依赖的package包/类
public void launchVPCSpotInstanceSubnetId() throws Exception {
enqueueRegions(DEFAULT_REGION);
enqueueXml(DEFAULT_REGION, "/availabilityZones.xml");
enqueueXml(DEFAULT_REGION, "/describe_images.xml");
enqueueXml(DEFAULT_REGION, "/describe_images_cc.xml");
enqueueXml(DEFAULT_REGION, "/request_spot_instances-ebs.xml");
enqueueXml(DEFAULT_REGION, "/request_spot_instances-ebs.xml");
enqueueXml(DEFAULT_REGION, "/describe_images_ebs.xml");
enqueue(DEFAULT_REGION, new MockResponse()); // create tags
ComputeService computeService = computeService();
Template template = computeService.templateBuilder().locationId("us-east-1a").build();
template.getOptions().as(AWSEC2TemplateOptions.class)
.spotPrice(1f).subnetId("subnet-xyz").keyPair("Demo").blockUntilRunning(false);
NodeMetadata node = Iterables.getOnlyElement(computeService.createNodesInGroup("test", 1, template));
assertEquals(node.getId(), "us-east-1/sir-228e6406");
assertPosted(DEFAULT_REGION, "Action=DescribeRegions");
assertPosted(DEFAULT_REGION, "Action=DescribeAvailabilityZones");
assertPosted(DEFAULT_REGION, "Action=DescribeImages&Filter.1.Name=owner-id&Filter.1.Value.1=137112412989&Filter.1.Value.2=801119661308&Filter.1.Value.3=063491364108&Filter.1.Value.4=099720109477&Filter.1.Value.5=411009282317&Filter.2.Name=state&Filter.2.Value.1=available&Filter.3.Name=image-type&Filter.3.Value.1=machine");
assertPosted(DEFAULT_REGION, "Action=DescribeImages&Filter.1.Name=virtualization-type&Filter.1.Value.1=hvm&Filter.2.Name=architecture&Filter.2.Value.1=x86_64&Filter.3.Name=owner-id&Filter.3.Value.1=137112412989&Filter.3.Value.2=099720109477&Filter.4.Name=hypervisor&Filter.4.Value.1=xen&Filter.5.Name=state&Filter.5.Value.1=available&Filter.6.Name=image-type&Filter.6.Value.1=machine&Filter.7.Name=root-device-type&Filter.7.Value.1=ebs");
assertPosted(DEFAULT_REGION, "Action=RequestSpotInstances&SpotPrice=1.0&InstanceCount=1&LaunchSpecification.ImageId=ami-" + getDefaultImageId() + "&LaunchSpecification.Placement.AvailabilityZone=us-east-1a&LaunchSpecification.InstanceType=" + getDefaultSmallestInstanceType() + "&LaunchSpecification.SubnetId=subnet-xyz&LaunchSpecification.KeyName=Demo&LaunchSpecification.UserData=I2Nsb3VkLWNvbmZpZwpyZXBvX3VwZ3JhZGU6IG5vbmUK");
assertPosted(DEFAULT_REGION, "Action=DescribeSpotInstanceRequests&SpotInstanceRequestId.1=sir-228e6406");
assertPosted(DEFAULT_REGION, "Action=DescribeImages&ImageId.1=ami-595a0a1c");
assertPosted(DEFAULT_REGION, "Action=CreateTags&Tag.1.Key=Name&Tag.1.Value=test-228e6406&ResourceId.1=sir-228e6406");
}
开发者ID:apache,项目名称:stratos,代码行数:30,代码来源:AWSEC2ComputeServiceApiMockTest.java
示例18: launchSpotInstanceIAMInstanceProfileArn
import org.jclouds.compute.domain.Template; //导入依赖的package包/类
public void launchSpotInstanceIAMInstanceProfileArn() throws Exception {
enqueueRegions(DEFAULT_REGION);
enqueueXml(DEFAULT_REGION, "/availabilityZones.xml");
enqueueXml(DEFAULT_REGION, "/describe_images.xml");
enqueueXml(DEFAULT_REGION, "/describe_images_cc.xml");
enqueueXml(DEFAULT_REGION, "/created_securitygroup.xml");
enqueueXml(DEFAULT_REGION, "/new_securitygroup.xml");
enqueueXml(DEFAULT_REGION, "/new_securitygroup.xml");
enqueueXml(DEFAULT_REGION, "/new_securitygroup.xml");
enqueueXml(DEFAULT_REGION, "/authorize_securitygroup_ingress_response.xml");
enqueueXml(DEFAULT_REGION, "/request_spot_instances-ebs.xml");
enqueueXml(DEFAULT_REGION, "/request_spot_instances-ebs.xml");
enqueueXml(DEFAULT_REGION, "/describe_images_ebs.xml");
enqueue(DEFAULT_REGION, new MockResponse()); // create tags
ComputeService computeService = computeService();
Template template = computeService.templateBuilder().locationId("us-east-1a").build();
template.getOptions().as(AWSEC2TemplateOptions.class).spotPrice(1f).iamInstanceProfileArn(iamInstanceProfileArn)
.noKeyPair().blockUntilRunning(false);
NodeMetadata node = Iterables.getOnlyElement(computeService.createNodesInGroup("test", 1, template));
assertEquals(node.getId(), "us-east-1/sir-228e6406");
assertPosted(DEFAULT_REGION, "Action=DescribeRegions");
assertPosted(DEFAULT_REGION, "Action=DescribeAvailabilityZones");
assertPosted(DEFAULT_REGION, "Action=DescribeImages&Filter.1.Name=owner-id&Filter.1.Value.1=137112412989&Filter.1.Value.2=801119661308&Filter.1.Value.3=063491364108&Filter.1.Value.4=099720109477&Filter.1.Value.5=411009282317&Filter.2.Name=state&Filter.2.Value.1=available&Filter.3.Name=image-type&Filter.3.Value.1=machine");
assertPosted(DEFAULT_REGION, "Action=DescribeImages&Filter.1.Name=virtualization-type&Filter.1.Value.1=hvm&Filter.2.Name=architecture&Filter.2.Value.1=x86_64&Filter.3.Name=owner-id&Filter.3.Value.1=137112412989&Filter.3.Value.2=099720109477&Filter.4.Name=hypervisor&Filter.4.Value.1=xen&Filter.5.Name=state&Filter.5.Value.1=available&Filter.6.Name=image-type&Filter.6.Value.1=machine&Filter.7.Name=root-device-type&Filter.7.Value.1=ebs");
assertPosted(DEFAULT_REGION, "Action=CreateSecurityGroup&GroupName=jclouds%23test&GroupDescription=jclouds%23test");
assertPosted(DEFAULT_REGION, "Action=DescribeSecurityGroups&GroupName.1=jclouds%23test");
assertPosted(DEFAULT_REGION, "Action=DescribeSecurityGroups&GroupName.1=jclouds%23test");
assertPosted(DEFAULT_REGION, "Action=DescribeSecurityGroups&GroupName.1=jclouds%23test");
assertPosted(DEFAULT_REGION, "Action=AuthorizeSecurityGroupIngress&GroupId=sg-3c6ef654&IpPermissions.0.IpProtocol=tcp&IpPermissions.0.FromPort=22&IpPermissions.0.ToPort=22&IpPermissions.0.IpRanges.0.CidrIp=0.0.0.0/0&IpPermissions.1.IpProtocol=tcp&IpPermissions.1.FromPort=0&IpPermissions.1.ToPort=65535&IpPermissions.1.Groups.0.UserId=993194456877&IpPermissions.1.Groups.0.GroupId=sg-3c6ef654&IpPermissions.2.IpProtocol=udp&IpPermissions.2.FromPort=0&IpPermissions.2.ToPort=65535&IpPermissions.2.Groups.0.UserId=993194456877&IpPermissions.2.Groups.0.GroupId=sg-3c6ef654");
assertPosted(DEFAULT_REGION, "Action=RequestSpotInstances&SpotPrice=1.0&InstanceCount=1&LaunchSpecification.ImageId=ami-" + getDefaultImageId() + "&LaunchSpecification.Placement.AvailabilityZone=us-east-1a&LaunchSpecification.SecurityGroup.1=jclouds%23test&LaunchSpecification.InstanceType=" + getDefaultSmallestInstanceType() + "&LaunchSpecification.UserData=I2Nsb3VkLWNvbmZpZwpyZXBvX3VwZ3JhZGU6IG5vbmUK&LaunchSpecification.IamInstanceProfile.Arn=arn%3Aaws%3Aiam%3A%3A123456789012%3Ainstance-profile/application_abc/component_xyz/Webserver");
assertPosted(DEFAULT_REGION, "Action=DescribeSpotInstanceRequests&SpotInstanceRequestId.1=sir-228e6406");
assertPosted(DEFAULT_REGION, "Action=DescribeImages&ImageId.1=ami-595a0a1c");
assertPosted(DEFAULT_REGION, "Action=CreateTags&Tag.1.Key=Name&Tag.1.Value=test-228e6406&ResourceId.1=sir-228e6406");
}
开发者ID:apache,项目名称:stratos,代码行数:40,代码来源:AWSEC2ComputeServiceApiMockTest.java
示例19: launchSpotInstanceIAMInstanceProfileName
import org.jclouds.compute.domain.Template; //导入依赖的package包/类
public void launchSpotInstanceIAMInstanceProfileName() throws Exception {
enqueueRegions(DEFAULT_REGION);
enqueueXml(DEFAULT_REGION, "/availabilityZones.xml");
enqueueXml(DEFAULT_REGION, "/describe_images.xml");
enqueueXml(DEFAULT_REGION, "/describe_images_cc.xml");
enqueueXml(DEFAULT_REGION, "/created_securitygroup.xml");
enqueueXml(DEFAULT_REGION, "/new_securitygroup.xml");
enqueueXml(DEFAULT_REGION, "/new_securitygroup.xml");
enqueueXml(DEFAULT_REGION, "/new_securitygroup.xml");
enqueueXml(DEFAULT_REGION, "/authorize_securitygroup_ingress_response.xml");
enqueueXml(DEFAULT_REGION, "/request_spot_instances-ebs.xml");
enqueueXml(DEFAULT_REGION, "/request_spot_instances-ebs.xml");
enqueueXml(DEFAULT_REGION, "/describe_images_ebs.xml");
enqueue(DEFAULT_REGION, new MockResponse()); // create tags
ComputeService computeService = computeService();
Template template = computeService.templateBuilder().locationId("us-east-1a").build();
template.getOptions().as(AWSEC2TemplateOptions.class).spotPrice(1f).iamInstanceProfileName("Webserver")
.noKeyPair().blockUntilRunning(false);
NodeMetadata node = Iterables.getOnlyElement(computeService.createNodesInGroup("test", 1, template));
assertEquals(node.getId(), "us-east-1/sir-228e6406");
assertPosted(DEFAULT_REGION, "Action=DescribeRegions");
assertPosted(DEFAULT_REGION, "Action=DescribeAvailabilityZones");
assertPosted(DEFAULT_REGION, "Action=DescribeImages&Filter.1.Name=owner-id&Filter.1.Value.1=137112412989&Filter.1.Value.2=801119661308&Filter.1.Value.3=063491364108&Filter.1.Value.4=099720109477&Filter.1.Value.5=411009282317&Filter.2.Name=state&Filter.2.Value.1=available&Filter.3.Name=image-type&Filter.3.Value.1=machine");
assertPosted(DEFAULT_REGION, "Action=DescribeImages&Filter.1.Name=virtualization-type&Filter.1.Value.1=hvm&Filter.2.Name=architecture&Filter.2.Value.1=x86_64&Filter.3.Name=owner-id&Filter.3.Value.1=137112412989&Filter.3.Value.2=099720109477&Filter.4.Name=hypervisor&Filter.4.Value.1=xen&Filter.5.Name=state&Filter.5.Value.1=available&Filter.6.Name=image-type&Filter.6.Value.1=machine&Filter.7.Name=root-device-type&Filter.7.Value.1=ebs");
assertPosted(DEFAULT_REGION, "Action=CreateSecurityGroup&GroupName=jclouds%23test&GroupDescription=jclouds%23test");
assertPosted(DEFAULT_REGION, "Action=DescribeSecurityGroups&GroupName.1=jclouds%23test");
assertPosted(DEFAULT_REGION, "Action=DescribeSecurityGroups&GroupName.1=jclouds%23test");
assertPosted(DEFAULT_REGION, "Action=DescribeSecurityGroups&GroupName.1=jclouds%23test");
assertPosted(DEFAULT_REGION, "Action=AuthorizeSecurityGroupIngress&GroupId=sg-3c6ef654&IpPermissions.0.IpProtocol=tcp&IpPermissions.0.FromPort=22&IpPermissions.0.ToPort=22&IpPermissions.0.IpRanges.0.CidrIp=0.0.0.0/0&IpPermissions.1.IpProtocol=tcp&IpPermissions.1.FromPort=0&IpPermissions.1.ToPort=65535&IpPermissions.1.Groups.0.UserId=993194456877&IpPermissions.1.Groups.0.GroupId=sg-3c6ef654&IpPermissions.2.IpProtocol=udp&IpPermissions.2.FromPort=0&IpPermissions.2.ToPort=65535&IpPermissions.2.Groups.0.UserId=993194456877&IpPermissions.2.Groups.0.GroupId=sg-3c6ef654");
assertPosted(DEFAULT_REGION, "Action=RequestSpotInstances&SpotPrice=1.0&InstanceCount=1&LaunchSpecification.ImageId=ami-" + getDefaultImageId() + "&LaunchSpecification.Placement.AvailabilityZone=us-east-1a&LaunchSpecification.SecurityGroup.1=jclouds%23test&LaunchSpecification.InstanceType=" + getDefaultSmallestInstanceType() + "&LaunchSpecification.UserData=I2Nsb3VkLWNvbmZpZwpyZXBvX3VwZ3JhZGU6IG5vbmUK&LaunchSpecification.IamInstanceProfile.Name=Webserver");
assertPosted(DEFAULT_REGION, "Action=DescribeSpotInstanceRequests&SpotInstanceRequestId.1=sir-228e6406");
assertPosted(DEFAULT_REGION, "Action=DescribeImages&ImageId.1=ami-595a0a1c");
assertPosted(DEFAULT_REGION, "Action=CreateTags&Tag.1.Key=Name&Tag.1.Value=test-228e6406&ResourceId.1=sir-228e6406");
}
开发者ID:apache,项目名称:stratos,代码行数:40,代码来源:AWSEC2ComputeServiceApiMockTest.java
示例20: buildTemplate
import org.jclouds.compute.domain.Template; //导入依赖的package包/类
@Override
public void buildTemplate() {
IaasProvider iaasProvider = getIaasProvider();
ComputeService computeService = iaasProvider.getComputeService();
Set<? extends Image> images = computeService.listImages();
Image image = findImage(images, iaasProvider.getImage());
if (image == null) {
throw new CloudControllerException(String.format("Docker image not found: %s", iaasProvider.getImage()));
}
Template template = computeService.templateBuilder().fromImage(image).build();
iaasProvider.setTemplate(template);
}
开发者ID:apache,项目名称:stratos,代码行数:13,代码来源:DockerIaas.java
注:本文中的org.jclouds.compute.domain.Template类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论