本文整理汇总了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;
}
}
示例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);
}
示例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);
// }
}
示例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);
}
示例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");
}
示例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);
}
}
}
}
示例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);
}
示例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;
}
示例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);
示例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);