use of com.cloud.storage.Volume in project cloudstack by apache.
the class ResizeVolumeCmdByAdmin method execute.
@Override
public void execute() throws ResourceAllocationException {
Volume volume = null;
try {
CallContext.current().setEventDetails("Volume Id: " + getEntityId() + " to size " + getSize() + "G");
volume = _volumeService.resizeVolume(this);
} catch (InvalidParameterValueException ex) {
s_logger.info(ex.getMessage());
throw new ServerApiException(ApiErrorCode.UNSUPPORTED_ACTION_ERROR, ex.getMessage());
}
if (volume != null) {
VolumeResponse response = _responseGenerator.createVolumeResponse(ResponseView.Full, volume);
//FIXME - have to be moved to ApiResponseHelper
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to resize volume");
}
}
use of com.cloud.storage.Volume in project cloudstack by apache.
the class ResizeVolumeCmd method getEntityOwnerId.
@Override
public long getEntityOwnerId() {
Volume volume = _entityMgr.findById(Volume.class, getEntityId());
if (volume == null) {
throw new InvalidParameterValueException("Unable to find volume by id=" + id);
}
Account account = _accountService.getAccount(volume.getAccountId());
//Can resize volumes for enabled projects/accounts only
if (account.getType() == Account.ACCOUNT_TYPE_PROJECT) {
Project project = _projectService.findByProjectAccountId(volume.getAccountId());
if (project.getState() != Project.State.Active) {
throw new PermissionDeniedException("Can't add resources to project id=" + project.getId() + " in state=" + project.getState() + " as it's no longer active");
}
} else if (account.getState() == Account.State.disabled) {
throw new PermissionDeniedException("The owner of volume " + id + " is disabled: " + account);
}
return volume.getAccountId();
}
use of com.cloud.storage.Volume in project cloudstack by apache.
the class UpdateVolumeCmd 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.Restricted, result);
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update volume");
}
}
use of com.cloud.storage.Volume in project cloudstack by apache.
the class AttachVolumeCmd method execute.
@Override
public void execute() {
CallContext.current().setEventDetails("Volume Id: " + getId() + " VmId: " + getVirtualMachineId());
Volume result = _volumeService.attachVolumeToVM(this);
if (result != null) {
VolumeResponse response = _responseGenerator.createVolumeResponse(ResponseView.Restricted, result);
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to attach volume");
}
}
use of com.cloud.storage.Volume in project cloudstack by apache.
the class CreateVolumeCmd method create.
@Override
public void create() throws ResourceAllocationException {
Volume volume = _volumeService.allocVolume(this);
if (volume != null) {
setEntityId(volume.getId());
setEntityUuid(volume.getUuid());
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create volume");
}
}
Aggregations