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

Java Placement类代码示例

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

本文整理汇总了Java中com.amazonaws.services.ec2.model.Placement的典型用法代码示例。如果您正苦于以下问题:Java Placement类的具体用法?Java Placement怎么用?Java Placement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Placement类属于com.amazonaws.services.ec2.model包,在下文中一共展示了Placement类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testGetComputeDescriptionKeyFromAWSInstance

import com.amazonaws.services.ec2.model.Placement; //导入依赖的package包/类
@Test
public void testGetComputeDescriptionKeyFromAWSInstance() throws Throwable {
    Map<String, ZoneData> zones = new HashMap<>();
    zones.put(AWS_ZONE_ID, ZoneData.build(AWS_REGION_ID, AWS_ZONE_ID, ""));

    Instance awsInstance = new Instance();
    awsInstance.setInstanceId(AWS_INSTANCE_ID);
    Placement placement = new Placement();
    placement.setAvailabilityZone(AWS_ZONE_ID);
    awsInstance.setPlacement(placement);
    String regionId = getRegionId(awsInstance);
    awsInstance.setInstanceType(AWS_INSTANCE_TYPE);
    awsInstance.setVpcId(AWS_VPC_ID);
    assertEquals(AWS_REGION_ID, regionId);
    InstanceDescKey computeDescriptionKey = getKeyForComputeDescriptionFromInstance(awsInstance,
            zones);
    assertEquals(AWS_COMPUTE_DESCRIPTION_KEY, computeDescriptionKey);
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:19,代码来源:TestAWSEnumerationUtils.java


示例2: convertCompleteInstance

import com.amazonaws.services.ec2.model.Placement; //导入依赖的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)));
}
 
开发者ID:elastisys,项目名称:scale.cloudpool,代码行数:26,代码来源:TestInstanceToMachine.java


示例3: convertInstanceMissingPublicIp

import com.amazonaws.services.ec2.model.Placement; //导入依赖的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)));
}
 
开发者ID:elastisys,项目名称:scale.cloudpool,代码行数:25,代码来源:TestInstanceToMachine.java


示例4: convertInstanceMissingPrivateIp

import com.amazonaws.services.ec2.model.Placement; //导入依赖的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)));
}
 
开发者ID:elastisys,项目名称:scale.cloudpool,代码行数:24,代码来源:TestInstanceToMachine.java


示例5: convertSpotInstance

import com.amazonaws.services.ec2.model.Placement; //导入依赖的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));
}
 
开发者ID:elastisys,项目名称:scale.cloudpool,代码行数:22,代码来源:TestInstanceToMachine.java


示例6: createPlacementGroupsIfDoNotExist

import com.amazonaws.services.ec2.model.Placement; //导入依赖的package包/类
public void createPlacementGroupsIfDoNotExist(org.excalibur.core.cloud.api.Placement... groups)
{
    if (groups != null)
    {
        ListeningExecutorService executor = newListeningDynamicScalingThreadPool(String.format("create-groups-%s", credentials_
                .getRegion().getName()));
        
        List<Callable<Void>> tasks = newArrayList();

        for (final org.excalibur.core.cloud.api.Placement placement : groups)
        {
            tasks.add(new Callable<Void>()
            {
                @Override
                public Void call() throws Exception
                {
                    if (placement != null && !isNullOrEmpty(placement.getGroupName()))
                    {
                        try
                        {
                            new AmazonEC2Client(awsCredentials_).describePlacementGroups(new DescribePlacementGroupsRequest().withGroupNames(placement.getGroupName()));
                        }
                        catch (AmazonClientException exception)
                        {
                            LOG.debug("The group {} is unknown! Provider message: {}", placement.getGroupName(), exception.getMessage());
                            ec2_.createPlacementGroup(new CreatePlacementGroupRequest()
                                .withGroupName(placement.getGroupName()).withStrategy(PlacementStrategy.Cluster));
                        }
                    }
                    return null;
                }
            });
        }
        
        invokeAllAndShutdownWhenFinish(tasks, executor);
    }
}
 
开发者ID:alessandroleite,项目名称:dohko,代码行数:38,代码来源:EC2.java


示例7: convertWithServiceStateTag

