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

Java DescribeInstanceAttributeRequest类代码示例

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

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



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

示例1: getInstanceAttribute

import com.amazonaws.services.ec2.model.DescribeInstanceAttributeRequest; //导入依赖的package包/类
@Override
public InstanceAttribute getInstanceAttribute(String instanceId, String attributeName) {
  OperationStats ops = new OperationStats("es2InstanceStore", "getInstanceAttribute");
  try {
    awsRateLimiter.acquire();
    DescribeInstanceAttributeRequest request = new DescribeInstanceAttributeRequest()
        .withInstanceId(instanceId)
        .withAttribute(InstanceAttributeName.fromValue(attributeName))
        .withSdkRequestTimeout(300 * 1000).withSdkClientExecutionTimeout(600 * 1000);

    DescribeInstanceAttributeResult result = defaultClient.describeInstanceAttribute(request);
    while (result != null) {
      ops.succeed();
      return result.getInstanceAttribute();
    }
  } catch (Exception ex) {
    ops.failed();
    throw ex;
  }
  return null;
}
 
开发者ID:pinterest,项目名称:soundwave,代码行数:22,代码来源:Ec2InstanceStore.java


示例2: describeInstanceAttribute

import com.amazonaws.services.ec2.model.DescribeInstanceAttributeRequest; //导入依赖的package包/类
/**
 * Retrieves an instance attribute.
 *
 * @param  instanceId instance ID
 * @param  attribute  name of attribute to describe
 * @return            attribute
 */
