use of com.cloud.api.response.VMSnapshotResponse in project cosmic by MissionCriticalCloud.
the class ListVMSnapshotCmd method execute.
@Override
public void execute() {
final List<? extends VMSnapshot> result = _vmSnapshotService.listVMSnapshots(this);
final ListResponse<VMSnapshotResponse> response = new ListResponse<>();
final List<VMSnapshotResponse> snapshotResponses = new ArrayList<>();
for (final VMSnapshot r : result) {
final VMSnapshotResponse vmSnapshotResponse = _responseGenerator.createVMSnapshotResponse(r);
vmSnapshotResponse.setObjectName("vmSnapshot");
snapshotResponses.add(vmSnapshotResponse);
}
response.setResponses(snapshotResponses);
response.setResponseName(getCommandName());
setResponseObject(response);
}
use of com.cloud.api.response.VMSnapshotResponse in project cosmic by MissionCriticalCloud.
the class CreateVMSnapshotCmd method execute.
@Override
public void execute() {
CallContext.current().setEventDetails("VM Id: " + getVmId());
final VMSnapshot result = _vmSnapshotService.createVMSnapshot(getVmId(), getEntityId(), isQuiescevm());
if (result != null) {
final VMSnapshotResponse response = _responseGenerator.createVMSnapshotResponse(result);
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create vm snapshot due to an internal error creating snapshot for vm " + getVmId());
}
}
use of com.cloud.api.response.VMSnapshotResponse in project cosmic by MissionCriticalCloud.
the class ApiResponseHelper method createVMSnapshotResponse.
@Override
public VMSnapshotResponse createVMSnapshotResponse(final VMSnapshot vmSnapshot) {
final VMSnapshotResponse vmSnapshotResponse = new VMSnapshotResponse();
vmSnapshotResponse.setId(vmSnapshot.getUuid());
vmSnapshotResponse.setName(vmSnapshot.getName());
vmSnapshotResponse.setState(vmSnapshot.getState());
vmSnapshotResponse.setCreated(vmSnapshot.getCreated());
vmSnapshotResponse.setDescription(vmSnapshot.getDescription());
vmSnapshotResponse.setDisplayName(vmSnapshot.getDisplayName());
final UserVm vm = ApiDBUtils.findUserVmById(vmSnapshot.getVmId());
if (vm != null) {
vmSnapshotResponse.setVirtualMachineid(vm.getUuid());
}
if (vmSnapshot.getParent() != null) {
final VMSnapshot vmSnapshotParent = ApiDBUtils.getVMSnapshotById(vmSnapshot.getParent());
if (vmSnapshotParent != null) {
vmSnapshotResponse.setParent(vmSnapshotParent.getUuid());
vmSnapshotResponse.setParentName(vmSnapshotParent.getDisplayName());
}
}
populateOwner(vmSnapshotResponse, vmSnapshot);
final Project project = ApiDBUtils.findProjectByProjectAccountId(vmSnapshot.getAccountId());
if (project != null) {
vmSnapshotResponse.setProjectId(project.getUuid());
vmSnapshotResponse.setProjectName(project.getName());
}
vmSnapshotResponse.setCurrent(vmSnapshot.getCurrent());
vmSnapshotResponse.setType(vmSnapshot.getType().toString());
vmSnapshotResponse.setObjectName("vmsnapshot");
return vmSnapshotResponse;
}
Aggregations