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>
(cherry picked from commit 53ca0b1861c743caf61ec04f776c87eac334f185)
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 62a733e8cf
commit 694b723899
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

@ -877,7 +877,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

@ -292,7 +292,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);