CLOUDSTACK-4074: if hypervisor doesn't return size of volume/template, don't update it into db

This commit is contained in:
Edison Su 2013-08-05 16:21:15 -07:00 committed by Min Chen
parent ec89e23665
commit a8ee45de7c
3 changed files with 10 additions and 7 deletions

View File

@ -30,7 +30,7 @@ public class VolumeObjectTO implements DataTO {
private Volume.Type volumeType;
private DataStoreTO dataStore;
private String name;
private long size;
private Long size;
private String path;
private Long volumeId;
private String vmName;
@ -108,7 +108,7 @@ public class VolumeObjectTO implements DataTO {
return this.name;
}
public long getSize() {
public Long getSize() {
return this.size;
}

View File

@ -564,7 +564,9 @@ public class VolumeObject implements VolumeInfo {
VolumeVO vol = this.volumeDao.findById(this.getId());
VolumeObjectTO newVol = (VolumeObjectTO) cpyAnswer.getNewData();
vol.setPath(newVol.getPath());
vol.setSize(newVol.getSize());
if (newVol.getSize() != null) {
vol.setSize(newVol.getSize());
}
vol.setPoolId(this.getDataStore().getId());
volumeDao.update(vol.getId(), vol);
} else if (answer instanceof CreateObjectAnswer) {
@ -572,7 +574,9 @@ public class VolumeObject implements VolumeInfo {
VolumeObjectTO newVol = (VolumeObjectTO) createAnswer.getData();
VolumeVO vol = this.volumeDao.findById(this.getId());
vol.setPath(newVol.getPath());
vol.setSize(newVol.getSize());
if (newVol.getSize() != null) {
vol.setSize(newVol.getSize());
}
vol.setPoolId(this.getDataStore().getId());
volumeDao.update(vol.getId(), vol);
}

View File

@ -943,7 +943,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
TemplateObjectTO newTemplate = new TemplateObjectTO();
newTemplate.setPath(result.first());
newTemplate.setSize(result.second());
newTemplate.setSize(result.third());
newTemplate.setFormat(ImageFormat.OVA);
return new CopyCmdAnswer(newTemplate);
} catch (Throwable e) {
@ -1651,12 +1651,11 @@ public class VmwareStorageProcessor implements StorageProcessor {
}
DatastoreMO primaryDsMo = new DatastoreMO(hyperHost.getContext(), morPrimaryDs);
Long size = restoreVolumeFromSecStorage(hyperHost, primaryDsMo,
restoreVolumeFromSecStorage(hyperHost, primaryDsMo,
newVolumeName, secondaryStorageUrl, backupPath, backedUpSnapshotUuid);
VolumeObjectTO newVol = new VolumeObjectTO();
newVol.setPath(newVolumeName);
newVol.setSize(size);
return new CopyCmdAnswer(newVol);
} catch (Throwable e) {
if (e instanceof RemoteException) {