Search in sources :

Example 1 with SystemVmResponse

use of org.apache.cloudstack.api.response.SystemVmResponse in project cloudstack by apache.

the class DestroySystemVmCmd method execute.

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

Example 2 with SystemVmResponse

use of org.apache.cloudstack.api.response.SystemVmResponse 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)

Example 3 with SystemVmResponse

use of org.apache.cloudstack.api.response.SystemVmResponse 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 4 with SystemVmResponse

use of org.apache.cloudstack.api.response.SystemVmResponse 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 5 with SystemVmResponse

use of org.apache.cloudstack.api.response.SystemVmResponse in project cloudstack by apache.

the class ScaleSystemVMCmd method execute.

@Override
public void execute() {
    CallContext.current().setEventDetails("SystemVm 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 = null;
    try {
        result = _mgr.upgradeSystemVM(this);
    } catch (ResourceUnavailableException ex) {
        s_logger.warn("Exception: ", ex);
        throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
    } catch (ConcurrentOperationException ex) {
        s_logger.warn("Exception: ", ex);
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
    } catch (ManagementServerException ex) {
        s_logger.warn("Exception: ", ex);
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
    } catch (VirtualMachineMigrationException ex) {
        s_logger.warn("Exception: ", ex);
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
    }
    if (result != null) {
        SystemVmResponse response = _responseGenerator.createSystemVmResponse(result);
        response.setResponseName(getCommandName());
        setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to upgrade system vm");
    }
}
Also used : SystemVmResponse(org.apache.cloudstack.api.response.SystemVmResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) ManagementServerException(com.cloud.exception.ManagementServerException) ServiceOffering(com.cloud.offering.ServiceOffering) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) VirtualMachineMigrationException(com.cloud.exception.VirtualMachineMigrationException) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException) VirtualMachine(com.cloud.vm.VirtualMachine)

Aggregations

SystemVmResponse (org.apache.cloudstack.api.response.SystemVmResponse)10 VirtualMachine (com.cloud.vm.VirtualMachine)8 ServerApiException (org.apache.cloudstack.api.ServerApiException)8 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)4 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)2 ManagementServerException (com.cloud.exception.ManagementServerException)2 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)2 VirtualMachineMigrationException (com.cloud.exception.VirtualMachineMigrationException)2 Host (com.cloud.host.Host)2 ServiceOffering (com.cloud.offering.ServiceOffering)2 DataCenter (com.cloud.dc.DataCenter)1 HostPodVO (com.cloud.dc.HostPodVO)1 Vlan (com.cloud.dc.Vlan)1 GuestVlan (com.cloud.network.GuestVlan)1 IpAddress (com.cloud.network.IpAddress)1 Network (com.cloud.network.Network)1 PhysicalNetwork (com.cloud.network.PhysicalNetwork)1 NetworkOffering (com.cloud.offering.NetworkOffering)1 StoragePool (com.cloud.storage.StoragePool)1 VMTemplateVO (com.cloud.storage.VMTemplateVO)1