Search in sources :

Example 71 with UserVm

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();
}
Also used : UserVm(com.cloud.uservm.UserVm) InvalidParameterValueException(com.cloud.utils.exception.InvalidParameterValueException) VMSnapshot(com.cloud.vm.snapshot.VMSnapshot)

Example 72 with UserVm

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");
    }
}
Also used : UserVm(com.cloud.uservm.UserVm) ServerApiException(com.cloud.api.ServerApiException) UserVmResponse(com.cloud.api.response.UserVmResponse)

Example 73 with UserVm

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");
    }
}
Also used : UserVm(com.cloud.uservm.UserVm) ServerApiException(com.cloud.api.ServerApiException) UserVmResponse(com.cloud.api.response.UserVmResponse)

Example 74 with UserVm

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());
    }
}
Also used : UserVm(com.cloud.uservm.UserVm) ServerApiException(com.cloud.api.ServerApiException) UserVmResponse(com.cloud.api.response.UserVmResponse)

Example 75 with UserVm

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");
    }
}
Also used : UserVm(com.cloud.uservm.UserVm) ServerApiException(com.cloud.api.ServerApiException) UserVmResponse(com.cloud.api.response.UserVmResponse)

Aggregations

UserVm (com.cloud.uservm.UserVm)196 ServerApiException (com.cloud.api.ServerApiException)59 UserVmResponse (com.cloud.api.response.UserVmResponse)59 ArrayList (java.util.ArrayList)54 ServerApiException (org.apache.cloudstack.api.ServerApiException)48 UserVmResponse (org.apache.cloudstack.api.response.UserVmResponse)47 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)32 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)30 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)28 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)28 Network (com.cloud.network.Network)26 Account (com.cloud.user.Account)22 InsufficientCapacityException (com.cloud.exception.InsufficientCapacityException)21 ManagementServerException (com.cloud.exception.ManagementServerException)21 HashMap (java.util.HashMap)16 ServiceOffering (com.cloud.offering.ServiceOffering)15 DataCenter (com.cloud.dc.DataCenter)14 List (java.util.List)14 ActionEvent (com.cloud.event.ActionEvent)12 VirtualMachineMigrationException (com.cloud.exception.VirtualMachineMigrationException)12