Source:
protected boolean canDoAction() { if (getVmTemplate() == null) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_TEMPLATE_DOES_NOT_EXIST); } if (getTemplateDisks() != null && !getTemplateDisks().isEmpty()) { ensureDomainMap(getTemplateDisks(), getParameters().getStorageDomainId()); ImagesHandler.fillImagesMapBasedOnTemplate(getVmTemplate(), imageFromSourceDomainMap, null, true); if (getVmTemplate().getDiskMap().values().size() != imageFromSourceDomainMap.size()) { log.errorFormat("Can't find any default active domain for one of the disks of template with id : {0}", getVmTemplate().getId()); return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_MISSED_STORAGES_FOR_SOME_DISKS); } if (!VmTemplateCommand.isVmTemplateImagesReady(getVmTemplate(), null, getReturnValue().getCanDoActionMessages(), true, true, true, false, getTemplateDisks())) { return false; } setStoragePoolId(getVmTemplate().getStoragePoolId()); if (!checkStorageDomain() || !checkStorageDomainStatus(StorageDomainStatus.Active)) { return false; } long actualDiskSize = Double.valueOf(getVmTemplate().getActualDiskSize()).longValue(); if (!checkFreeSpaceOnDestinationDomain(getStorageDomain(), actualDiskSize)) { return false; } try { if (atLeastOneImageFoundInStorageDomain(getTemplateDisks(), getStorageDomain().getId())) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_DOMAIN_ALREADY_CONTAINS_DISK); } } catch (RuntimeException e) { log.error("Failed to validate if target storage domain already contains one of the template disks! " + e.getMessage()); } StoragePoolIsoMapId storagePoolIsoMapId = new StoragePoolIsoMapId(getStorageDomain().getId(), getVmTemplate().getStoragePoolId().getValue()); if (DbFacade.getInstance().getStoragePoolIsoMapDao().get(storagePoolIsoMapId) == null) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_POOL_NOT_MATCH); } } return true; }

Target:
protected boolean canDoAction() { boolean retValue = true; if (getVmTemplate() == null) { retValue = false; addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_TEMPLATE_DOES_NOT_EXIST); } else if (getTemplateDisks() != null && !getTemplateDisks().isEmpty()) { ensureDomainMap(getTemplateDisks(), getParameters().getStorageDomainId()); ImagesHandler.fillImagesMapBasedOnTemplate(getVmTemplate(), imageFromSourceDomainMap, null, true); if (getVmTemplate().getDiskTemplateMap().values().size() != imageFromSourceDomainMap.size()) { log.errorFormat("Can not found any default active domain for one of the disks of template with id : {0}", getVmTemplate().getId()); addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_MISSED_STORAGES_FOR_SOME_DISKS); retValue = false; } retValue = retValue && VmTemplateCommand.isVmTemplateImagesReady(getVmTemplate(), null, getReturnValue().getCanDoActionMessages(), true, true, true, false, getTemplateDisks()); if (retValue) { setStoragePoolId(getVmTemplate().getStoragePoolId()); retValue = checkStorageDomain() && checkStorageDomainStatus(StorageDomainStatus.Active) && checkIfDisksExist(getTemplateDisks()) && checkFreeSpaceOnDestinationDomain(getStorageDomain(), (int) getVmTemplate().getActualDiskSize()); } if (retValue && DbFacade.getInstance() .getStoragePoolIsoMapDao() .get(new StoragePoolIsoMapId(getStorageDomain().getId(), getVmTemplate().getStoragePoolId())) == null) { retValue = false; addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_POOL_NOT_MATCH); } } return retValue; }