use of com.cloud.api.response.VolumeResponse in project CloudStack-archive by CloudStack-extras.
the class AttachVolumeCmd method execute.
@Override
public void execute() {
UserContext.current().setEventDetails("Volume Id: " + getId() + " VmId: " + getVirtualMachineId());
Volume result = _userVmService.attachVolumeToVM(this);
if (result != null) {
VolumeResponse response = _responseGenerator.createVolumeResponse(result);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to attach volume");
}
}
use of com.cloud.api.response.VolumeResponse in project CloudStack-archive by CloudStack-extras.
the class MigrateVolumeCmd method execute.
@Override
public void execute() {
Volume result;
try {
result = _storageService.migrateVolume(getVolumeId(), getStoragePoolId());
if (result != null) {
VolumeResponse response = _responseGenerator.createVolumeResponse(result);
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
} catch (ConcurrentOperationException e) {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to migrate volume: ");
}
}
use of com.cloud.api.response.VolumeResponse in project CloudStack-archive by CloudStack-extras.
the class ListVolumesCmd method execute.
@Override
public void execute() {
List<? extends Volume> volumes = _storageService.searchForVolumes(this);
ListResponse<VolumeResponse> response = new ListResponse<VolumeResponse>();
List<VolumeResponse> volResponses = new ArrayList<VolumeResponse>();
for (Volume volume : volumes) {
VolumeResponse volResponse = _responseGenerator.createVolumeResponse(volume);
volResponse.setObjectName("volume");
volResponses.add(volResponse);
}
response.setResponses(volResponses);
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
use of com.cloud.api.response.VolumeResponse in project CloudStack-archive by CloudStack-extras.
the class DetachVolumeCmd method execute.
@Override
public void execute() {
UserContext.current().setEventDetails("Volume Id: " + getId() + " VmId: " + getVirtualMachineId());
Volume result = _userVmService.detachVolumeFromVM(this);
if (result != null) {
VolumeResponse response = _responseGenerator.createVolumeResponse(result);
response.setResponseName("volume");
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to detach volume");
}
}
use of com.cloud.api.response.VolumeResponse in project CloudStack-archive by CloudStack-extras.
the class CreateVolumeCmd method execute.
@Override
public void execute() {
UserContext.current().setEventDetails("Volume Id: " + getEntityId() + ((getSnapshotId() == null) ? "" : " from snapshot: " + getSnapshotId()));
Volume volume = _storageService.createVolume(this);
if (volume != null) {
VolumeResponse response = _responseGenerator.createVolumeResponse(volume);
//FIXME - have to be moved to ApiResponseHelper
// if the volume was created from a snapshot, snapshotId will be set so we pass it back in the response
response.setSnapshotId(getSnapshotId());
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create a volume");
}
}
Aggregations