本文整理汇总了Java中com.amazonaws.services.ec2.model.CreateVolumeRequest类的典型用法代码示例。如果您正苦于以下问题:Java CreateVolumeRequest类的具体用法?Java CreateVolumeRequest怎么用?Java CreateVolumeRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CreateVolumeRequest类属于com.amazonaws.services.ec2.model包,在下文中一共展示了CreateVolumeRequest类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createVolume
import com.amazonaws.services.ec2.model.CreateVolumeRequest; //导入依赖的package包/类
/**
* Creates a volume and return the volume id.
*/
public static String createVolume(VerificationHost host, AmazonEC2Client client) {
CreateVolumeRequest req = new CreateVolumeRequest()
.withAvailabilityZone(zoneId + avalabilityZoneIdentifier)
.withSize(1);
CreateVolumeResult res = client.createVolume(req);
String volumeId = res.getVolume().getVolumeId();
Filter filter = new Filter().withName(VOLUME_ID_ATTRIBUTE).withValues(volumeId);
DescribeVolumesRequest volumesRequest = new DescribeVolumesRequest()
.withVolumeIds(volumeId)
.withFilters(filter);
host.waitFor("Timeout waiting for creating volume", () -> {
DescribeVolumesResult volumesResult = client.describeVolumes(volumesRequest);
String state = volumesResult.getVolumes().get(0).getState();
if (state.equalsIgnoreCase(VOLUME_STATUS_AVAILABLE)) {
return true;
}
return false;
});
return volumeId;
}
示例2: createVolume
import com.amazonaws.services.ec2.model.CreateVolumeRequest; //导入依赖的package包/类
/**
* Creates volume for EBS.
* @return volume ID of newly created volume
*/
private String createVolume(String storageId, String snapshotId, int size) {
String volumeType = Ec2IaasHandler.findStorageProperty(this.targetProperties, storageId, VOLUME_TYPE_PREFIX);
if(volumeType == null) volumeType = "standard";
CreateVolumeRequest createVolumeRequest = new CreateVolumeRequest()
.withAvailabilityZone( this.availabilityZone )
.withVolumeType( volumeType )
.withSize( size ); // The size of the volume, in gigabytes.
// EC2 snapshot IDs start with "snap-"...
if(! Utils.isEmptyOrWhitespaces(snapshotId) && snapshotId.startsWith("snap-"))
createVolumeRequest.withSnapshotId(snapshotId);
CreateVolumeResult createVolumeResult = this.ec2Api.createVolume(createVolumeRequest);
return createVolumeResult.getVolume().getVolumeId();
}
示例3: createVolume
import com.amazonaws.services.ec2.model.CreateVolumeRequest; //导入依赖的package包/类
/**
* Create Volume.
*
* @param availabilityZone the availability zone
* @param iops the iops
* @param size the size
* @param snapshotId the snapshot id
* @param volumeType the volume type
* @return Volume
*/
protected final Volume createVolume(final String availabilityZone, final Integer iops, final Integer size, final String snapshotId, final String volumeType) {
Volume volume = null;
CreateVolumeRequest req = new CreateVolumeRequest();
req.setAvailabilityZone(availabilityZone);
req.setIops(iops);
req.setSize(size);
req.setSnapshotId(snapshotId);
req.setVolumeType(volumeType);
CreateVolumeResult result = amazonEC2Client.createVolume(req);
if (result != null) {
volume = result.getVolume();
}
return volume;
}
示例4: createVolume
import com.amazonaws.services.ec2.model.CreateVolumeRequest; //导入依赖的package包/类
protected Volume createVolume(Zone zone, Integer sizeGb, String snapshotId)
{
CreateVolumeResult request = ec2_.createVolume(new CreateVolumeRequest()
.withAvailabilityZone(zone.getName())
.withSize(sizeGb)
.withSnapshotId(snapshotId));
return request.getVolume();
}
示例5: createVolume
import com.amazonaws.services.ec2.model.CreateVolumeRequest; //导入依赖的package包/类
public void createVolume(AwsProcessClient awsProcessClient, Long instanceNo, Long volumeNo) {
AwsVolume awsVolume = awsVolumeDao.read(volumeNo);
AwsInstance awsInstance = awsInstanceDao.read(instanceNo);
// ボリュームの作成
CreateVolumeRequest request = new CreateVolumeRequest();
request.withSize(awsVolume.getSize());
request.withSnapshotId(awsVolume.getSnapshotId());
request.withAvailabilityZone(awsInstance.getAvailabilityZone());
String volumeType = Config.getProperty("aws.volumeType");
if (StringUtils.isNotEmpty(volumeType)) {
request.withVolumeType(volumeType);
}
CreateVolumeResult result = awsProcessClient.getEc2Client().createVolume(request);
Volume volume = result.getVolume();
String volumeId = volume.getVolumeId();
// ログ出力
if (log.isInfoEnabled()) {
log.info(MessageUtils.getMessage("IPROCESS-100121", volumeId));
}
//イベントログ出力
Component component = null;
if (awsVolume.getComponentNo() != null) {
component = componentDao.read(awsVolume.getComponentNo());
}
Instance instance = instanceDao.read(instanceNo);
processLogger.debug(component, instance, "AwsEbsCreate", new Object[] { awsProcessClient.getPlatform()
.getPlatformName() });
// データベース更新
awsVolume.setVolumeId(volume.getVolumeId());
awsVolume.setStatus(volume.getState());
awsVolumeDao.update(awsVolume);
}
示例6: createVolume
import com.amazonaws.services.ec2.model.CreateVolumeRequest; //导入依赖的package包/类
@Override
public Image createVolume(CreateVolumeRequest request,
ResultCapture<CreateVolumeResult> extractor) {
ActionResult result = service.performAction("CreateVolume", request,
extractor);
if (result == null) return null;
return new ImageImpl(result.getResource());
}
示例7: prepareCreateVolumeRequest
import com.amazonaws.services.ec2.model.CreateVolumeRequest; //导入依赖的package包/类
private CreateVolumeRequest prepareCreateVolumeRequest(AuthenticatedContext ac, AwsInstanceView awsInstanceView, AmazonEC2Client client) {
String availabilityZone = prepareDescribeAvailabilityZonesResult(ac, client);
CreateVolumeRequest createVolumeRequest = new CreateVolumeRequest().withSize(VOLUME_SIZE).withAvailabilityZone(availabilityZone).withEncrypted(true);
if (awsInstanceView.isKmsEnabled()) {
createVolumeRequest.withKmsKeyId(awsInstanceView.getKmsKey());
}
return createVolumeRequest;
}
示例8: createVolume
import com.amazonaws.services.ec2.model.CreateVolumeRequest; //导入依赖的package包/类
@Override
public CreateVolumeResult createVolume(CreateVolumeRequest createVolumeRequest) throws AmazonServiceException, AmazonClientException {
throw new UnsupportedOperationException("Not supported in mock");
}
示例9: createVolume
import com.amazonaws.services.ec2.model.CreateVolumeRequest; //导入依赖的package包/类
/**
* Creates an ebs volume.
*/
public void createVolume(CreateVolumeRequest req,
AsyncHandler<CreateVolumeRequest, CreateVolumeResult> creationHandler) {
this.client.createVolumeAsync(req, creationHandler);
}
示例10: createVolume
import com.amazonaws.services.ec2.model.CreateVolumeRequest; //导入依赖的package包/类
/**
* Performs the <code>CreateVolume</code> action.
*
* <p>
*
* @return The <code>Image</code> resource object associated with the result
* of this action.
* @see CreateVolumeRequest
*/
com.amazonaws.resources.ec2.Image createVolume(CreateVolumeRequest request);