bug 10455: CreatePrivateTemplate - If the volume's template id is null and it is ROOT (meaning that the vm was created out of a blank template) then take the source template id from the user vm table.

Status 10455: resolved fixed
This commit is contained in:
Nitin 2011-06-27 17:20:42 +05:30
parent a295e381a7
commit 5810b838ed
1 changed files with 5 additions and 1 deletions

View File

@ -160,6 +160,7 @@ import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
import com.cloud.storage.VMTemplateVO;
import com.cloud.storage.VMTemplateZoneVO;
import com.cloud.storage.Volume;
import com.cloud.storage.Volume.Type;
import com.cloud.storage.VolumeVO;
import com.cloud.storage.dao.DiskOfferingDao;
import com.cloud.storage.dao.GuestOSCategoryDao;
@ -1402,7 +1403,10 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
if (volume != null) {
VMTemplateVO template = ApiDBUtils.findTemplateById(volume.getTemplateId());
isExtractable = template != null && template.isExtractable() && template.getTemplateType() != Storage.TemplateType.SYSTEM;
sourceTemplateId = template.getId();
if (template == null && volume.getVolumeType() == Type.ROOT){ //vm created out of blank template
UserVm userVm = ApiDBUtils.findUserVmById(volume.getInstanceId());
sourceTemplateId = userVm.getIsoId();
}
}
privateTemplate = new VMTemplateVO(nextTemplateId, uniqueName, name, ImageFormat.RAW, isPublic, featured, isExtractable, TemplateType.USER, null, null, requiresHvmValue, bitsValue, accountId,
null, description, passwordEnabledValue, guestOS.getId(), true, hyperType);