bug 5927: incremental checkin

This commit is contained in:
abhishek 2010-09-02 19:10:13 -07:00
parent 53e4db39ed
commit d3e323b9ec
5 changed files with 37 additions and 8 deletions

View File

@ -2189,4 +2189,5 @@ public interface ManagementServer {
Map<String, String> listCapabilities();
GuestOSCategoryVO getGuestOsCategory(Long guestOsId);
VolumeVO findVolumeByInstanceAndDeviceId(long instanceId, long deviceId);
}

View File

@ -60,6 +60,7 @@ public class DetachVolumeCmd extends BaseCmd {
Long volumeId = (Long) params.get(BaseCmd.Properties.ID.getName());
Long deviceId = (Long) params.get(BaseCmd.Properties.DEVICE_ID.getName());
Long instanceId = (Long) params.get(BaseCmd.Properties.VIRTUAL_MACHINE_ID.getName());
VolumeVO volume = null;
if((volumeId==null && (deviceId==null && instanceId==null)) || (volumeId!=null && (deviceId!=null || instanceId!=null)) || (volumeId==null && (deviceId==null || instanceId==null)))
{
@ -85,9 +86,18 @@ public class DetachVolumeCmd extends BaseCmd {
}
// Check that the volume ID is valid
VolumeVO volume = getManagementServer().findVolumeById(volumeId);
if (volume == null)
throw new ServerApiException(BaseCmd.PARAM_ERROR, "Unable to find volume with ID: " + volumeId);
if(volumeId != 0)
{
volume = getManagementServer().findVolumeById(volumeId);
if (volume == null)
throw new ServerApiException(BaseCmd.PARAM_ERROR, "Unable to find volume with ID: " + volumeId);
}
else
{
volume = getManagementServer().findVolumeByInstanceAndDeviceId(instanceId, deviceId);
if (volume == null)
throw new ServerApiException(BaseCmd.PARAM_ERROR, "Unable to find volume with ID: " + volumeId);
}
// If the account is not an admin, check that the volume is owned by the account that was passed in
if (!isAdmin) {

View File

@ -40,7 +40,7 @@ public class VolumeOperationParam {
// Used for Attach, Detach, and Delete
private long volumeId;
private long eventId;
private long deviceId;
private Long deviceId;
public VolumeOperationParam() {
}
@ -117,11 +117,11 @@ public class VolumeOperationParam {
return eventId;
}
public void setDeviceId(long deviceId) {
public void setDeviceId(Long deviceId) {
this.deviceId = deviceId;
}
public long getDeviceId() {
public Long getDeviceId() {
return deviceId;
}

View File

@ -1991,7 +1991,11 @@ public class ManagementServerImpl implements ManagementServer {
@Override
public long detachVolumeFromVMAsync(long volumeId, long deviceId, long instanceId) throws InvalidParameterValueException {
VolumeVO volume = _volumeDao.findById(volumeId);
VolumeVO volume = null;
if(volumeId!=0)
volume = _volumeDao.findById(volumeId);
else
volume = _volumeDao.findByInstanceAndDeviceId(instanceId, deviceId).get(0);
// Check that the volume is a data volume
if (volume.getVolumeType() != VolumeType.DATADISK) {
@ -5559,6 +5563,20 @@ public class ManagementServerImpl implements ManagementServer {
return null;
}
}
@Override
public VolumeVO findVolumeByInstanceAndDeviceId(long instanceId, long deviceId)
{
VolumeVO volume = _volumeDao.findByInstanceAndDeviceId(instanceId, deviceId).get(0);
if (volume != null && !volume.getDestroyed() && volume.getRemoved() == null)
{
return volume;
}
else
{
return null;
}
}
@Override

View File

@ -432,7 +432,7 @@ public class UserVmManagerImpl implements UserVmManager {
Long vmId = null;
if(instanceId!=0)
if(instanceId==0)
{
vmId = volume.getInstanceId();
}