@@ -0,0 +1,3005 @@
+package com.cloud.api.commands;%0A%0Aimport com.cloud.api.ApiConstants;%0Aimport com.cloud.api.BaseAsyncCmd;%0Aimport com.cloud.api.BaseCmd;%0Aimport com.cloud.api.Parameter;%0Aimport com.cloud.api.ServerApiException;%0Aimport com.cloud.api.BaseCmd.CommandType;%0Aimport com.cloud.api.response.VolumeResponse;%0Aimport com.cloud.event.EventTypes;%0Aimport com.cloud.exception.ConcurrentOperationException;%0Aimport com.cloud.exception.InsufficientCapacityException;%0Aimport com.cloud.exception.ResourceAllocationException;%0Aimport com.cloud.exception.ResourceUnavailableException;%0Aimport com.cloud.storage.Volume;%0Aimport com.cloud.user.Account;%0Aimport com.cloud.uservm.UserVm;%0A%0Apublic class MigrateVolumeCmd extends BaseAsyncCmd %7B%0A%09private static final String s_name = %22migratevolumeresponse%22;%0A%09%0A%09 /////////////////////////////////////////////////////%0A    //////////////// API parameters /////////////////////%0A    /////////////////////////////////////////////////////%0A%0A    @Parameter(name=ApiConstants.VOLUME_ID, type=CommandType.LONG, required=true, description=%22the ID of the volume%22)%0A    private Long volumeId;%0A%0A    @Parameter(name=ApiConstants.STORAGE_ID, type=CommandType.LONG, required=false, description=%22destination storage pool ID to migrate the volume to%22)%0A    private Long storageId;%0A    %0A    /////////////////////////////////////////////////////%0A    /////////////////// Accessors ///////////////////////%0A    /////////////////////////////////////////////////////%0A%0A    public Long getVolumeId() %7B%0A        return volumeId;%0A    %7D%0A%0A    public Long getStoragePoolId() %7B%0A    %09return storageId;%0A    %7D%0A    /////////////////////////////////////////////////////%0A    /////////////// API Implementation///////////////////%0A    /////////////////////////////////////////////////////%0A%0A    @Override%0A    public String getCommandName() %7B%0A        return s_name;%0A    %7D%0A    %0A    @Override%0A    public long getEntityOwnerId() %7B%0A    %09  Volume volume = _entityMgr.findById(Volume.class, getVolumeId());%0A          if (volume != null) %7B%0A              return volume.getAccountId();%0A          %7D%0A%0A          return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked%0A    %7D%0A%0A    @Override%0A    public String getEventType() %7B%0A        return EventTypes.EVENT_VOLUME_MIGRATE;%0A    %7D%0A%0A    @Override%0A    public String getEventDescription() %7B%0A        return  %22Attempting to migrate volume Id: %22 + getVolumeId() + %22 to storage pool Id: %22+ getStoragePoolId();%0A    %7D%0A    %0A    %0A    @Override%0A    public void execute()%7B%0A    %09Volume result;%0A%09%09try %7B%0A%09%09%09result = _storageService.migrateVolume(getVolumeId(), getStoragePoolId());%0A%09%09%09 if (result != null) %7B%0A%09             VolumeResponse response = _responseGenerator.createVolumeResponse(result);%0A%09             response.setResponseName(getCommandName());%0A%09             this.setResponseObject(response);%0A%09%09%09 %7D%0A%09%09%7D catch (ConcurrentOperationException e) %7B%0A%09%09%09throw new ServerApiException(BaseCmd.INTERNAL_ERROR, %22Failed to migrate volume: %22);%0A%09%09%7D%0A    %09%0A    %7D%0A%0A%7D%0A

add basic storage migration support