import com.amazonaws.services.ec2.model.Placement; //导入依赖的package包/类
@Test
public void convertWithServiceStateTag() {
    Tag serviceStateTag = new Tag().withKey(ScalingTags.SERVICE_STATE_TAG)
            .withValue(ServiceState.OUT_OF_SERVICE.name());
    Instance instance = new Instance().withInstanceId("i-1").withInstanceType(InstanceType.M1Medium)
            .withState(new InstanceState().withName(InstanceStateName.Running))
            .withPlacement(new Placement("us-east-1b")).withTags(serviceStateTag);

    Machine machine = convert(instance);
    assertThat(machine.getServiceState(), is(ServiceState.OUT_OF_SERVICE));
}
 
开发者ID:elastisys,项目名称:scale.cloudpool,代码行数:12,代码来源:TestInstanceToMachine.java


示例8: convertWithMembershipStatusTag

import com.amazonaws.services.ec2.model.Placement; //导入依赖的package包/类
@Test
public void convertWithMembershipStatusTag() {
    MembershipStatus status = MembershipStatus.awaitingService();
    String statusJsonString = JsonUtils.toString(JsonUtils.toJson(status));
    Tag membershipStatusTag = new Tag().withKey(ScalingTags.MEMBERSHIP_STATUS_TAG).withValue(statusJsonString);
    Instance instance = new Instance().withInstanceId("i-1").withInstanceType(InstanceType.M1Medium)
            .withState(new InstanceState().withName(InstanceStateName.Running))
            .withPlacement(new Placement("us-east-1b")).withTags(membershipStatusTag);

    Machine machine = convert(instance);
    assertThat(machine.getMembershipStatus(), is(status));
}
 
开发者ID:elastisys,项目名称:scale.cloudpool,代码行数:13,代码来源:TestInstanceToMachine.java


示例9: prepareEC2RequestNode

import com.amazonaws.services.ec2.model.Placement; //导入依赖的package包/类
/**
 * Prepares the request.
 * @param targetProperties the target properties
 * @param userData the user data to pass
 * @return a request
 * @throws UnsupportedEncodingException
 */
private RunInstancesRequest prepareEC2RequestNode( Map<String,String> targetProperties, String userData )
throws UnsupportedEncodingException {

	RunInstancesRequest runInstancesRequest = new RunInstancesRequest();
	String flavor = targetProperties.get(Ec2Constants.VM_INSTANCE_TYPE);
	if( Utils.isEmptyOrWhitespaces( flavor ))
		flavor = "t1.micro";

	runInstancesRequest.setInstanceType( flavor );
	runInstancesRequest.setImageId( targetProperties.get( Ec2Constants.AMI_VM_NODE ));

	runInstancesRequest.setMinCount( 1 );
	runInstancesRequest.setMaxCount( 1 );
	runInstancesRequest.setKeyName( targetProperties.get(Ec2Constants.SSH_KEY_NAME));

	String secGroup = targetProperties.get(Ec2Constants.SECURITY_GROUP_NAME);
	if( Utils.isEmptyOrWhitespaces(secGroup))
		secGroup = "default";

	runInstancesRequest.setSecurityGroups(Collections.singletonList(secGroup));

	String availabilityZone = targetProperties.get(Ec2Constants.AVAILABILITY_ZONE);
	if(! Utils.isEmptyOrWhitespaces(availabilityZone))
		runInstancesRequest.setPlacement(new Placement(availabilityZone));

	// The following part enables to transmit data to the VM.
	// When the VM is up, it will be able to read this data.
	String encodedUserData = new String( Base64.encodeBase64( userData.getBytes( StandardCharsets.UTF_8 )), "UTF-8" );
	runInstancesRequest.setUserData( encodedUserData );

	return runInstancesRequest;
}
 
开发者ID:roboconf,项目名称:roboconf-platform,代码行数:40,代码来源:Ec2IaasHandler.java


示例10: createAndRunInstance

