com.amazonaws.services.ec2.model.CreateVolumeResult Java Examples
The following examples show how to use
com.amazonaws.services.ec2.model.CreateVolumeResult.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Ec2MachineConfigurator.java From roboconf-platform with Apache License 2.0 | 6 votes |
/** * 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(); }
Example #2
Source File: BaseTest.java From aws-mock with MIT License | 6 votes |
/** * 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; }
Example #3
Source File: EncryptedSnapshotService.java From cloudbreak with Apache License 2.0 | 6 votes |
private Optional<String> prepareSnapshotForEncryptionBecauseThatDoesNotExist(AuthenticatedContext ac, CloudStack cloudStack, AwsInstanceView instanceView, AmazonEC2Client client, PersistenceNotifier resourceNotifier) { LOGGER.debug("Create an encrypted EBS volume for group: '{}'", instanceView.getGroupName()); CreateVolumeResult volumeResult = client.createVolume(prepareCreateVolumeRequest(ac, instanceView, client, cloudStack)); String volumeId = volumeResult.getVolume().getVolumeId(); checkEbsVolumeStatus(ac, client, volumeId); saveEncryptedResource(ac, resourceNotifier, ResourceType.AWS_ENCRYPTED_VOLUME, volumeId, instanceView.getGroupName()); LOGGER.debug("Encrypted EBS volume has been created with id: '{}', for group: '{}'", volumeId, instanceView.getGroupName()); LOGGER.debug("Create an encrypted snapshot of EBS volume for group: '{}'", instanceView.getGroupName()); CreateSnapshotResult snapshotResult = client.createSnapshot(prepareCreateSnapshotRequest(volumeResult)); checkSnapshotReadiness(ac, client, snapshotResult); LOGGER.debug("Encrypted snapshot of EBS volume has been created with id: '{}', for group: '{}'", snapshotResult.getSnapshot().getSnapshotId(), instanceView.getGroupName()); client.createTags(prepareCreateTagsRequest(ac, cloudStack, instanceView, snapshotResult)); return Optional.of(snapshotResult.getSnapshot().getSnapshotId()); }
Example #4
Source File: EC2Impl.java From aws-sdk-java-resources with Apache License 2.0 | 5 votes |
@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()); }
Example #5
Source File: EC2Impl.java From aws-sdk-java-resources with Apache License 2.0 | 5 votes |
@Override public Image createVolume(String availabilityZone, Integer size, ResultCapture<CreateVolumeResult> extractor) { CreateVolumeRequest request = new CreateVolumeRequest() .withAvailabilityZone(availabilityZone) .withSize(size); return createVolume(request, extractor); }
Example #6
Source File: EC2Impl.java From aws-sdk-java-resources with Apache License 2.0 | 5 votes |
@Override public Image createVolume(String snapshotId, String availabilityZone, ResultCapture<CreateVolumeResult> extractor) { CreateVolumeRequest request = new CreateVolumeRequest() .withSnapshotId(snapshotId) .withAvailabilityZone(availabilityZone); return createVolume(request, extractor); }
Example #7
Source File: AwsLaunchTest.java From cloudbreak with Apache License 2.0 | 5 votes |
private void setupCreateVolumeResponse() { when(amazonEC2Client.createVolume(any())).thenReturn( new CreateVolumeResult().withVolume( new com.amazonaws.services.ec2.model.Volume().withVolumeId(VOLUME_ID + getNextVolumeId()) ) ); }
Example #8
Source File: AwsVolumeProcess.java From primecloud-controller with GNU General Public License v2.0 | 5 votes |
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); }
Example #9
Source File: EC2Impl.java From aws-sdk-java-resources with Apache License 2.0 | 4 votes |
@Override public Image createVolume(String availabilityZone, Integer size) { return createVolume(availabilityZone, size, (ResultCapture<CreateVolumeResult>)null); }
Example #10
Source File: EC2Impl.java From aws-sdk-java-resources with Apache License 2.0 | 4 votes |
@Override public Image createVolume(String snapshotId, String availabilityZone) { return createVolume(snapshotId, availabilityZone, (ResultCapture<CreateVolumeResult>)null); }
Example #11
Source File: AwsVolumeResourceBuilder.java From cloudbreak with Apache License 2.0 | 4 votes |
@Override public List<CloudResource> build(AwsContext context, long privateId, AuthenticatedContext auth, Group group, List<CloudResource> buildableResource, CloudStack cloudStack) throws Exception { LOGGER.debug("Create volumes on provider"); AmazonEc2RetryClient client = getAmazonEC2Client(auth); Map<String, List<Volume>> volumeSetMap = Collections.synchronizedMap(new HashMap<>()); List<Future<?>> futures = new ArrayList<>(); String snapshotId = getEbsSnapshotIdIfNeeded(auth, cloudStack, group); boolean encryptedVolumeUsingFastApproach = isEncryptedVolumeUsingFastApproachRequested(group); String volumeEncryptionKey = getVolumeEncryptionKey(group, encryptedVolumeUsingFastApproach); TagSpecification tagSpecification = new TagSpecification() .withResourceType(com.amazonaws.services.ec2.model.ResourceType.Volume) .withTags(awsTaggingService.prepareEc2Tags(auth, cloudStack.getTags())); List<CloudResource> requestedResources = buildableResource.stream() .filter(cloudResource -> CommonStatus.REQUESTED.equals(cloudResource.getStatus())) .collect(Collectors.toList()); Long ephemeralCount = group.getReferenceInstanceConfiguration().getTemplate().getVolumes().stream() .filter(vol -> AwsDiskType.Ephemeral.value().equalsIgnoreCase(vol.getType())).collect(Collectors.counting()); LOGGER.debug("Start creating data volumes for stack: '{}' group: '{}'", auth.getCloudContext().getName(), group.getName()); for (CloudResource resource : requestedResources) { volumeSetMap.put(resource.getName(), Collections.synchronizedList(new ArrayList<>())); VolumeSetAttributes volumeSet = resource.getParameter(CloudResource.ATTRIBUTES, VolumeSetAttributes.class); DeviceNameGenerator generator = new DeviceNameGenerator(DEVICE_NAME_TEMPLATE, ephemeralCount.intValue()); futures.addAll(volumeSet.getVolumes().stream() .map(createVolumeRequest(snapshotId, encryptedVolumeUsingFastApproach, volumeEncryptionKey, tagSpecification, volumeSet)) .map(request -> intermediateBuilderExecutor.submit(() -> { CreateVolumeResult result = client.createVolume(request); String volumeId = result.getVolume().getVolumeId(); Volume volume = new Volume(volumeId, generator.next(), request.getSize(), request.getVolumeType()); volumeSetMap.get(resource.getName()).add(volume); })) .collect(Collectors.toList())); } for (Future<?> future : futures) { future.get(); } return buildableResource.stream() .peek(resource -> { List<Volume> volumes = volumeSetMap.get(resource.getName()); if (!CollectionUtils.isEmpty(volumes)) { resource.getParameter(CloudResource.ATTRIBUTES, VolumeSetAttributes.class).setVolumes(volumes); } }) .map(copyResourceWithNewStatus(CommonStatus.CREATED)) .collect(Collectors.toList()); }
Example #12
Source File: AmazonEc2RetryClient.java From cloudbreak with Apache License 2.0 | 4 votes |
public CreateVolumeResult createVolume(CreateVolumeRequest request) { return retry.testWith2SecDelayMax15Times(() -> mapThrottlingError(() -> client.createVolume(request))); }
Example #13
Source File: EncryptedSnapshotService.java From cloudbreak with Apache License 2.0 | 4 votes |
private CreateSnapshotRequest prepareCreateSnapshotRequest(CreateVolumeResult volumeResult) { return new CreateSnapshotRequest().withVolumeId(volumeResult.getVolume().getVolumeId()).withDescription(ENCRYPTED_SNAPSHOT); }
Example #14
Source File: AwsVolumeResourceBuilderTest.java From cloudbreak with Apache License 2.0 | 4 votes |
private CreateVolumeResult createCreateVolumeResult() { return new CreateVolumeResult().withVolume(new com.amazonaws.services.ec2.model.Volume().withVolumeId(VOLUME_ID)); }
Example #15
Source File: EC2.java From aws-sdk-java-resources with Apache License 2.0 | 2 votes |
/** * The convenient method form for the <code>CreateVolume</code> action. * * @see #createVolume(CreateVolumeRequest, ResultCapture) */ com.amazonaws.resources.ec2.Image createVolume(String availabilityZone, Integer size, ResultCapture<CreateVolumeResult> extractor);
Example #16
Source File: EC2.java From aws-sdk-java-resources with Apache License 2.0 | 2 votes |
/** * The convenient method form for the <code>CreateVolume</code> action. * * @see #createVolume(CreateVolumeRequest, ResultCapture) */ com.amazonaws.resources.ec2.Image createVolume(String snapshotId, String availabilityZone, ResultCapture<CreateVolumeResult> extractor);
Example #17
Source File: EC2.java From aws-sdk-java-resources with Apache License 2.0 | 2 votes |
/** * 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);