Search in sources :

Example 6 with VolumeResponse

use of org.apache.cloudstack.api.response.VolumeResponse in project cloudstack by apache.

the class UploadVolumeCmd method execute.

/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
    Volume volume = _volumeService.uploadVolume(this);
    if (volume != null) {
        VolumeResponse response = _responseGenerator.createVolumeResponse(ResponseView.Restricted, volume);
        response.setResponseName(getCommandName());
        setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to upload volume");
    }
}
Also used : VolumeResponse(org.apache.cloudstack.api.response.VolumeResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) Volume(com.cloud.storage.Volume)

Example 7 with VolumeResponse

use of org.apache.cloudstack.api.response.VolumeResponse in project cloudstack by apache.

the class DetachVolumeCmd method execute.

@Override
public void execute() {
    CallContext.current().setEventDetails("Volume Id: " + getId() + " VmId: " + getVirtualMachineId());
    Volume result = _volumeService.detachVolumeFromVM(this);
    if (result != null) {
        VolumeResponse response = _responseGenerator.createVolumeResponse(ResponseView.Restricted, result);
        response.setResponseName("volume");
        setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to detach volume");
    }
}
Also used : VolumeResponse(org.apache.cloudstack.api.response.VolumeResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) Volume(com.cloud.storage.Volume)

Example 8 with VolumeResponse

use of org.apache.cloudstack.api.response.VolumeResponse in project cloudstack by apache.

the class UploadVolumeCmdByAdmin method execute.

@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
    Volume volume = _volumeService.uploadVolume(this);
    if (volume != null) {
        VolumeResponse response = _responseGenerator.createVolumeResponse(ResponseView.Full, volume);
        response.setResponseName(getCommandName());
        setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to upload volume");
    }
}
Also used : VolumeResponse(org.apache.cloudstack.api.response.VolumeResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) Volume(com.cloud.storage.Volume)

Example 9 with VolumeResponse

use of org.apache.cloudstack.api.response.VolumeResponse in project cloudstack by apache.

the class AttachVolumeCmdByAdmin 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.Full, result);
        response.setResponseName(getCommandName());
        setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to attach volume");
    }
}
Also used : VolumeResponse(org.apache.cloudstack.api.response.VolumeResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) Volume(com.cloud.storage.Volume)

Example 10 with VolumeResponse

use of org.apache.cloudstack.api.response.VolumeResponse in project cloudstack by apache.

the class DetachVolumeCmdByAdmin method execute.

@Override
public void execute() {
    CallContext.current().setEventDetails("Volume Id: " + getId() + " VmId: " + getVirtualMachineId());
    Volume result = _volumeService.detachVolumeFromVM(this);
    if (result != null) {
        VolumeResponse response = _responseGenerator.createVolumeResponse(ResponseView.Full, result);
        response.setResponseName("volume");
        setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to detach volume");
    }
}
Also used : VolumeResponse(org.apache.cloudstack.api.response.VolumeResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) Volume(com.cloud.storage.Volume)

Aggregations

VolumeResponse (org.apache.cloudstack.api.response.VolumeResponse)18 ServerApiException (org.apache.cloudstack.api.ServerApiException)15 Volume (com.cloud.storage.Volume)14 ArrayList (java.util.ArrayList)3 VolumeJoinVO (com.cloud.api.query.vo.VolumeJoinVO)2 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)2 Snapshot (com.cloud.storage.Snapshot)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Hashtable (java.util.Hashtable)1 List (java.util.List)1 ResponseView (org.apache.cloudstack.api.ResponseObject.ResponseView)1 ListVolumesCmdByAdmin (org.apache.cloudstack.api.command.admin.volume.ListVolumesCmdByAdmin)1 ListResponse (org.apache.cloudstack.api.response.ListResponse)1 DataStore (org.apache.cloudstack.engine.subsystem.api.storage.DataStore)1 DataStoreDriver (org.apache.cloudstack.engine.subsystem.api.storage.DataStoreDriver)1 VolumeMetricsResponse (org.apache.cloudstack.response.VolumeMetricsResponse)1