Search in sources :

Example 1 with DeleteVolumeResult

use of com.amazonaws.services.ec2.model.DeleteVolumeResult in project photon-model by vmware.

the class AWSDiskService method deleteDisk.

/**
 * Deletes the diskstate and the corresponding volume on aws.
 */
private void deleteDisk(AWSDiskContext context) {
    if (context.diskRequest.isMockRequest) {
        deleteDiskState(context, AwsDiskStage.FINISHED);
        return;
    }
    DiskState diskState = context.disk;
    String diskId = diskState.id;
    if (diskId == null || !diskId.startsWith(AWS_VOLUME_ID_PREFIX)) {
        String message = "disk Id cannot be empty";
        this.logSevere("[AWSDiskService] " + message);
        throw new IllegalArgumentException(message);
    }
    if (diskState.status != DiskService.DiskStatus.AVAILABLE) {
        String message = String.format("disk cannot be deleted. Current status is %s", diskState.status.name());
        this.logSevere("[AWSDiskService] " + message);
        throw new IllegalArgumentException(message);
    }
    AsyncHandler<DeleteVolumeRequest, DeleteVolumeResult> deletionHandler = new AWSDiskDeletionHandler(this, context);
    DeleteVolumeRequest deleteVolumeRequest = new DeleteVolumeRequest().withVolumeId(diskId);
    context.client.deleteVolume(deleteVolumeRequest, deletionHandler);
}
Also used : DeleteVolumeRequest(com.amazonaws.services.ec2.model.DeleteVolumeRequest) DeleteVolumeResult(com.amazonaws.services.ec2.model.DeleteVolumeResult) DiskState(com.vmware.photon.controller.model.resources.DiskService.DiskState)

Aggregations

DeleteVolumeRequest (com.amazonaws.services.ec2.model.DeleteVolumeRequest)1 DeleteVolumeResult (com.amazonaws.services.ec2.model.DeleteVolumeResult)1 DiskState (com.vmware.photon.controller.model.resources.DiskService.DiskState)1