CLOUDSTACK-8312: Fix NPE regression, copy template can have NULL volume size

The copy command reply can have null size returned, so check and set values

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
Rohit Yadav 2015-03-20 17:25:52 +05:30
parent d70937aeb9
commit 53ca0b1861
3 changed files with 9 additions and 3 deletions

View File

@ -190,7 +190,9 @@ public class TemplateObject implements TemplateInfo {
TemplateObjectTO newTemplate = (TemplateObjectTO)cpyAnswer.getNewData();
VMTemplateStoragePoolVO templatePoolRef = templatePoolDao.findByPoolTemplate(getDataStore().getId(), getId());
templatePoolRef.setDownloadPercent(100);
templatePoolRef.setTemplateSize(newTemplate.getSize());
if (newTemplate.getSize() != null) {
templatePoolRef.setTemplateSize(newTemplate.getSize());
}
templatePoolRef.setDownloadState(Status.DOWNLOADED);
templatePoolRef.setLocalDownloadPath(newTemplate.getPath());
templatePoolRef.setInstallPath(newTemplate.getPath());

View File

@ -843,7 +843,9 @@ public class XenServerStorageProcessor implements StorageProcessor {
newVol.setUuid(uuidToReturn);
newVol.setPath(uuidToReturn);
newVol.setSize(physicalSize);
if (physicalSize != null) {
newVol.setSize(physicalSize);
}
newVol.setFormat(ImageFormat.VHD);
return new CopyCmdAnswer(newVol);

View File

@ -263,7 +263,9 @@ public class Xenserver625StorageProcessor extends XenServerStorageProcessor {
newVol.setUuid(uuidToReturn);
newVol.setPath(uuidToReturn);
newVol.setSize(physicalSize);
if (physicalSize != null) {
newVol.setSize(physicalSize);
}
newVol.setFormat(Storage.ImageFormat.VHD);
return new CopyCmdAnswer(newVol);