use of com.cloud.vm.VirtualMachine in project cosmic by MissionCriticalCloud.
the class StartSystemVMCmd method execute.
@Override
public void execute() {
CallContext.current().setEventDetails("Vm Id: " + getId());
final VirtualMachine instance = _mgr.startSystemVM(getId());
if (instance != null) {
final SystemVmResponse response = _responseGenerator.createSystemVmResponse(instance);
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Fail to start system vm");
}
}
use of com.cloud.vm.VirtualMachine in project cosmic by MissionCriticalCloud.
the class StopSystemVmCmd method execute.
@Override
public void execute() throws ResourceUnavailableException, ConcurrentOperationException {
CallContext.current().setEventDetails("Vm Id: " + getId());
final VirtualMachine result = _mgr.stopSystemVM(this);
if (result != null) {
final SystemVmResponse response = _responseGenerator.createSystemVmResponse(result);
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Fail to stop system vm");
}
}
use of com.cloud.vm.VirtualMachine in project cosmic by MissionCriticalCloud.
the class DestroySystemVmCmd method execute.
@Override
public void execute() {
CallContext.current().setEventDetails("Vm Id: " + getId());
final VirtualMachine instance = _mgr.destroySystemVM(this);
if (instance != null) {
final SystemVmResponse response = _responseGenerator.createSystemVmResponse(instance);
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Fail to destroy system vm");
}
}
use of com.cloud.vm.VirtualMachine in project cosmic by MissionCriticalCloud.
the class MigrateSystemVMCmd method execute.
@Override
public void execute() {
final Host destinationHost = _resourceService.getHost(getHostId());
if (destinationHost == null) {
throw new InvalidParameterValueException("Unable to find the host to migrate the VM, host id=" + getHostId());
}
try {
CallContext.current().setEventDetails("VM Id: " + getVirtualMachineId() + " to host Id: " + getHostId());
// FIXME : Should not be calling UserVmService to migrate all types of VMs - need a generic VM layer
final VirtualMachine migratedVm = _userVmService.migrateVirtualMachine(getVirtualMachineId(), destinationHost);
if (migratedVm != null) {
// return the generic system VM instance response
final SystemVmResponse response = _responseGenerator.createSystemVmResponse(migratedVm);
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to migrate the system vm");
}
} catch (final ResourceUnavailableException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
} catch (final ConcurrentOperationException e) {
s_logger.warn("Exception: ", e);
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
} catch (final ManagementServerException e) {
s_logger.warn("Exception: ", e);
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
} catch (final VirtualMachineMigrationException e) {
s_logger.warn("Exception: ", e);
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
}
}
use of com.cloud.vm.VirtualMachine in project cosmic by MissionCriticalCloud.
the class RebootSystemVmCmd method execute.
@Override
public void execute() {
CallContext.current().setEventDetails("Vm Id: " + getId());
final VirtualMachine result = _mgr.rebootSystemVM(this);
if (result != null) {
final SystemVmResponse response = _responseGenerator.createSystemVmResponse(result);
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Fail to reboot system vm");
}
}
Aggregations