use of com.cloud.uservm.UserVm in project cosmic by MissionCriticalCloud.
the class CreateSnapshotFromVMSnapshotCmd method getVmId.
private Long getVmId() {
final VMSnapshot vmsnapshot = _entityMgr.findById(VMSnapshot.class, getVMSnapshotId());
if (vmsnapshot == null) {
throw new InvalidParameterValueException("Unable to find vm snapshot by id=" + getVMSnapshotId());
}
final UserVm vm = _entityMgr.findById(UserVm.class, vmsnapshot.getVmId());
if (vm == null) {
throw new InvalidParameterValueException("Unable to find vm by vm snapshot id=" + getVMSnapshotId());
}
return vm.getId();
}
use of com.cloud.uservm.UserVm in project cosmic by MissionCriticalCloud.
the class ResetVMPasswordCmd method execute.
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException {
password = _mgr.generateRandomPassword();
CallContext.current().setEventDetails("Vm Id: " + getId());
final UserVm result = _userVmService.resetVMPassword(this, password);
if (result != null) {
final UserVmResponse response = _responseGenerator.createUserVmResponse(ResponseView.Restricted, "virtualmachine", result).get(0);
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to reset vm password");
}
}
use of com.cloud.uservm.UserVm in project cosmic by MissionCriticalCloud.
the class ResetVMSSHKeyCmd method execute.
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException {
CallContext.current().setEventDetails("Vm Id: " + getId());
final UserVm result = _userVmService.resetVMSSHKey(this);
if (result != null) {
final UserVmResponse response = _responseGenerator.createUserVmResponse(ResponseView.Restricted, "virtualmachine", result).get(0);
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to reset vm SSHKey");
}
}
use of com.cloud.uservm.UserVm in project cosmic by MissionCriticalCloud.
the class RestoreVMCmd method execute.
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
final UserVm result;
CallContext.current().setEventDetails("Vm Id: " + getVmId());
result = _userVmService.restoreVM(this);
if (result != null) {
final UserVmResponse response = _responseGenerator.createUserVmResponse(ResponseView.Restricted, "virtualmachine", result).get(0);
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to restore vm " + getVmId());
}
}
use of com.cloud.uservm.UserVm in project cosmic by MissionCriticalCloud.
the class StopVMCmd method execute.
@Override
public void execute() throws ServerApiException, ConcurrentOperationException {
CallContext.current().setEventDetails("Vm Id: " + getId());
final UserVm result;
result = _userVmService.stopVirtualMachine(getId(), isForced());
if (result != null) {
final UserVmResponse response = _responseGenerator.createUserVmResponse(ResponseView.Restricted, "virtualmachine", result).get(0);
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to stop vm");
}
}
Aggregations