CLOUDSTACK-1374 - When user uploads a volume using uploadVolume API command, only volume_host_ref table is getting updated with corresponding size of volume and "volumes" table, the size of volume still remains zero even ager the volume gets completely downloaded.

Signed-off-by: Nitin Mehta <nitin.mehta@citrix.com>
This commit is contained in:
Sanjay Tripathi 2013-02-26 10:43:19 +05:30 committed by Nitin Mehta
parent a1b33cadf5
commit 10236bee26
2 changed files with 21 additions and 9 deletions

View File

@ -343,8 +343,14 @@ public class DownloadListener implements Listener {
updateBuilder.setInstallPath(answer.getInstallPath());
updateBuilder.setSize(answer.getTemplateSize());
updateBuilder.setPhysicalSize(answer.getTemplatePhySicalSize());
volumeHostDao.update(getVolumeHostId(), updateBuilder);
// Update volume size in Volume table.
VolumeVO updateVolume = _volumeDao.createForUpdate();
updateVolume.setSize(answer.getTemplateSize());
_volumeDao.update(volume.getId(), updateVolume);
/*if (answer.getCheckSum() != null) {
VMTemplateVO templateDaoBuilder = _vmTemplateDao.createForUpdate();
templateDaoBuilder.setChecksum(answer.getCheckSum());

View File

@ -717,7 +717,7 @@ public class DownloadMonitorImpl extends ManagerBase implements DownloadMonitor
//Exists then don't download
if (volumeInfos.containsKey(volume.getId())){
TemplateInfo volInfo = volumeInfos.remove(volume.getId());
toBeDownloaded.remove(volumeHost);
toBeDownloaded.remove(volumeHost);
s_logger.info("Volume Sync found " + volume.getUuid() + " already in the volume host table");
if (volumeHost.getDownloadState() != Status.DOWNLOADED) {
volumeHost.setErrorString("");
@ -735,13 +735,19 @@ public class DownloadMonitorImpl extends ManagerBase implements DownloadMonitor
}
} else { // Put them in right status
volumeHost.setDownloadPercent(100);
volumeHost.setDownloadState(Status.DOWNLOADED);
volumeHost.setInstallPath(volInfo.getInstallPath());
volumeHost.setSize(volInfo.getSize());
volumeHost.setPhysicalSize(volInfo.getPhysicalSize());
volumeHost.setLastUpdated(new Date());
_volumeHostDao.update(volumeHost.getId(), volumeHost);
volumeHost.setDownloadPercent(100);
volumeHost.setDownloadState(Status.DOWNLOADED);
volumeHost.setInstallPath(volInfo.getInstallPath());
volumeHost.setSize(volInfo.getSize());
volumeHost.setPhysicalSize(volInfo.getPhysicalSize());
volumeHost.setLastUpdated(new Date());
_volumeHostDao.update(volumeHost.getId(), volumeHost);
if (volume.getSize() == 0) {
// Set volume size in volumes table
volume.setSize(volInfo.getSize());
_volumeDao.update(volumeHost.getVolumeId(), volume);
}
}
continue;
}