use of org.apache.cloudstack.api.response.SnapshotResponse in project cloudstack by apache.
the class CreateSnapshotFromVMSnapshotCmd method execute.
@Override
public void execute() {
s_logger.info("CreateSnapshotFromVMSnapshotCmd with vm snapshot id:" + getVMSnapshotId() + " and snapshot id:" + getEntityId() + " starts:" + System.currentTimeMillis());
CallContext.current().setEventDetails("Vm Snapshot Id: " + getVMSnapshotId());
Snapshot snapshot = null;
try {
snapshot = _snapshotService.backupSnapshotFromVmSnapshot(getEntityId(), getVmId(), getVolumeId(), getVMSnapshotId());
if (snapshot != null) {
SnapshotResponse response = _responseGenerator.createSnapshotResponse(snapshot);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create snapshot due to an internal error creating snapshot from vm snapshot " + getVMSnapshotId());
}
} catch (InvalidParameterValueException ex) {
throw ex;
} catch (Exception e) {
s_logger.debug("Failed to create snapshot", e);
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create snapshot due to an internal error creating snapshot from vm snapshot " + getVMSnapshotId());
} finally {
if (snapshot == null) {
try {
_snapshotService.deleteSnapshot(getEntityId());
} catch (Exception e) {
s_logger.debug("Failed to clean failed snapshot" + getEntityId());
}
}
}
}
Aggregations