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);
}
Aggregations