com.amazonaws.services.ec2.model.DeleteVolumeRequest Java Examples

The following examples show how to use com.amazonaws.services.ec2.model.DeleteVolumeRequest. 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: AwsVolumeProcess.java    From primecloud-controller with GNU General Public License v2.0 6 votes vote down vote up
public void deleteVolume(AwsProcessClient awsProcessClient, Long instanceNo, Long volumeNo) {
    AwsVolume awsVolume = awsVolumeDao.read(volumeNo);
    String volumeId = awsVolume.getVolumeId();

    // イベントログ出力
    Component component = null;
    if (awsVolume.getComponentNo() != null) {
        component = componentDao.read(awsVolume.getComponentNo());
    }
    Instance instance = null;
    if (instanceNo != null) {
        instance = instanceDao.read(instanceNo);
    }
    processLogger.debug(component, instance, "AwsEbsDelete",
            new Object[] { awsProcessClient.getPlatform().getPlatformName(), awsVolume.getVolumeId() });

    // ボリュームの削除
    DeleteVolumeRequest request = new DeleteVolumeRequest();
    request.withVolumeId(volumeId);
    awsProcessClient.getEc2Client().deleteVolume(request);

    // ログ出力
    if (log.isInfoEnabled()) {
        log.info(MessageUtils.getMessage("IPROCESS-100127", volumeId));
    }
}
 
Example #2
Source File: AwsVolumeResourceBuilder.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
private void deleteOrphanedVolumes(List<CloudResourceStatus> cloudResourceStatuses, AmazonEc2RetryClient client) {
    cloudResourceStatuses.stream()
            .filter(cloudResourceStatus -> ResourceStatus.CREATED.equals(cloudResourceStatus.getStatus()))
            .map(CloudResourceStatus::getCloudResource)
            .map(cloudResource -> cloudResource.getParameter(CloudResource.ATTRIBUTES, VolumeSetAttributes.class))
            .map(VolumeSetAttributes::getVolumes)
            .flatMap(List::stream)
            .map(VolumeSetAttributes.Volume::getId)
            .map(volumeId -> new DeleteVolumeRequest().withVolumeId(volumeId))
            .forEach(client::deleteVolume);
}
 
Example #3
Source File: EncryptedSnapshotService.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
private void deleteVolumeResources(AmazonEC2Client client, List<CloudResource> resources) {
    Set<CloudResource> encryptedVolumes = filterResourcesByType(resources, ResourceType.AWS_ENCRYPTED_VOLUME);
    for (CloudResource volume : encryptedVolumes) {
        try {
            DeleteVolumeRequest deleteVolumeRequest = new DeleteVolumeRequest().withVolumeId(volume.getName());
            client.deleteVolume(deleteVolumeRequest);
        } catch (Exception e) {
            String errorMessage = String.format("Failed to delete volume [id:'%s'], detailed message: %s", volume.getName(), e.getMessage());
            LOGGER.warn(errorMessage, e);
            if (!e.getMessage().contains(VOLUME_NOT_FOUND_MSG_CODE)) {
                throw new CloudConnectorException(errorMessage, e);
            }
        }
    }
}
 
Example #4
Source File: BaseTest.java    From aws-mock with MIT License 5 votes vote down vote up
/**
 * Delete Volume.
 *
 * @param volumeId the volume id
 * @return true if deleted, otherwise false.
 */
protected final boolean deleteVolume(final String volumeId) {
    DeleteVolumeRequest req = new DeleteVolumeRequest();
    req.setVolumeId(volumeId);
    DeleteVolumeResult result = amazonEC2Client.deleteVolume(req);
    if (result != null) {
        return true;
    }

    return false;
}
 
Example #5
Source File: AmazonEc2RetryClient.java    From cloudbreak with Apache License 2.0 4 votes vote down vote up
public DeleteVolumeResult deleteVolume(DeleteVolumeRequest request) {
    return retry.testWith2SecDelayMax15Times(() -> mapThrottlingError(() -> client.deleteVolume(request)));
}