diff --git a/core/src/org/apache/cloudstack/storage/to/VolumeObjectTO.java b/core/src/org/apache/cloudstack/storage/to/VolumeObjectTO.java index 9f466ae4a10..5685fad59c4 100644 --- a/core/src/org/apache/cloudstack/storage/to/VolumeObjectTO.java +++ b/core/src/org/apache/cloudstack/storage/to/VolumeObjectTO.java @@ -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; } diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeObject.java b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeObject.java index de63d7d636f..404e3b24404 100644 --- a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeObject.java +++ b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeObject.java @@ -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); } diff --git a/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java b/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java index cc1a168937d..ffd192e6932 100644 --- a/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java +++ b/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java @@ -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) {