@VisibleForTesting
InstanceAttribute describeInstanceAttribute(String instanceId, InstanceAttributeName attribute) {
  DescribeInstanceAttributeRequest request = new DescribeInstanceAttributeRequest()
      .withInstanceId(instanceId)
      .withAttribute(attribute);

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


示例3: addSecurityGroupsToEc2Instance

import com.amazonaws.services.ec2.model.DescribeInstanceAttributeRequest; //导入依赖的package包/类
/**
 * Adds the security groups to an EC2 instance.
 *
 * @param ec2InstanceId the ec2 instance id.
 * @param securityGroups security groups to be added.
 * @param awsParams awsParamsDto object
 *
 * @return updated security groups.
 */
@Override
public List<String> addSecurityGroupsToEc2Instance(String ec2InstanceId, List<String> securityGroups, AwsParamsDto awsParams)
{
    Set<String> updatedSecurityGroups = new HashSet<>();
    for (String securityGroup : securityGroups)
    {
        updatedSecurityGroups.add(securityGroup);
    }

    // Get existing security groups
    DescribeInstanceAttributeRequest describeInstanceAttributeRequest =
        new DescribeInstanceAttributeRequest().withInstanceId(ec2InstanceId).withAttribute(InstanceAttributeName.GroupSet);

    DescribeInstanceAttributeResult describeInstanceAttributeResult =
        ec2Operations.describeInstanceAttribute(getEc2Client(awsParams), describeInstanceAttributeRequest);

    List<GroupIdentifier> groups = describeInstanceAttributeResult.getInstanceAttribute().getGroups();
    for (GroupIdentifier groupIdentifier : groups)
    {
        updatedSecurityGroups.add(groupIdentifier.getGroupId());
    }

    // Add security group on master EC2 instance
    ModifyInstanceAttributeRequest modifyInstanceAttributeRequest =
        new ModifyInstanceAttributeRequest().withInstanceId(ec2InstanceId).withGroups(updatedSecurityGroups);

    ec2Operations.modifyInstanceAttribute(getEc2Client(awsParams), modifyInstanceAttributeRequest);

    return new ArrayList<>(updatedSecurityGroups);
}
 
开发者ID:FINRAOS,项目名称:herd,代码行数:40,代码来源:Ec2DaoImpl.java


示例4: describeInstanceAttribute

import com.amazonaws.services.ec2.model.DescribeInstanceAttributeRequest; //导入依赖的package包/类
/**
 * Describe the EC2 instance attribute
 */
@Override
public DescribeInstanceAttributeResult describeInstanceAttribute(AmazonEC2Client ec2Client,
    DescribeInstanceAttributeRequest describeInstanceAttributeRequest)
{
    return ec2Client.describeInstanceAttribute(describeInstanceAttributeRequest);
}
 
开发者ID:FINRAOS,项目名称:herd,代码行数:10,代码来源:Ec2OperationsImpl.java


示例5: describeInstanceAttribute

import com.amazonaws.services.ec2.model.DescribeInstanceAttributeRequest; //导入依赖的package包/类
@Override
public DescribeInstanceAttributeResult describeInstanceAttribute(AmazonEC2Client ec2Client,
    DescribeInstanceAttributeRequest describeInstanceAttributeRequest)
{
    InstanceAttribute instanceAttribute = new InstanceAttribute();
    instanceAttribute.withGroups(new GroupIdentifier().withGroupId("A_TEST_SECURITY_GROUP"));
    return new DescribeInstanceAttributeResult().withInstanceAttribute(instanceAttribute);
}
 
开发者ID:FINRAOS,项目名称:herd,代码行数:9,代码来源:MockEc2OperationsImpl.java


示例6: getTaupageYaml

import com.amazonaws.services.ec2.model.DescribeInstanceAttributeRequest; //导入依赖的package包/类
@Override
public Optional<TaupageYaml> getTaupageYaml(final String instanceId, final String account, final String region) {
    final AmazonEC2Client client = clientProvider.getClient(AmazonEC2Client.class,
            account,
            Region.getRegion(Regions.fromName(region)));

    try {
        final DescribeInstanceAttributeResult response = client.describeInstanceAttribute(
                new DescribeInstanceAttributeRequest()
                        .withInstanceId(instanceId)
                        .withAttribute(USER_DATA));


        return ofNullable(response)
                .map(DescribeInstanceAttributeResult::getInstanceAttribute)
                .map(InstanceAttribute::getUserData)
                .map(Base64::decode)
                .map(String::new)
                .map(TaupageYamlUtil::parseTaupageYaml);

    } catch (final AmazonClientException e) {
        log.warn("Could not get Taupage YAML for instance: " + instanceId, e);
        return empty();
    } catch (YAMLException | IllegalArgumentException s) {
        log.warn("Taupage YAML is not valid for instance: " + instanceId, s);
        return empty();
    }
}
 
开发者ID:zalando-stups,项目名称:fullstop,代码行数:29,代码来源:FetchTaupageYamlImpl.java


示例7: getTaupageYaml

import com.amazonaws.services.ec2.model.DescribeInstanceAttributeRequest; //导入依赖的package包/类
private Optional<TaupageYaml> getTaupageYaml(@Nonnull final EC2InstanceContext context) {

        if (context.isTaupageAmi().orElse(false)) {

            final String instanceId = context.getInstanceId();

            try {
                return Optional.of(context.getClient(AmazonEC2Client.class))
                        .map(client -> client.describeInstanceAttribute(new DescribeInstanceAttributeRequest()
                                .withInstanceId(instanceId)
                                .withAttribute(USER_DATA)))
                        .map(DescribeInstanceAttributeResult::getInstanceAttribute)
                        .map(InstanceAttribute::getUserData)
                        .map(Base64::decode)
                        .map(String::new)
                        .map(TaupageYamlUtil::parseTaupageYaml);

            } catch (final AmazonClientException e) {
                log.warn("Could not get Taupage YAML for instance: " + instanceId, e);
                return empty();
            } catch (YAMLException | IllegalArgumentException s)   {
                log.warn("Taupage YAML is not valid for instance: " + instanceId, s);
                return empty();
            }

        } else {
            return empty();
        }

    }
 
开发者ID:zalando-stups,项目名称:fullstop,代码行数:31,代码来源:TaupageYamlProviderImpl.java


示例8: describeAttribute

import com.amazonaws.services.ec2.model.DescribeInstanceAttributeRequest; //导入依赖的package包/类
@Override
public DescribeInstanceAttributeResult describeAttribute(
        DescribeInstanceAttributeRequest request,
        ResultCapture<DescribeInstanceAttributeResult> extractor) {

    ActionResult result = resource.performAction("DescribeAttribute",
            request, extractor);

    if (result == null) return null;
    return (DescribeInstanceAttributeResult) result.getData();
}
 
开发者ID:awslabs,项目名称:aws-sdk-java-resources,代码行数:12,代码来源:InstanceImpl.java


示例9: findTerminationProtection

import com.amazonaws.services.ec2.model.DescribeInstanceAttributeRequest; //导入依赖的package包/类
@Override
public Boolean findTerminationProtection(Account account, Region region, String instanceId) {
    AmazonEC2 ec2 = findClient(account, region);

    DescribeInstanceAttributeRequest req = new DescribeInstanceAttributeRequest();
    req.setAttribute("disableApiTermination");
    req.setInstanceId(instanceId);

    log.debug("start describing instance termination protection for account:{} in region:{} via api", account.getId() + "=>" + account.getName(), region);
    DescribeInstanceAttributeResult res = ec2.describeInstanceAttribute(req);

    return res.getInstanceAttribute().getDisableApiTermination();
}
 
开发者ID:veyronfei,项目名称:clouck,代码行数:14,代码来源:Ec2WrapperImpl.java


示例10: findShutdownBehavior

import com.amazonaws.services.ec2.model.DescribeInstanceAttributeRequest; //导入依赖的package包/类
@Override
public String findShutdownBehavior(Account account, Region region, String instanceId) {
    AmazonEC2 ec2 = findClient(account, region);

    DescribeInstanceAttributeRequest req = new DescribeInstanceAttributeRequest();
    req.setAttribute("instanceInitiatedShutdownBehavior");
    req.setInstanceId(instanceId);

    log.debug("start describing instance shutdown behavior for account:{} in region:{} via api", account.getId() + "=>" + account.getName(), region);
    DescribeInstanceAttributeResult res = ec2.describeInstanceAttribute(req);

    return res.getInstanceAttribute().getInstanceInitiatedShutdownBehavior();
}
 
开发者ID:veyronfei,项目名称:clouck,代码行数:14,代码来源:Ec2WrapperImpl.java


示例11: findUserData

import com.amazonaws.services.ec2.model.DescribeInstanceAttributeRequest; //导入依赖的package包/类
@Override
public String findUserData(Account account, Region region, String instanceId) {
    AmazonEC2 ec2 = findClient(account, region);

    DescribeInstanceAttributeRequest req = new DescribeInstanceAttributeRequest();
    req.setAttribute("userData");
    req.setInstanceId(instanceId);

    log.debug("start describing instance user data for account:{} in region:{} via api", account.getId() + "=>" + account.getName(), region);
    DescribeInstanceAttributeResult res = ec2.describeInstanceAttribute(req);

    return res.getInstanceAttribute().getUserData();
}
 
开发者ID:veyronfei,项目名称:clouck,代码行数:14,代码来源:Ec2WrapperImpl.java


示例12: describeInstanceAttribute

import com.amazonaws.services.ec2.model.DescribeInstanceAttributeRequest; //导入依赖的package包/类
@Override
public DescribeInstanceAttributeResult describeInstanceAttribute(DescribeInstanceAttributeRequest describeInstanceAttributeRequest) throws AmazonServiceException, AmazonClientException {
    throw new UnsupportedOperationException("Not supported in mock");
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:AmazonEC2Mock.java


示例13: addDeleteOnTerminationFlag

import com.amazonaws.services.ec2.model.DescribeInstanceAttributeRequest; //导入依赖的package包/类
/**
 * Adds a delete on termination flag to all volumes in an {@code InstanceEbsVolumes} list
 * that have the ATTACHED status. This makes sure that the volumes associated with the
 * instance will be automatically cleaned up upon instance termination.
 *
 * @param instanceEbsVolumesList list of instances along with their associated volumes
 */
public void addDeleteOnTerminationFlag(List<InstanceEbsVolumes> instanceEbsVolumesList) {
  Set<String> volumesToFlag = getAllVolumeIdsWithStatus(instanceEbsVolumesList, InstanceEbsVolumes.Status.ATTACHED);

  if (!volumesToFlag.isEmpty()) {
    for (InstanceEbsVolumes instanceEbsVolumes : instanceEbsVolumesList) {
      String ec2InstanceId = instanceEbsVolumes.getEc2InstanceId();

      DescribeInstanceAttributeRequest instanceAttributeRequest = new DescribeInstanceAttributeRequest()
          .withAttribute(InstanceAttributeName.BlockDeviceMapping)
          .withInstanceId(ec2InstanceId);

      List<InstanceBlockDeviceMapping> blockDeviceMappings =
          client.describeInstanceAttribute(instanceAttributeRequest)
              .getInstanceAttribute()
              .getBlockDeviceMappings();

      for (InstanceBlockDeviceMapping blockDeviceMapping : blockDeviceMappings) {
        String volumeId = blockDeviceMapping.getEbs().getVolumeId();

        // The block device mapping may have volumes associated with it that were not
        // provisioned by us. We skip marking those volumes for deletion.

        if (!volumesToFlag.contains(volumeId)) {
          continue;
        }

        InstanceBlockDeviceMappingSpecification updatedSpec = new InstanceBlockDeviceMappingSpecification()
            .withEbs(
                new EbsInstanceBlockDeviceSpecification()
                    .withDeleteOnTermination(true)
                    .withVolumeId(volumeId)
            )
            .withDeviceName(blockDeviceMapping.getDeviceName());

        ModifyInstanceAttributeRequest modifyRequest = new ModifyInstanceAttributeRequest()
            .withBlockDeviceMappings(updatedSpec)
            .withInstanceId(ec2InstanceId);

        client.modifyInstanceAttribute(modifyRequest);
      }
    }
  }
}
 
开发者ID:cloudera,项目名称:director-aws-plugin,代码行数:51,代码来源:EBSAllocator.java


示例14: toExcaliburInstance

import com.amazonaws.services.ec2.model.DescribeInstanceAttributeRequest; //导入依赖的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


示例15: describeInstanceAttribute

import com.amazonaws.services.ec2.model.DescribeInstanceAttributeRequest; //导入依赖的package包/类
/**
 * {@link AmazonEC2#describeInstanceAttribute(DescribeInstanceAttributeRequest)}
 * 
 * @param ec2Client {@link AmazonEC2} to use.
 * @param describeInstanceAttributeRequest The request object.
 * @return {@link DescribeInstanceAttributeResult}
 */
public DescribeInstanceAttributeResult describeInstanceAttribute(AmazonEC2Client ec2Client,
    DescribeInstanceAttributeRequest describeInstanceAttributeRequest);
 
开发者ID:FINRAOS,项目名称:herd,代码行数:10,代码来源:Ec2Operations.java


示例16: describeAttribute

import com.amazonaws.services.ec2.model.DescribeInstanceAttributeRequest; //导入依赖的package包/类
/**
 * Performs the <code>DescribeAttribute</code> action.
 *
 * <p>
 * The following request parameters will be populated from the data of this
 * <code>Instance</code> resource, and any conflicting parameter value set
 * in the request will be overridden:
 * <ul>
 *   <li>
 *     <b><code>InstanceId</code></b>
 *         - mapped from the <code>Id</code> identifier.
 *   </li>
 * </ul>
 *
 * <p>
 *
 * @return The response of the low-level client operation associated with
 *         this resource action.
 * @see DescribeInstanceAttributeRequest
 */
DescribeInstanceAttributeResult describeAttribute(
        DescribeInstanceAttributeRequest request);
 
开发者ID:awslabs,项目名称:aws-sdk-java-resources,代码行数:23,代码来源:Instance.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java AmazonDynamoDBClient类代码示例发布时间:2022-05-23
下一篇:
Java XSObjectListImpl类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap