bug CS-14945:

UploadVolume API is async now with the guidance for all the new apis added in 3.0.x need to be async. Though the success/failure wont be available through the queryAsync job which will report only the initial validation success or failure. The success or failure and the progress will all be available through listVolumes api.
This commit is contained in:
Nitin Mehta 2012-05-21 14:18:02 +05:30
parent d77af1a96c
commit a4adc25295
2 changed files with 17 additions and 8 deletions

View File

@ -14,8 +14,9 @@ package com.cloud.api.commands;
import org.apache.log4j.Logger;
import com.cloud.api.ApiConstants;
import com.cloud.api.BaseCmd;
import com.cloud.api.ApiConstants;
import com.cloud.api.BaseAsyncCmd;
import com.cloud.api.BaseCmd;
import com.cloud.api.IdentityMapper;
import com.cloud.api.Implementation;
import com.cloud.api.Parameter;
@ -30,7 +31,7 @@ import com.cloud.storage.Volume;
import com.cloud.user.UserContext;
@Implementation(description="Uploads a data disk.", responseObject=VolumeResponse.class)
public class UploadVolumeCmd extends BaseCmd {
public class UploadVolumeCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(UploadVolumeCmd.class.getName());
private static final String s_name = "uploadvolumeresponse";
@ -128,4 +129,14 @@ public class UploadVolumeCmd extends BaseCmd {
return accountId;
}
@Override
public String getEventDescription() {
return "uploading volume: " + getVolumeName() + " in the zone " + getZoneId();
}
@Override
public String getEventType() {
return EventTypes.EVENT_VOLUME_UPLOAD;
}
}

View File

@ -1686,13 +1686,12 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag
/*
* Just allocate a volume in the database, don't send the createvolume cmd to hypervisor. The volume will be finally
* created
* Upload the volume to secondary storage.
*
*/
@Override
@DB
@ActionEvent(eventType = EventTypes.EVENT_VOLUME_UPLOAD, eventDescription = "creating volume", create = true)
@ActionEvent(eventType = EventTypes.EVENT_VOLUME_UPLOAD, eventDescription = "uploading volume", async = true)
public VolumeVO uploadVolume(UploadVolumeCmd cmd) throws ResourceAllocationException{
Account caller = UserContext.current().getCaller();
long ownerId = cmd.getEntityOwnerId();
@ -1704,8 +1703,7 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag
validateVolume(caller, ownerId, zoneId, volumeName, url, format);
VolumeVO volume = persistVolume(caller, ownerId, zoneId, volumeName, url, cmd.getFormat());
_downloadMonitor.downloadVolumeToStorage(volume, zoneId, url, cmd.getChecksum(), ImageFormat.valueOf(format.toUpperCase()));
return volume;
return volume;
}
private boolean validateVolume(Account caller, long ownerId, Long zoneId, String volumeName, String url, String format) throws ResourceAllocationException{