use of com.cloud.uservm.UserVm in project CloudStack-archive by CloudStack-extras.
the class AttachIsoCmd method execute.
@Override
public void execute() {
UserContext.current().setEventDetails("Vm Id: " + getVirtualMachineId() + " ISO Id: " + getId());
boolean result = _templateService.attachIso(id, virtualMachineId);
if (result) {
UserVm userVm = _responseGenerator.findUserVmById(virtualMachineId);
if (userVm != null) {
UserVmResponse response = _responseGenerator.createUserVmResponse("virtualmachine", userVm).get(0);
response.setResponseName(DeployVMCmd.getResultObjectName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to attach iso");
}
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to attach iso");
}
}
use of com.cloud.uservm.UserVm in project CloudStack-archive by CloudStack-extras.
the class RebootVMCmd method execute.
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException {
UserContext.current().setEventDetails("Vm Id: " + getId());
UserVm result;
if (_userVmService.getHypervisorTypeOfUserVM(getId()) == HypervisorType.BareMetal) {
result = _bareMetalVmService.rebootVirtualMachine(this);
} else {
result = _userVmService.rebootVirtualMachine(this);
}
if (result != null) {
UserVmResponse response = _responseGenerator.createUserVmResponse("virtualmachine", result).get(0);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to reboot vm instance");
}
}
use of com.cloud.uservm.UserVm in project CloudStack-archive by CloudStack-extras.
the class RecoverVMCmd method execute.
@Override
public void execute() throws ResourceAllocationException {
UserVm result = _userVmService.recoverVirtualMachine(this);
if (result != null) {
UserVmResponse recoverVmResponse = _responseGenerator.createUserVmResponse("virtualmachine", result).get(0);
recoverVmResponse.setResponseName(getCommandName());
this.setResponseObject(recoverVmResponse);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to recover vm");
}
}
use of com.cloud.uservm.UserVm in project CloudStack-archive by CloudStack-extras.
the class UpdateVMCmd method execute.
@Override
public void execute() {
UserContext.current().setEventDetails("Vm Id: " + getId());
UserVm result = _userVmService.updateVirtualMachine(this);
if (result != null) {
UserVmResponse response = _responseGenerator.createUserVmResponse("virtualmachine", result).get(0);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update vm");
}
}
use of com.cloud.uservm.UserVm in project CloudStack-archive by CloudStack-extras.
the class UpgradeVMCmd 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);
}
UserVm result = _userVmService.upgradeVirtualMachine(this);
if (result != null) {
UserVmResponse response = _responseGenerator.createUserVmResponse("virtualmachine", result).get(0);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to upgrade vm");
}
}
Aggregations