public static VMTemplateVO findTemplateById(Long templateId) { VMTemplateVO template = s_templateDao.findByIdIncludingRemoved(templateId); if (template != null) { Map<String, String> details = s_templateDetailsDao.listDetailsKeyPairs(templateId); if (details != null && !details.isEmpty()) { template.setDetails(details); } } return template; }
private boolean updateUserDataInternal(UserVm vm) throws ResourceUnavailableException, InsufficientCapacityException { VMTemplateVO template = _templateDao.findByIdIncludingRemoved(vm.getTemplateId()); List<? extends Nic> nics = _nicDao.listByVmId(vm.getId()); if (nics == null || nics.isEmpty()) { s_logger.error("unable to find any nics for vm " + vm.getUuid()); return false; } boolean userDataApplied = false; for (Nic nic : nics) { userDataApplied |= applyUserData(template.getHypervisorType(), vm, nic); } return userDataApplied; }
@Override public List<VMTemplateStoragePoolVO> getUnusedTemplatesInPool(StoragePoolVO pool) { List<VMTemplateStoragePoolVO> unusedTemplatesInPool = new ArrayList<VMTemplateStoragePoolVO>(); List<VMTemplateStoragePoolVO> allTemplatesInPool = _tmpltPoolDao.listByPoolId(pool.getId()); for (VMTemplateStoragePoolVO templatePoolVO : allTemplatesInPool) { VMTemplateVO template = _tmpltDao.findByIdIncludingRemoved(templatePoolVO.getTemplateId()); // If this is a routing template, consider it in use if (template.getTemplateType() == TemplateType.SYSTEM) { continue; } // If the template is not yet downloaded to the pool, consider it in // use if (templatePoolVO.getDownloadState() != Status.DOWNLOADED) { continue; } if (template.getFormat() != ImageFormat.ISO && !_volumeDao.isAnyVolumeActivelyUsingTemplateOnPool(template.getId(), pool.getId())) { unusedTemplatesInPool.add(templatePoolVO); } } return unusedTemplatesInPool; }
@Override public boolean templateIsDeleteable(VMTemplateHostVO templateHostRef) { VMTemplateVO template = _tmpltDao.findByIdIncludingRemoved(templateHostRef.getTemplateId()); long templateId = template.getId(); HostVO secondaryStorageHost = _hostDao.findById(templateHostRef.getHostId());
VMTemplateVO template = _templateDao.findByIdIncludingRemoved(vmInstance.getTemplateId()); if (template.isEnablePassword()) { Nic defaultNic = _networkModel.getDefaultNic(vmId);
/** * Storage plug-ins for managed storage can be designed in such a way as to store a template on the primary storage once and * make use of it via storage-side cloning. * * This method determines how many more bytes it will need for the template (if the template is already stored on the primary storage, * then the answer is 0). */ private long getAskingSizeForTemplateBasedOnClusterAndStoragePool(Long templateId, Long clusterId, StoragePoolVO storagePoolVO) { if (templateId == null || clusterId == null || storagePoolVO == null || !storagePoolVO.isManaged()) { return 0; } VMTemplateVO tmpl = _templateDao.findByIdIncludingRemoved(templateId); if (tmpl == null || ImageFormat.ISO.equals(tmpl.getFormat())) { return 0; } HypervisorType hypervisorType = tmpl.getHypervisorType(); // The getSupportsResigning method is applicable for XenServer as a UUID-resigning patch may or may not be installed on those hypervisor hosts. if (_clusterDao.getSupportsResigning(clusterId) || HypervisorType.VMware.equals(hypervisorType) || HypervisorType.KVM.equals(hypervisorType)) { return getBytesRequiredForTemplate(tmpl, storagePoolVO); } return 0; }
@Override public boolean accept(final NetworkTopologyVisitor visitor, final VirtualRouter router) throws ResourceUnavailableException { _router = router; UserVmDao userVmDao = visitor.getVirtualNetworkApplianceFactory().getUserVmDao(); _userVM = userVmDao.findById(_profile.getVirtualMachine().getId()); userVmDao.loadDetails(_userVM); NicDao nicDao = visitor.getVirtualNetworkApplianceFactory().getNicDao(); _nicVo = nicDao.findById(_nic.getId()); // for basic zone, send vm data/password information only to the router in the same pod VMTemplateDao templateDao = visitor.getVirtualNetworkApplianceFactory().getTemplateDao(); _template = templateDao.findByIdIncludingRemoved(_profile.getTemplateId()); return visitor.visit(this); }
VMInstanceVO vmInstance = _vmDao.findById(vmId); VMTemplateVO template = _templateDao.findByIdIncludingRemoved(vmInstance.getTemplateId()); Nic defaultNic = _networkModel.getDefaultNic(vmId); if (defaultNic == null) {
VMTemplateVO tmpl = _templateDao.findByIdIncludingRemoved(volume.getTemplateId());
VMTemplateVO template = _templateDao.findByIdIncludingRemoved(vm.getTemplateId()); if (template.isEnablePassword()) {
VMTemplateVO template = _templateDao.findByIdIncludingRemoved(userVm.getTemplateId()); if (template == null || !template.isEnablePassword()) { throw new InvalidParameterValueException("Fail to reset password for the virtual machine, the template is not password enabled");
template = _templateDao.findByIdIncludingRemoved(templateId); // Done for backward compatibility - Bug-5221 if (template == null) { throw new InvalidParameterValueException("Please specify a valid template ID.");
_vmDao.loadDetails(vm); template = _templateDao.findByIdIncludingRemoved(vm.getTemplateId());
VMTemplateVO template = _templateDao.findByIdIncludingRemoved(userVm.getTemplateId());