import com.amazonaws.services.ec2.model.Placement; //导入依赖的package包/类
private void createAndRunInstance(AmazonEC2Client ec2Client, Exchange exchange) {
    String ami;
    InstanceType instanceType;
    int minCount;
    int maxCount;
    boolean monitoring;
    String kernelId;
    boolean ebsOptimized;
    Collection securityGroups;
    String keyName;
    String clientToken;
    Placement placement;
    RunInstancesRequest request = new RunInstancesRequest();
    if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(EC2Constants.IMAGE_ID))) {
        ami = exchange.getIn().getHeader(EC2Constants.IMAGE_ID, String.class);
        request.withImageId(ami);
    } else {
        throw new IllegalArgumentException("AMI must be specified");
    }
    if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(EC2Constants.INSTANCE_TYPE))) {
        instanceType = exchange.getIn().getHeader(EC2Constants.INSTANCE_TYPE, InstanceType.class);
        request.withInstanceType(instanceType.toString());
    } else {
        throw new IllegalArgumentException("Instance Type must be specified");
    }
    if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(EC2Constants.INSTANCE_MIN_COUNT))) {
        minCount = exchange.getIn().getHeader(EC2Constants.INSTANCE_MIN_COUNT, Integer.class);
        request.withMinCount(minCount);
    } else {
        throw new IllegalArgumentException("Min instances count must be specified");
    }
    if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(EC2Constants.INSTANCE_MAX_COUNT))) {
        maxCount = exchange.getIn().getHeader(EC2Constants.INSTANCE_MAX_COUNT, Integer.class);
        request.withMaxCount(maxCount);
    } else {
        throw new IllegalArgumentException("Max instances count must be specified");
    }
    if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(EC2Constants.INSTANCE_MONITORING))) {
        monitoring = exchange.getIn().getHeader(EC2Constants.INSTANCE_MONITORING, Boolean.class);
        request.withMonitoring(monitoring);
    }
    if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(EC2Constants.INSTANCE_KERNEL_ID))) {
        kernelId = exchange.getIn().getHeader(EC2Constants.INSTANCE_KERNEL_ID, String.class);
        request.withKernelId(kernelId);
    }       
    if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(EC2Constants.INSTANCE_EBS_OPTIMIZED))) {
        ebsOptimized = exchange.getIn().getHeader(EC2Constants.INSTANCE_EBS_OPTIMIZED, Boolean.class);
        request.withEbsOptimized(ebsOptimized);
    }
    if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(EC2Constants.INSTANCE_SECURITY_GROUPS))) {
        securityGroups = exchange.getIn().getHeader(EC2Constants.INSTANCE_SECURITY_GROUPS, Collection.class);
        request.withSecurityGroups(securityGroups);
    }
    if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(EC2Constants.INSTANCES_KEY_PAIR))) {
        keyName = exchange.getIn().getHeader(EC2Constants.INSTANCES_KEY_PAIR, String.class);
        request.withKeyName(keyName);
    }
    if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(EC2Constants.INSTANCES_CLIENT_TOKEN))) {
        clientToken = exchange.getIn().getHeader(EC2Constants.INSTANCES_CLIENT_TOKEN, String.class);
        request.withClientToken(clientToken);
    }
    if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(EC2Constants.INSTANCES_PLACEMENT))) {
        placement = exchange.getIn().getHeader(EC2Constants.INSTANCES_PLACEMENT, Placement.class);
        request.withPlacement(placement);
    }
    RunInstancesResult result;
    try {
        result = ec2Client.runInstances(request);
    } catch (AmazonServiceException ase) {
        LOG.trace("Run Instances command returned the error code {}", ase.getErrorCode());
        throw ase;
    }
    LOG.trace("Creating and running instances with ami [{}] and instance type {}", ami, instanceType.toString());
    Message message = getMessageForResponse(exchange);
    message.setBody(result);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:77,代码来源:EC2Producer.java


示例11: newRunInstancesRequest

import com.amazonaws.services.ec2.model.Placement; //导入依赖的package包/类
/**
 * Builds a {@code RunInstancesRequest} starting from a template and a virtual instance ID.
 * Instances will be tagged as they're created.
 *
 * @param template          the instance template
 * @param virtualInstanceId the virtual instance IDs
 * @param userDefinedTags   user defined tags to attach to the instance
 */
