Search in sources :

Example 71 with VirtualMachine

use of com.cloud.vm.VirtualMachine in project cloudstack by apache.

the class StopSystemVmCmd method execute.

@Override
public void execute() throws ResourceUnavailableException, ConcurrentOperationException {
    CallContext.current().setEventDetails("Vm Id: " + this._uuidMgr.getUuid(VirtualMachine.class, getId()));
    VirtualMachine result = _mgr.stopSystemVM(this);
    if (result != null) {
        SystemVmResponse response = _responseGenerator.createSystemVmResponse(result);
        response.setResponseName(getCommandName());
        setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Fail to stop system vm");
    }
}
Also used : SystemVmResponse(org.apache.cloudstack.api.response.SystemVmResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) VirtualMachine(com.cloud.vm.VirtualMachine)

Example 72 with VirtualMachine

use of com.cloud.vm.VirtualMachine in project cloudstack by apache.

the class ListSystemVMsCmd method execute.

@Override
public void execute() {
    Pair<List<? extends VirtualMachine>, Integer> systemVMs = _mgr.searchForSystemVm(this);
    ListResponse<SystemVmResponse> response = new ListResponse<SystemVmResponse>();
    List<SystemVmResponse> vmResponses = new ArrayList<SystemVmResponse>();
    for (VirtualMachine systemVM : systemVMs.first()) {
        SystemVmResponse vmResponse = _responseGenerator.createSystemVmResponse(systemVM);
        vmResponse.setObjectName("systemvm");
        vmResponses.add(vmResponse);
    }
    response.setResponses(vmResponses, systemVMs.second());
    response.setResponseName(getCommandName());
    setResponseObject(response);
}
Also used : SystemVmResponse(org.apache.cloudstack.api.response.SystemVmResponse) ListResponse(org.apache.cloudstack.api.response.ListResponse) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) VirtualMachine(com.cloud.vm.VirtualMachine)

Example 73 with VirtualMachine

use of com.cloud.vm.VirtualMachine in project cloudstack by apache.

the class RebootSystemVmCmd method execute.

@Override
public void execute() {
    CallContext.current().setEventDetails("Vm Id: " + this._uuidMgr.getUuid(VirtualMachine.class, getId()));
    VirtualMachine result = _mgr.rebootSystemVM(this);
    if (result != null) {
        SystemVmResponse response = _responseGenerator.createSystemVmResponse(result);
        response.setResponseName(getCommandName());
        setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Fail to reboot system vm");
    }
}
Also used : SystemVmResponse(org.apache.cloudstack.api.response.SystemVmResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) VirtualMachine(com.cloud.vm.VirtualMachine)

Example 74 with VirtualMachine

use of com.cloud.vm.VirtualMachine in project cloudstack by apache.

the class StartSystemVMCmd method execute.

@Override
public void execute() {
    CallContext.current().setEventDetails("Vm Id: " + this._uuidMgr.getUuid(VirtualMachine.class, getId()));
    VirtualMachine instance = _mgr.startSystemVM(getId());
    if (instance != null) {
        SystemVmResponse response = _responseGenerator.createSystemVmResponse(instance);
        response.setResponseName(getCommandName());
        setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Fail to start system vm");
    }
}
Also used : SystemVmResponse(org.apache.cloudstack.api.response.SystemVmResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) VirtualMachine(com.cloud.vm.VirtualMachine)

Example 75 with VirtualMachine

use of com.cloud.vm.VirtualMachine in project cloudstack by apache.

the class UpgradeSystemVMCmd method execute.

@Override
public void execute() {
    CallContext.current().setEventDetails("Vm Id: " + this._uuidMgr.getUuid(VirtualMachine.class, getId()));
    ServiceOffering serviceOffering = _entityMgr.findById(ServiceOffering.class, serviceOfferingId);
    if (serviceOffering == null) {
        throw new InvalidParameterValueException("Unable to find service offering: " + serviceOfferingId);
    }
    VirtualMachine result = _mgr.upgradeSystemVM(this);
    if (result != null) {
        SystemVmResponse response = _responseGenerator.createSystemVmResponse(result);
        response.setResponseName(getCommandName());
        setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Fail to reboot system vm");
    }
}
Also used : SystemVmResponse(org.apache.cloudstack.api.response.SystemVmResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) ServiceOffering(com.cloud.offering.ServiceOffering) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) VirtualMachine(com.cloud.vm.VirtualMachine)

Aggregations

VirtualMachine (com.cloud.vm.VirtualMachine)141 HostVO (com.cloud.host.HostVO)38 ArrayList (java.util.ArrayList)35 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)26 HashMap (java.util.HashMap)25 List (java.util.List)23 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)21 VMInstanceVO (com.cloud.vm.VMInstanceVO)20 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)19 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)19 DataCenter (com.cloud.dc.DataCenter)17 Host (com.cloud.host.Host)17 ServiceOffering (com.cloud.offering.ServiceOffering)17 Test (org.junit.Test)17 ServerApiException (com.cloud.api.ServerApiException)16 SystemVmResponse (com.cloud.api.response.SystemVmResponse)14 InvalidParameterValueException (com.cloud.utils.exception.InvalidParameterValueException)14 OperationTimedoutException (com.cloud.exception.OperationTimedoutException)13 Account (com.cloud.user.Account)13 UserVm (com.cloud.uservm.UserVm)13