Java 类com.amazonaws.services.ec2.model.CreateVolumeRequest 实例源码

项目:photon-model    文件:TestAWSSetupUtils.java   
/**
 * 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;
}
项目:roboconf-platform    文件:Ec2MachineConfigurator.java   
/**
 * 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();
}
项目:aws-mock    文件:BaseTest.java   
/**
 * 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;
}
项目:dohko    文件:EC2.java   
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();
}
项目:primecloud-controller    文件:AwsVolumeProcess.java   
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);
}
项目:aws-sdk-java-resources    文件:EC2Impl.java   
@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());
}
项目:aws-sdk-java-resources    文件:EC2Impl.java   
@Override
public Image createVolume(String availabilityZone, Integer size,
        ResultCapture<CreateVolumeResult> extractor) {

    CreateVolumeRequest request = new CreateVolumeRequest()
        .withAvailabilityZone(availabilityZone)
        .withSize(size);
    return createVolume(request, extractor);
}
项目:aws-sdk-java-resources    文件:EC2Impl.java   
@Override
public Image createVolume(String snapshotId, String availabilityZone,
        ResultCapture<CreateVolumeResult> extractor) {

    CreateVolumeRequest request = new CreateVolumeRequest()
        .withSnapshotId(snapshotId)
        .withAvailabilityZone(availabilityZone);
    return createVolume(request, extractor);
}
项目:cloudbreak    文件:EncryptedSnapshotPreparator.java   
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;
}
项目:elasticsearch_my    文件:AmazonEC2Mock.java   
@Override
public CreateVolumeResult createVolume(CreateVolumeRequest createVolumeRequest) throws AmazonServiceException, AmazonClientException {
    throw new UnsupportedOperationException("Not supported in mock");
}
项目:photon-model    文件:AwsDiskClient.java   
/**
 * Creates an ebs volume.
 */
public void createVolume(CreateVolumeRequest req,
        AsyncHandler<CreateVolumeRequest, CreateVolumeResult> creationHandler) {
    this.client.createVolumeAsync(req, creationHandler);
}
项目:aws-sdk-java-resources    文件:EC2Impl.java   
@Override
public Image createVolume(CreateVolumeRequest request) {
    return createVolume(request, null);
}
项目:aws-sdk-java-resources    文件:EC2.java   
/**
 * 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);
项目:aws-sdk-java-resources    文件:EC2.java   
/**
 * Performs the <code>CreateVolume</code> action and use a ResultCapture to
 * retrieve the low-level client response.
 *
 * <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,
        ResultCapture<CreateVolumeResult> extractor);