@SuppressWarnings("ConstantConditions")
private RunInstancesRequest newRunInstancesRequest(EC2InstanceTemplate template,
    String virtualInstanceId, List<Tag> userDefinedTags) {

  String image = template.getImage();
  String type = template.getType();

  InstanceNetworkInterfaceSpecification network =
      getInstanceNetworkInterfaceSpecification(template);

  List<BlockDeviceMapping> deviceMappings = getBlockDeviceMappings(template);

  LOG.info(">> Instance request type: {}, image: {}", type, image);

  List<Tag> tags = ec2TagHelper.getInstanceTags(template, virtualInstanceId, userDefinedTags);
  List<TagSpecification> tagSpecifications = Lists.newArrayList(
      new TagSpecification().withTags(tags).withResourceType(ResourceType.Instance),
      new TagSpecification().withTags(tags).withResourceType(ResourceType.Volume));

  RunInstancesRequest request = new RunInstancesRequest()
      .withImageId(image)
      .withInstanceType(type)
      .withMaxCount(1)
      .withMinCount(1)
      .withClientToken(UUID.randomUUID().toString())
      .withNetworkInterfaces(network)
      .withTagSpecifications(tagSpecifications)
      .withBlockDeviceMappings(deviceMappings)
      .withEbsOptimized(template.isEbsOptimized());

  if (template.getIamProfileName().isPresent()) {
    request.withIamInstanceProfile(new IamInstanceProfileSpecification()
        .withName(template.getIamProfileName().get()));
  }

  if (template.getKeyName().isPresent()) {
    request.withKeyName(template.getKeyName().get());
  }

  Placement placement = null;
  if (template.getAvailabilityZone().isPresent()) {
    placement = new Placement().withAvailabilityZone(template.getAvailabilityZone().get());
  }
  if (template.getPlacementGroup().isPresent()) {
    placement = (placement == null) ?
        new Placement().withGroupName(template.getPlacementGroup().get())
        : placement.withGroupName(template.getPlacementGroup().get());
  }
  placement = (placement == null) ?
      new Placement().withTenancy(template.getTenancy())
      : placement.withTenancy(template.getTenancy());

  request.withPlacement(placement);

  Optional<String> userData = template.getUserData();
  if (userData.isPresent()) {
    request.withUserData(userData.get());
  }

  return request;
}
 
开发者ID:cloudera,项目名称:director-aws-plugin,代码行数:70,代码来源:EC2Provider.java


示例12: createPlacementGroups

import com.amazonaws.services.ec2.model.Placement; //导入依赖的package包/类
public void createPlacementGroups(org.excalibur.core.cloud.api.Placement... groups)
{
    createPlacementGroupsIfDoNotExist(groups);
}
 
开发者ID:alessandroleite,项目名称:dohko,代码行数:5,代码来源:EC2.java


示例13: toExcaliburInstance

import com.amazonaws.services.ec2.model.Placement; //导入依赖的package包/类
private VirtualMachine toExcaliburInstance(Instance instance, KeyPair keyPair)
    {
        Map<String, Tag> tags = TAGS.apply(instance.getTags());

        VirtualMachine vm = new VirtualMachine()
                .setName(instance.getInstanceId())
                .setImageId(instance.getImageId())
                .setType(InstanceType.valueOf(instance.getInstanceType()).setProvider(this.credentials_.getProvider()))
                .setState(new InstanceStateDetails(InstanceStateType.valueOfFrom(instance.getState().getName()), new Date())) //TODO we need to improve this
                .setConfiguration(
                        new VmConfiguration()
                                .setKeyName(instance.getKeyName())
                                .setKeyPairs(new KeyPairs().setPrivateKey(keyPair))
                                .setPlatform(isNullOrEmpty(instance.getPlatform()) ? DEFAULT_PLATFORM : instance.getPlatform())
                                .setPlatformUserName(tags.get(DEFAULT_PLATFORM_INSTANCE_USERNAME_TAG) != null ? 
                                        tags.get(DEFAULT_PLATFORM_INSTANCE_USERNAME_TAG).getValue() : 
                                        System.getProperty("org.excalibur.default.platform.username"))
                                .setPrivateIpAddress(instance.getPrivateIpAddress()).setPublicIpAddress(instance.getPublicIpAddress())
                                .setPublicDnsName(instance.getPublicDnsName())).setLaunchTime(instance.getLaunchTime())
//                .setLocation(new Region().setName(instance.getPlacement().getAvailabilityZone()))
//                .setLocation(credentials_.getRegion())
                .setLocation(new Zone().setName(instance.getPlacement().getAvailabilityZone()).setRegion(credentials_.getRegion()))                
                .setPlacement(new org.excalibur.core.cloud.api.Placement()
                                .setGroupName(instance.getPlacement().getGroupName())
                                .setZone(instance.getPlacement().getAvailabilityZone()))
                .setOwner(new User(this.credentials_.getUserId()).setUsername(tags.get("username") != null ? tags.get("username").getValue(): null));
        
        if (tags.containsKey("keyname"))
        {
            if (vm.getConfiguration().getKeyPairs().getPrivateKey() == null)
            {
                vm.getConfiguration().getKeyPairs().setPrivateKey(new KeyPair());
            }
            
            vm.getConfiguration().getKeyPairs().getPrivateKey().setKeyName(tags.get("keyname").getValue());
        }
        else
        {
            return null;
        }
        
        InstanceAttribute attribute = new AmazonEC2Client(awsCredentials_).describeInstanceAttribute(
                new DescribeInstanceAttributeRequest().withInstanceId(instance.getInstanceId()).withAttribute("userData")).getInstanceAttribute();
        
//        List<InstanceStatus> instanceStatuses = new AmazonEC2Client(awsCredentials_).describeInstanceStatus(
//                new DescribeInstanceStatusRequest().withInstanceIds(instance.getInstanceId())).getInstanceStatuses();

        if (!isNullOrEmpty(attribute.getUserData()))
        {
            String userData = new String(Base64.decodeBase64(attribute.getUserData().getBytes()));
            int i = userData.indexOf("#start-data"), f = userData.indexOf("#end-data");
            
            if (i > -1 && f > -1)
            {
                String[] keys = userData.substring(i, f).split("#");
                checkState(keys.length == 4);
                
                vm.getConfiguration().getKeyPairs().getPrivateKey().setKeyMaterial(keys[2]);
                vm.getConfiguration().getKeyPairs()
                        .setPublicKey(new KeyPair().setKeyName(tags.get("keyname").getValue()).setKeyMaterial(keys[3].trim()));
            }
            
            vm.setUserData(attribute.getUserData());
        } 
        
        for (Tag tag: tags.values())
        {
            vm.getTags().add(org.excalibur.core.cloud.api.domain.Tag.valueOf(tag.getKey(), tag.getValue()));
        }
        
        return vm;

    }
 
