CLOUDSTACK-7754: Templates source_template_id is null when it is created from Snapshot with its corresponding volume removed. Fix it by searching for volumes including removed.

(cherry picked from commit 287ff83552)
This commit is contained in:
Nitin Mehta 2014-10-20 16:49:48 -07:00
parent 3db112f75c
commit a72580def0
1 changed files with 3 additions and 2 deletions

View File

@ -1410,9 +1410,10 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
privateTemplate = _tmpltDao.findById(templateId);
if (snapshotId != null) {
//getting the prent volume
//getting the parent volume
long parentVolumeId = _snapshotDao.findById(snapshotId).getVolumeId();
VolumeVO parentVolume = _volumeDao.findById(parentVolumeId);
//Volume can be removed
VolumeVO parentVolume = _volumeDao.findByIdIncludingRemoved(parentVolumeId);
if (parentVolume != null && parentVolume.getIsoId() != null && parentVolume.getIsoId() != 0) {
privateTemplate.setSourceTemplateId(parentVolume.getIsoId());