Omer Frenkel has uploaded a new change for review. Change subject: webadmin: warn when exporting template version if base is missing ......................................................................
webadmin: warn when exporting template version if base is missing added a warning to the user, if trying to export template version, and the base template is missing on the export domain, because on import the base template must exist, or clone is needed. this is very similar for exporting thin vm when template is missing. Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1073035 Change-Id: I028f9e98a31cca391e05e2e02c535f5f1b2068cf Signed-off-by: Omer Frenkel <[email protected]> --- M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/help/HelpTag.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/templates/TemplateListModel.java M frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java 3 files changed, 182 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/00/26000/1 diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/help/HelpTag.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/help/HelpTag.java index 5422557..b90258c 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/help/HelpTag.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/help/HelpTag.java @@ -398,6 +398,8 @@ template_not_found_on_export_domain("template_not_found_on_export_domain", HelpTagType.WEBADMIN, "VMs Tab > Export VM(s) > Confirm VM's Template not on Export Domain"), //$NON-NLS-1$ //$NON-NLS-2$ + base_template_not_found_on_export_domain("base_template_not_found_on_export_domain", HelpTagType.WEBADMIN, "Templates Tab > Export Template Version(s) > Confirm Base Template not on Export Domain"), //$NON-NLS-1$ //$NON-NLS-2$ + templates("templates", HelpTagType.UNKNOWN), //$NON-NLS-1$ users("users", HelpTagType.UNKNOWN), //$NON-NLS-1$ diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/templates/TemplateListModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/templates/TemplateListModel.java index e56c945..99921b4 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/templates/TemplateListModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/templates/TemplateListModel.java @@ -12,7 +12,9 @@ import org.ovirt.engine.core.common.action.VdcActionType; import org.ovirt.engine.core.common.action.VdcReturnValueBase; import org.ovirt.engine.core.common.action.VmTemplateParametersBase; +import org.ovirt.engine.core.common.businessentities.DiskImage; import org.ovirt.engine.core.common.businessentities.StorageDomain; +import org.ovirt.engine.core.common.businessentities.StoragePool; import org.ovirt.engine.core.common.businessentities.VmTemplate; import org.ovirt.engine.core.common.businessentities.VmTemplateStatus; import org.ovirt.engine.core.common.businessentities.VmWatchdog; @@ -209,6 +211,159 @@ } if (!model.validate()) + { + return; + } + + model.startProgress(null); + + getTemplatesNotPresentOnExportDomain(); + } + + private void getTemplatesNotPresentOnExportDomain() + { + ExportVmModel model = (ExportVmModel) getWindow(); + Guid storageDomainId = ((StorageDomain) model.getStorage().getSelectedItem()).getId(); + + AsyncDataProvider.getDataCentersByStorageDomain(new AsyncQuery(this, + new INewAsyncCallback() { + @Override + public void onSuccess(Object target, Object returnValue) { + TemplateListModel templateListModel = (TemplateListModel) target; + ArrayList<StoragePool> storagePools = + (ArrayList<StoragePool>) returnValue; + StoragePool storagePool = storagePools.size() > 0 ? storagePools.get(0) : null; + + templateListModel.postGetTemplatesNotPresentOnExportDomain(storagePool); + } + }), storageDomainId); + } + + private void postGetTemplatesNotPresentOnExportDomain(StoragePool storagePool) + { + ExportVmModel model = (ExportVmModel) getWindow(); + Guid storageDomainId = ((StorageDomain) model.getStorage().getSelectedItem()).getId(); + + if (storagePool != null) + { + AsyncDataProvider.getAllTemplatesFromExportDomain(new AsyncQuery(this, + new INewAsyncCallback() { + @Override + public void onSuccess(Object target, Object returnValue) { + TemplateListModel templateListModel = (TemplateListModel) target; + HashMap<VmTemplate, ArrayList<DiskImage>> templatesDiskSet = + (HashMap<VmTemplate, ArrayList<DiskImage>>) returnValue; + HashMap<String, ArrayList<String>> templateDic = + new HashMap<String, ArrayList<String>>(); + ArrayList<String> verTempMissingBase = new ArrayList<String>(); + + // check if relevant templates are already there + for (Object selectedItem : templateListModel.getSelectedItems()) + { + VmTemplate template = (VmTemplate) selectedItem; + // only relevant for template versions + if (!template.isBaseTemplate()) { + boolean hasMatch = false; + for (VmTemplate a : templatesDiskSet.keySet()) + { + if (template.getBaseTemplateId().equals(a.getId())) + { + hasMatch = true; + break; + } + } + + if (!template.getBaseTemplateId().equals(Guid.Empty) && !hasMatch) + { + verTempMissingBase.add(template.getName()); + } + } + } + + templateListModel.postExportGetMissingTemplates(verTempMissingBase); + } + }), + storagePool.getId(), + storageDomainId); + } + } + + private void postExportGetMissingTemplates(ArrayList<String> missingTemplatesFromVms) + { + ExportVmModel model = (ExportVmModel) getWindow(); + ArrayList<VdcActionParametersBase> parameters = new ArrayList<VdcActionParametersBase>(); + + model.stopProgress(); + + for (Object item : getSelectedItems()) + { + VmTemplate a = (VmTemplate) item; + if (a.getId().equals(Guid.Empty)) + { + continue; + } + MoveOrCopyParameters tempVar = + new MoveOrCopyParameters(a.getId(), + ((StorageDomain) model.getStorage().getSelectedItem()).getId()); + tempVar.setForceOverride((Boolean) model.getForceOverride().getEntity()); + parameters.add(tempVar); + } + + if ((missingTemplatesFromVms == null || missingTemplatesFromVms.size() > 0)) + { + ConfirmationModel confirmModel = new ConfirmationModel(); + setConfirmWindow(confirmModel); + confirmModel.setTitle(ConstantsManager.getInstance() + .getConstants() + .baseTemplatesNotFoundOnExportDomainTitle()); + confirmModel.setHelpTag(HelpTag.base_template_not_found_on_export_domain); + confirmModel.setHashName("base_template_not_found_on_export_domain"); //$NON-NLS-1$ + + confirmModel.setMessage(missingTemplatesFromVms == null ? ConstantsManager.getInstance() + .getConstants() + .couldNotReadTemplatesFromExportDomainMsg() + : ConstantsManager.getInstance() + .getConstants() + .theFollowingTemplatesAreMissingOnTargetExportDomainForTemplateVersionsMsg()); + confirmModel.setItems(missingTemplatesFromVms); + + UICommand tempVar = new UICommand("OnExportNoTemplates", this); //$NON-NLS-1$ + tempVar.setTitle(ConstantsManager.getInstance().getConstants().ok()); + tempVar.setIsDefault(true); + confirmModel.getCommands().add(tempVar); + UICommand tempVar2 = new UICommand("CancelConfirmation", this); //$NON-NLS-1$ + tempVar2.setTitle(ConstantsManager.getInstance().getConstants().cancel()); + tempVar2.setIsCancel(true); + confirmModel.getCommands().add(tempVar2); + } + else + { + if (model.getProgress() != null) + { + return; + } + + model.startProgress(null); + + Frontend.getInstance().runMultipleAction(VdcActionType.ExportVmTemplate, parameters, + new IFrontendMultipleActionAsyncCallback() { + @Override + public void executed(FrontendMultipleActionAsyncResult result) { + + ExportVmModel localModel = (ExportVmModel) result.getState(); + localModel.stopProgress(); + cancel(); + + } + }, model); + } + } + + private void onExportNoTemplates() + { + ExportVmModel model = (ExportVmModel) getWindow(); + + if (model.getProgress() != null) { return; } @@ -539,7 +694,16 @@ { Frontend.getInstance().unsubscribe(); + cancelConfirmation(); + setWindow(null); + + updateActionAvailability(); + } + + private void cancelConfirmation() + { + setConfirmWindow(null); } @Override @@ -685,6 +849,14 @@ { onRemove(); } + else if ("OnExportNoTemplates".equals(command.getName())) //$NON-NLS-1$ + { + onExportNoTemplates(); + } + else if ("CancelConfirmation".equals(command.getName())) //$NON-NLS-1$ + { + cancelConfirmation(); + } } @Override diff --git a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java index 8f3b759..121babc 100644 --- a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java +++ b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java @@ -639,6 +639,9 @@ @DefaultStringValue("Template(s) not Found on Export Domain") String templatesNotFoundOnExportDomainTitle(); + @DefaultStringValue("Base Template(s) not Found on Export Domain") + String baseTemplatesNotFoundOnExportDomainTitle(); + @DefaultStringValue("Run Virtual Machine(s)") String runVirtualMachinesTitle(); @@ -1379,6 +1382,11 @@ "Do you wish to continue anyway?") String theFollowingTemplatesAreMissingOnTargetExportDomainMsg(); + @DefaultStringValue("The following template versions are based on templates which do not exist on the export domain and are required for the template version to function.\n" + + "If you proceed you will not be able to import these template versions unless you already have the relevant templates on the target domains, or by using Clone.\n" + + "Do you wish to continue anyway?") + String theFollowingTemplatesAreMissingOnTargetExportDomainForTemplateVersionsMsg(); + @DefaultStringValue("There are no active Data-Centers in the system.") String noActiveDataCenters(); -- To view, visit http://gerrit.ovirt.org/26000 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I028f9e98a31cca391e05e2e02c535f5f1b2068cf Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Omer Frenkel <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