开发者ID:alessandroleite,项目名称:dohko,代码行数:74,代码来源:EC2.java


示例14: convertObject

import com.amazonaws.services.ec2.model.Placement; //导入依赖的package包/类
@Override
protected Instance convertObject(com.xerox.amazonws.ec2.ReservationDescription.Instance from) {
    Instance to = new Instance();

    to.setInstanceId(from.getInstanceId());
    to.setImageId(from.getImageId());

    InstanceState state = new InstanceState();
    state.setCode(from.getStateCode());
    state.setName(from.getState());
    to.setState(state);

    to.setPrivateDnsName(from.getPrivateDnsName());
    to.setPublicDnsName(from.getDnsName());
    to.setStateTransitionReason(from.getReason());
    to.setKeyName(from.getKeyName());
    to.setAmiLaunchIndex(null);
    to.setProductCodes(null);
    to.setInstanceType(from.getInstanceType().name());
    to.setLaunchTime(from.getLaunchTime().getTime());

    Placement placement = new Placement();
    placement.setAvailabilityZone(from.getAvailabilityZone());
    placement.setGroupName(null); // 未実装
    to.setPlacement(placement);

    to.setKernelId(from.getKernelId());
    to.setRamdiskId(from.getRamdiskId());
    to.setPlatform(from.getPlatform());

    Monitoring monitoring = new Monitoring();
    monitoring.setState(Boolean.toString(from.isMonitoring()));
    to.setMonitoring(monitoring);

    // 未実装
    to.setSubnetId(null);
    to.setVpcId(null);
    to.setPrivateIpAddress(null);
    to.setPublicIpAddress(null);
    to.setStateReason(null);
    //to.setArchitecture(null);
    to.setRootDeviceName(null);
    to.setRootDeviceName(null);
    to.setBlockDeviceMappings(null);
    //to.setVirtualizationType(null);
    //to.setInstanceLifecycle(null);
    to.setSpotInstanceRequestId(null);
    //to.setLicense(null);
    to.setClientToken(null);
    to.setTags(null);

    return to;
}
 
开发者ID:primecloud-controller-org,项目名称:primecloud-controller,代码行数:54,代码来源:InstanceConverter.java


示例15: getPlacement

import com.amazonaws.services.ec2.model.Placement; //导入依赖的package包/类
@Override
public Placement getPlacement() {
    return (Placement) resource.getAttribute("Placement");
}
 
开发者ID:awslabs,项目名称:aws-sdk-java-resources,代码行数:5,代码来源:InstanceImpl.java


示例16: getPlacement

import com.amazonaws.services.ec2.model.Placement; //导入依赖的package包/类
/**
 * Gets the value of the Placement attribute. If this resource is not yet
 * loaded, a call to {@code load()} is made to retrieve the value of the
 * attribute.
 */
Placement getPlacement();
 
开发者ID:awslabs,项目名称:aws-sdk-java-resources,代码行数:7,代码来源:Instance.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java VCFHeaderLineCount类代码示例发布时间:2022-05-22
下一篇:
Java CacheProvider类代码示例发布时间: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