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

Java ModifyInstanceAttributeRequest类代码示例

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

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



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

示例1: modifyInstanceAttribute

import com.amazonaws.services.ec2.model.ModifyInstanceAttributeRequest; //导入依赖的package包/类
@Override
public void modifyInstanceAttribute(AmazonEC2Client ec2Client, ModifyInstanceAttributeRequest modifyInstanceAttributeRequest)
{
    if (modifyInstanceAttributeRequest.getGroups() != null &&
        modifyInstanceAttributeRequest.getGroups().get(0).equals(MockAwsOperationsHelper.AMAZON_SERVICE_EXCEPTION))
    {
        throw new AmazonServiceException(MockAwsOperationsHelper.AMAZON_SERVICE_EXCEPTION);
    }

    if (modifyInstanceAttributeRequest.getGroups() != null &&
        modifyInstanceAttributeRequest.getGroups().get(0).equals(MockAwsOperationsHelper.AMAZON_THROTTLING_EXCEPTION))
    {
        AmazonServiceException throttlingException = new AmazonServiceException("test throttling exception");
        throttlingException.setErrorCode("ThrottlingException");

        throw throttlingException;
    }

}
 
开发者ID:FINRAOS,项目名称:herd,代码行数:20,代码来源:MockEc2OperationsImpl.java


示例2: addSecurityGroupsToEc2Instance

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


示例3: modifyInstanceAttributes

import com.amazonaws.services.ec2.model.ModifyInstanceAttributeRequest; //导入依赖的package包/类
public void modifyInstanceAttributes(String instanceId, Attribute... attributes)
    {
        checkState(!isNullOrEmpty(instanceId));
        
//        InstanceState instanceState = 
//                ec2_.describeInstanceStatus(new DescribeInstanceStatusRequest().withInstanceIds(instanceId)).getInstanceStatuses().get(0).getInstanceState();
//        
//        final InstanceStateType stateType = InstanceStateType.valueOfFrom(instanceState.getName());
//        boolean isRunning = InstanceStateType.RUNNING.equals(stateType);
//        
//        if (isRunning)
//        {
            this.stop(instanceId);
//        }
        
        for (Attribute attribute : attributes)
        {
            if (attribute != null && !isNullOrEmpty(attribute.getName()))
            {
                ModifyInstanceAttributeRequest request = new ModifyInstanceAttributeRequest()
                        .withInstanceId(instanceId)
                        .withAttribute(attribute.getName());

                if (!isNullOrEmpty(attribute.getValue()))
                {
                    request.setValue(attribute.getValue());
                }
                
                ec2_.modifyInstanceAttribute(request);
            }
        }
        
//        if (isRunning)
//        {
            this.startInstances(instanceId);
//        }
    }
 
开发者ID:alessandroleite,项目名称:dohko,代码行数:38,代码来源:EC2.java


示例4: modifyAttribute

import com.amazonaws.services.ec2.model.ModifyInstanceAttributeRequest; //导入依赖的package包/类
@Override
public void modifyAttribute(String attribute, ResultCapture<Void> extractor)
        {

    ModifyInstanceAttributeRequest request = new
            ModifyInstanceAttributeRequest()

        .withAttribute(attribute);
    modifyAttribute(request, extractor);
}
 
开发者ID:awslabs,项目名称:aws-sdk-java-resources,代码行数:11,代码来源:InstanceImpl.java


示例5: modifyInstanceAttribute

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


示例6: addDeleteOnTerminationFlag

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


示例7: modifyInstanceAttribute

import com.amazonaws.services.ec2.model.ModifyInstanceAttributeRequest; //导入依赖的package包/类
/**
 * Modify EC2 instance attributes
 */
@Override
public void modifyInstanceAttribute(AmazonEC2Client ec2Client, ModifyInstanceAttributeRequest modifyInstanceAttributeRequest)
{
    ec2Client.modifyInstanceAttribute(modifyInstanceAttributeRequest);
}
 
开发者ID:FINRAOS,项目名称:herd,代码行数:9,代码来源:Ec2OperationsImpl.java


示例8: attachVolumes

import com.amazonaws.services.ec2.model.ModifyInstanceAttributeRequest; //导入依赖的package包/类
/**
 * Attaches volume(s) for EBS.
 * @return true if successful attachment, or nothing to do. false otherwise
 */
private boolean attachVolumes() {

	// If volume is found in map, it has been successfully created (no need to check here)
	for( Map.Entry<String,String> entry : this.storageIdToVolumeId.entrySet()) {

		String volumeId = entry.getValue();
		String storageId = entry.getKey();

		// Give a name to the volume before attaching
		String nameTemplate = Ec2IaasHandler.findStorageProperty(this.targetProperties, storageId, VOLUME_NAME_PREFIX);
		String name = Ec2IaasHandler.expandVolumeName(
				nameTemplate, this.applicationName, this.scopedInstance.getName());
		if(Utils.isEmptyOrWhitespaces(name)) name = "Created by Roboconf for " + this.tagName;
		tagResource(volumeId, name);

		// Attach volume now
		String mountPoint = Ec2IaasHandler.findStorageProperty(this.targetProperties, storageId, VOLUME_MOUNT_POINT_PREFIX);
		if(Utils.isEmptyOrWhitespaces(mountPoint)) mountPoint = "/dev/sdf";

		AttachVolumeRequest attachRequest = new AttachVolumeRequest()
			.withInstanceId(this.machineId)
			.withDevice(mountPoint)
			.withVolumeId(volumeId);

		try {
			this.ec2Api.attachVolume(attachRequest);
		} catch(Exception e) {
			this.logger.warning("EBS Volume attachment error: " + e);
		}

		// Set deleteOnTermination flag ?
		if(Boolean.parseBoolean(Ec2IaasHandler.findStorageProperty(this.targetProperties, storageId, VOLUME_DELETE_OT_PREFIX))) {
			EbsInstanceBlockDeviceSpecification ebsSpecification = new EbsInstanceBlockDeviceSpecification()
				.withVolumeId(volumeId)
				.withDeleteOnTermination(true);

			InstanceBlockDeviceMappingSpecification mappingSpecification = new InstanceBlockDeviceMappingSpecification()
				.withDeviceName(mountPoint)
				.withEbs(ebsSpecification);

			ModifyInstanceAttributeRequest request = new ModifyInstanceAttributeRequest()
				.withInstanceId(this.machineId)
				.withBlockDeviceMappings(mappingSpecification);

			this.ec2Api.modifyInstanceAttribute(request);
		}
	}

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


示例9: modifyInstanceAttribute

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


示例10: modifyAttribute

import com.amazonaws.services.ec2.model.ModifyInstanceAttributeRequest; //导入依赖的package包/类
/**
 * Performs the <code>ModifyAttribute</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>
 *
 * @see ModifyInstanceAttributeRequest
 */
void modifyAttribute(ModifyInstanceAttributeRequest request);
 
开发者ID:awslabs,项目名称:aws-sdk-java-resources,代码行数:20,代码来源:Instance.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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