use of com.cloud.api.ServerApiException in project CloudStack-archive by CloudStack-extras.
the class DestroyVMCmd method execute.
@Override
public void execute() throws ResourceUnavailableException, ConcurrentOperationException {
UserContext.current().setEventDetails("Vm Id: " + getId());
UserVm result;
if (_userVmService.getHypervisorTypeOfUserVM(getId()) == HypervisorType.BareMetal) {
result = _bareMetalVmService.destroyVm(this);
} else {
result = _userVmService.destroyVm(this);
}
if (result != null) {
UserVmResponse response = _responseGenerator.createUserVmResponse("virtualmachine", result).get(0);
response.setResponseName("virtualmachine");
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to destroy vm");
}
}
use of com.cloud.api.ServerApiException in project CloudStack-archive by CloudStack-extras.
the class DetachIsoCmd method execute.
@Override
public void execute() {
boolean result = _templateService.detachIso(virtualMachineId);
if (result) {
UserVm userVm = _entityMgr.findById(UserVm.class, virtualMachineId);
UserVmResponse response = _responseGenerator.createUserVmResponse("virtualmachine", userVm).get(0);
response.setResponseName(DeployVMCmd.getResultObjectName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to detach iso");
}
}
use of com.cloud.api.ServerApiException in project CloudStack-archive by CloudStack-extras.
the class DisassociateIPAddrCmd method execute.
@Override
public void execute() throws InsufficientAddressCapacityException {
UserContext.current().setEventDetails("Ip Id: " + getIpAddressId());
boolean result = _networkService.disassociateIpAddress(id);
if (result) {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to disassociate ip address");
}
}
use of com.cloud.api.ServerApiException in project CloudStack-archive by CloudStack-extras.
the class EnableAccountCmd method execute.
@Override
public void execute() {
Account result = _accountService.enableAccount(getAccountName(), getDomainId(), getId());
if (result != null) {
AccountResponse response = _responseGenerator.createAccountResponse(result);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to enable account");
}
}
use of com.cloud.api.ServerApiException in project CloudStack-archive by CloudStack-extras.
the class EnableStaticNatCmd method execute.
@Override
public void execute() throws ResourceUnavailableException {
try {
boolean result = _rulesService.enableStaticNat(ipAddressId, virtualMachineId, false);
if (result) {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to enable static nat");
}
} catch (NetworkRuleConflictException ex) {
s_logger.info("Network rule conflict: " + ex.getMessage());
s_logger.trace("Network Rule Conflict: ", ex);
throw new ServerApiException(BaseCmd.NETWORK_RULE_CONFLICT_ERROR, ex.getMessage());
}
}
Aggregations