Search in sources :

Example 1 with SystemVmResponse

use of com.cloud.api.response.SystemVmResponse in project CloudStack-archive by CloudStack-extras.

the class RebootSystemVmCmd method execute.

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

Example 2 with SystemVmResponse

use of com.cloud.api.response.SystemVmResponse in project CloudStack-archive by CloudStack-extras.

the class UpgradeSystemVMCmd method execute.

@Override
public void execute() {
    UserContext.current().setEventDetails("Vm Id: " + getId());
    ServiceOffering serviceOffering = _configService.getServiceOffering(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());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Fail to reboot system vm");
    }
}
Also used : SystemVmResponse(com.cloud.api.response.SystemVmResponse) ServerApiException(com.cloud.api.ServerApiException) ServiceOffering(com.cloud.offering.ServiceOffering) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) VirtualMachine(com.cloud.vm.VirtualMachine)

Example 3 with SystemVmResponse

use of com.cloud.api.response.SystemVmResponse in project CloudStack-archive by CloudStack-extras.

the class ListSystemVMsCmd method execute.

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

Example 4 with SystemVmResponse

use of com.cloud.api.response.SystemVmResponse in project CloudStack-archive by CloudStack-extras.

the class DestroySystemVmCmd method execute.

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

Example 5 with SystemVmResponse

use of com.cloud.api.response.SystemVmResponse in project cosmic by MissionCriticalCloud.

the class ScaleSystemVMCmd method execute.

@Override
public void execute() {
    CallContext.current().setEventDetails("SystemVm Id: " + getId());
    final 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 (final ResourceUnavailableException ex) {
        s_logger.warn("Exception: ", ex);
        throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
    } catch (final ConcurrentOperationException ex) {
        s_logger.warn("Exception: ", ex);
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
    } catch (final ManagementServerException ex) {
        s_logger.warn("Exception: ", ex);
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
    } catch (final VirtualMachineMigrationException ex) {
        s_logger.warn("Exception: ", ex);
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
    }
    if (result != null) {
        final 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(com.cloud.api.response.SystemVmResponse) ServerApiException(com.cloud.api.ServerApiException) ManagementServerException(com.cloud.exception.ManagementServerException) ServiceOffering(com.cloud.offering.ServiceOffering) InvalidParameterValueException(com.cloud.utils.exception.InvalidParameterValueException) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) VirtualMachineMigrationException(com.cloud.exception.VirtualMachineMigrationException) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException) VirtualMachine(com.cloud.vm.VirtualMachine)

Aggregations

SystemVmResponse (com.cloud.api.response.SystemVmResponse)15 VirtualMachine (com.cloud.vm.VirtualMachine)14 ServerApiException (com.cloud.api.ServerApiException)12 ServiceOffering (com.cloud.offering.ServiceOffering)3 InvalidParameterValueException (com.cloud.utils.exception.InvalidParameterValueException)3 ListResponse (com.cloud.api.response.ListResponse)2 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 ArrayList (java.util.ArrayList)2 DataCenter (com.cloud.dc.DataCenter)1 HostPodVO (com.cloud.dc.HostPodVO)1 Vlan (com.cloud.dc.Vlan)1 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)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