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());
}
}
use of com.cloud.api.ServerApiException in project CloudStack-archive by CloudStack-extras.
the class ExtractIsoCmd method execute.
@Override
public void execute() {
try {
UserContext.current().setEventDetails(getEventDescription());
Long uploadId = _templateService.extract(this);
if (uploadId != null) {
ExtractResponse response = _responseGenerator.createExtractResponse(uploadId, id, zoneId, getEntityOwnerId(), mode);
response.setResponseName(getCommandName());
response.setObjectName("iso");
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to extract iso");
}
} catch (InternalErrorException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
}
}
use of com.cloud.api.ServerApiException in project CloudStack-archive by CloudStack-extras.
the class ExtractVolumeCmd method execute.
@Override
public void execute() {
try {
UserContext.current().setEventDetails("Volume Id: " + getId());
Long uploadId = _mgr.extractVolume(this);
if (uploadId != null) {
Upload uploadInfo = _entityMgr.findById(Upload.class, uploadId);
ExtractResponse response = new ExtractResponse();
response.setResponseName(getCommandName());
response.setObjectName("volume");
response.setIdentityTableName("volumes");
response.setId(id);
response.setName(_entityMgr.findById(Volume.class, id).getName());
response.setZoneId(zoneId);
response.setZoneName(_entityMgr.findById(DataCenter.class, zoneId).getName());
response.setMode(mode);
response.setUploadId(uploadId);
response.setState(uploadInfo.getUploadState().toString());
response.setAccountId(getEntityOwnerId());
response.setUrl(uploadInfo.getUploadUrl());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to extract volume");
}
} catch (URISyntaxException ex) {
s_logger.info(ex);
throw new ServerApiException(BaseCmd.PARAM_ERROR, ex.getMessage());
}
}
Aggregations