use of org.apache.cloudstack.api.ServerApiException in project cloudstack by apache.
the class DestroyVMCmdByAdmin method execute.
@Override
public void execute() throws ResourceUnavailableException, ConcurrentOperationException {
CallContext.current().setEventDetails("Vm Id: " + getId());
UserVm result = _userVmService.destroyVm(this);
UserVmResponse response = new UserVmResponse();
if (result != null) {
List<UserVmResponse> responses = _responseGenerator.createUserVmResponse(ResponseView.Full, "virtualmachine", result);
if (responses != null && !responses.isEmpty()) {
response = responses.get(0);
}
response.setResponseName("virtualmachine");
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to destroy vm");
}
}
use of org.apache.cloudstack.api.ServerApiException in project cloudstack by apache.
the class UpdateVPCCmdByAdmin method execute.
@Override
public void execute() {
Vpc result = _vpcService.updateVpc(getId(), getVpcName(), getDisplayText(), getCustomId(), getDisplayVpc());
if (result != null) {
VpcResponse response = _responseGenerator.createVpcResponse(ResponseView.Full, result);
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update VPC");
}
}
use of org.apache.cloudstack.api.ServerApiException in project cloudstack by apache.
the class CreateVolumeCmdByAdmin method execute.
@Override
public void execute() {
CallContext.current().setEventDetails("Volume Id: " + getEntityId() + ((getSnapshotId() == null) ? "" : " from snapshot: " + getSnapshotId()));
Volume volume = _volumeService.createVolume(this);
if (volume != null) {
VolumeResponse response = _responseGenerator.createVolumeResponse(ResponseView.Full, volume);
//FIXME - have to be moved to ApiResponseHelper
if (getSnapshotId() != null) {
Snapshot snap = _entityMgr.findById(Snapshot.class, getSnapshotId());
if (snap != null) {
// if the volume was
response.setSnapshotId(snap.getUuid());
// created from a
// snapshot,
// snapshotId will
// be set so we pass
// it back in the
// response
}
}
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create a volume");
}
}
use of org.apache.cloudstack.api.ServerApiException in project cloudstack by apache.
the class MigrateVolumeCmdByAdmin method execute.
@Override
public void execute() {
Volume result;
result = _volumeService.migrateVolume(this);
if (result != null) {
VolumeResponse response = _responseGenerator.createVolumeResponse(ResponseView.Full, result);
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to migrate volume");
}
}
use of org.apache.cloudstack.api.ServerApiException in project cloudstack by apache.
the class UpdateVolumeCmdByAdmin method execute.
@Override
public void execute() {
CallContext.current().setEventDetails("Volume Id: " + getId());
Volume result = _volumeService.updateVolume(getId(), getPath(), getState(), getStorageId(), getDisplayVolume(), getCustomId(), getEntityOwnerId(), getChainInfo());
if (result != null) {
VolumeResponse response = _responseGenerator.createVolumeResponse(ResponseView.Full, result);
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update volume");
}
}
Aggregations