Vitor de Lima has uploaded a new change for review. Change subject: ui: OVF import in multiple architecture scenario ......................................................................
ui: OVF import in multiple architecture scenario This patch prevents the user from import VMs and templates with different architectures into the same cluster. This is done by showing a warning when there are selected VMs with different architectures in the Import VM and Import Template dialog. Also, when the Import VM dialog is shown the only clusters displayed in the dialog are the ones compatible with the architecture of the selected VMs and templates. Change-Id: I77c5bee8d71dd394fd7d4b51645bb0b296788780 Signed-off-by: Vitor de Lima <vitor.l...@eldorado.org.br> --- M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/storage/TemplateBackupModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/storage/VmBackupModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/ImportVmModel.java M frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java M frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java M frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/storage/backup/ImportVmPopupView.java M frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/storage/SubTabStorageTemplateBackupView.java M frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/storage/SubTabStorageVmBackupView.java 9 files changed, 126 insertions(+), 2 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/12/19012/1 diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java index 191bbe6..658d9f0 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java @@ -624,6 +624,17 @@ aQuery); } + public static List<VDSGroup> filterByArchitecture(List<VDSGroup> clusters, ArchitectureType targetArchitecture) { + List<VDSGroup> filteredClusters = new ArrayList<VDSGroup>(); + + for (VDSGroup cluster : clusters) { + if (cluster.getArchitecture().equals(targetArchitecture)) { + filteredClusters.add(cluster); + } + } + return filteredClusters; + } + public static void getClusterByServiceList(AsyncQuery aQuery, Guid dataCenterId, final boolean supportsVirtService, final boolean supportsGlusterService) { aQuery.converterCallback = new IAsyncConverter() { diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/storage/TemplateBackupModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/storage/TemplateBackupModel.java index d9ca20a..b15b892 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/storage/TemplateBackupModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/storage/TemplateBackupModel.java @@ -11,12 +11,14 @@ import org.ovirt.engine.core.common.action.VdcActionType; import org.ovirt.engine.core.common.action.VdcReturnValueBase; import org.ovirt.engine.core.common.action.VmTemplateImportExportParameters; +import org.ovirt.engine.core.common.businessentities.ArchitectureType; import org.ovirt.engine.core.common.businessentities.DiskImage; import org.ovirt.engine.core.common.businessentities.Quota; import org.ovirt.engine.core.common.businessentities.StorageDomainSharedStatus; import org.ovirt.engine.core.common.businessentities.StorageDomainType; import org.ovirt.engine.core.common.businessentities.StoragePool; import org.ovirt.engine.core.common.businessentities.VDSGroup; +import org.ovirt.engine.core.common.businessentities.VmBase; import org.ovirt.engine.core.common.businessentities.VmTemplate; import org.ovirt.engine.core.common.queries.GetAllFromExportDomainQueryParameters; import org.ovirt.engine.core.common.queries.VdcQueryReturnValue; @@ -125,6 +127,13 @@ } @Override + protected ArchitectureType getArchitectureFromItem(Object item) { + VmBase template = (VmBase) item; + + return template.getArchitecture(); + } + + @Override protected String getObjectName(Object object) { return ((ImportTemplateData) object).getTemplate().getName(); } diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/storage/VmBackupModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/storage/VmBackupModel.java index d20c3ba..c5a319c 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/storage/VmBackupModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/storage/VmBackupModel.java @@ -14,6 +14,7 @@ import org.ovirt.engine.core.common.action.VdcActionParametersBase; import org.ovirt.engine.core.common.action.VdcActionType; import org.ovirt.engine.core.common.action.VdcReturnValueBase; +import org.ovirt.engine.core.common.businessentities.ArchitectureType; import org.ovirt.engine.core.common.businessentities.Disk; import org.ovirt.engine.core.common.businessentities.DiskImage; import org.ovirt.engine.core.common.businessentities.IVdcQueryable; @@ -167,11 +168,50 @@ getEntity().getId()); } + protected ArchitectureType getArchitectureFromItem(Object item) { + VM vm = (VM) item; + + return vm.getArchitecture(); + } + @Override protected void restore() { super.restore(); if (getWindow() != null) { + return; + } + + // Checks if there are selected VMs of multiple architectures + ArchitectureType firstArch = null; + boolean multipleArchs = false; + + for (Object item : getSelectedItems()) { + ArchitectureType arch = getArchitectureFromItem(item); + + if (firstArch == null) { + firstArch = arch; + } else { + if (!firstArch.equals(arch)) { + multipleArchs = true; + } + } + } + + if (multipleArchs) { + ConfirmationModel confirmModel = new ConfirmationModel(); + setConfirmWindow(confirmModel); + confirmModel.setTitle(ConstantsManager.getInstance().getConstants().invalidImportTitle()); + confirmModel.setHashName("multiple_archs_dialog"); //$NON-NLS-1$ + confirmModel.setMessage(ConstantsManager.getInstance().getConstants().invalidImportMsg()); + + UICommand command = new UICommand("multipleArchsOK", this); //$NON-NLS-1$ + command.setTitle(ConstantsManager.getInstance().getConstants().ok()); + command.setIsDefault(true); + confirmModel.getCommands().add(command); + + setConfirmWindow(confirmModel); + return; } @@ -189,6 +229,7 @@ model.getCommands().add(tempVar3); model.setItems(getSelectedItems()); model.init(getEntity().getId()); + model.setTargetArchitecture(firstArch); // Add 'Close' command UICommand closeCommand = new UICommand("Cancel", this); //$NON-NLS-1$ @@ -538,6 +579,10 @@ } } + private void multipleArchsOK() { + setConfirmWindow(null); + } + @Override public void executeCommand(UICommand command) { super.executeCommand(command); @@ -550,6 +595,8 @@ onClone(); } else if (command.getName().equals("closeClone")) { //$NON-NLS-1$ closeClone(); + } else if (command.getName().equals("multipleArchsOK")) { //$NON-NLS-1$ + multipleArchsOK(); } } diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/ImportVmModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/ImportVmModel.java index 7b7baae..fa6341f 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/ImportVmModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/ImportVmModel.java @@ -6,6 +6,7 @@ import java.util.Map; import java.util.Map.Entry; +import org.ovirt.engine.core.common.businessentities.ArchitectureType; import org.ovirt.engine.core.common.businessentities.Disk; import org.ovirt.engine.core.common.businessentities.DiskImage; import org.ovirt.engine.core.common.businessentities.Quota; @@ -49,6 +50,7 @@ public class ImportVmModel extends ListWithDetailsModel { public static final String ON_DISK_LOAD = "OnDiskLoad"; //$NON-NLS-1$ + ArchitectureType targetArchitecture; private VmImportDiskListModel importDiskListModel; private StoragePool storagePool; private boolean hasQuota; @@ -64,6 +66,14 @@ public void setStoragePool(StoragePool storagePool) { this.storagePool = storagePool; + } + + public ArchitectureType getTargetArchitecture() { + return targetArchitecture; + } + + public void setTargetArchitecture(ArchitectureType targetArchitecture) { + this.targetArchitecture = targetArchitecture; } private ListModel storage; @@ -183,8 +193,21 @@ @Override public void onSuccess(Object model, Object returnValue) { ArrayList<VDSGroup> clusters = (ArrayList<VDSGroup>) returnValue; - getCluster().setItems(clusters); - getCluster().setSelectedItem(Linq.firstOrDefault(clusters)); + + ImportVmModel importModel = (ImportVmModel) model; + + ArchitectureType targetArch = importModel.getTargetArchitecture(); + + if (targetArch != null) { + List<VDSGroup> filteredClusters = AsyncDataProvider.filterByArchitecture(clusters, + targetArch); + getCluster().setItems(filteredClusters); + getCluster().setSelectedItem(Linq.firstOrDefault(filteredClusters)); + } else { + getCluster().setItems(clusters); + getCluster().setSelectedItem(Linq.firstOrDefault(clusters)); + } + // get storage domains AsyncDataProvider.getStorageDomainList(new AsyncQuery(ImportVmModel.this, new INewAsyncCallback() { 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 7f351be..8176740 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 @@ -310,6 +310,9 @@ @DefaultStringValue("Template Import") String templateImportTitle(); + @DefaultStringValue("Invalid Import Configuration") + String invalidImportTitle(); + @DefaultStringValue("Remove Backed up Template(s)") String removeBackedUpTemplatesTitle(); @@ -738,6 +741,9 @@ @DefaultStringValue("There is no Data Storage Domain to import the Template into. Please attach a Data Storage Domain to the Template's Data Center.") String thereIsNoDataStorageDomainToImportTemplateIntoMsg(); + @DefaultStringValue("There are selected items with non-matching architectures. Please select only items with the same architecture to proceed the import process.") + String invalidImportMsg(); + @DefaultStringValue("The Export Domain is inactive. Data can be retrieved only when the Domain is activated") String theExportDomainIsInactiveMsg(); diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java index f3bf715..1df880f 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java @@ -1492,6 +1492,9 @@ @DefaultStringValue("CPUs") String cpusVm(); + @DefaultStringValue("Architecture") + String architectureVm(); + @DefaultStringValue("Network") String networkVm(); diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/storage/backup/ImportVmPopupView.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/storage/backup/ImportVmPopupView.java index fd12e2e..35fd26c 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/storage/backup/ImportVmPopupView.java +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/storage/backup/ImportVmPopupView.java @@ -316,6 +316,14 @@ }; table.addColumn(cpuColumn, constants.cpusVm(), "50px"); //$NON-NLS-1$ + TextColumnWithTooltip<Object> archColumn = new TextColumnWithTooltip<Object>() { + @Override + public String getValue(Object object) { + return String.valueOf(((ImportVmData) object).getVm().getArchitecture()); + } + }; + table.addColumn(archColumn, constants.architectureVm(), "50px"); //$NON-NLS-1$ + TextColumnWithTooltip<Object> diskColumn = new TextColumnWithTooltip<Object>() { @Override public String getValue(Object object) { diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/storage/SubTabStorageTemplateBackupView.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/storage/SubTabStorageTemplateBackupView.java index d459f28..13487ec 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/storage/SubTabStorageTemplateBackupView.java +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/storage/SubTabStorageTemplateBackupView.java @@ -71,6 +71,15 @@ }; getTable().addColumn(cpuColumn, constants.cpusVm(), "160px"); //$NON-NLS-1$ + TextColumnWithTooltip<VmTemplate> archColumn = + new TextColumnWithTooltip<VmTemplate>() { + @Override + public String getValue(VmTemplate object) { + return String.valueOf(object.getArchitecture()); + } + }; + getTable().addColumn(archColumn, constants.architectureVm(), "160px"); //$NON-NLS-1$ + TextColumnWithTooltip<VmTemplate> diskColumn = new TextColumnWithTooltip<VmTemplate>() { @Override diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/storage/SubTabStorageVmBackupView.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/storage/SubTabStorageVmBackupView.java index 589d328..9ebb2b9 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/storage/SubTabStorageVmBackupView.java +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/storage/SubTabStorageVmBackupView.java @@ -113,6 +113,14 @@ }; getTable().addColumn(cpuColumn, constants.cpusVm(), "95px"); //$NON-NLS-1$ + TextColumnWithTooltip<VM> archColumn = new TextColumnWithTooltip<VM>() { + @Override + public String getValue(VM object) { + return String.valueOf(object.getArchitecture()); + } + }; + getTable().addColumn(archColumn, constants.architectureVm(), "95px"); //$NON-NLS-1$ + TextColumnWithTooltip<VM> diskColumn = new TextColumnWithTooltip<VM>() { @Override public String getValue(VM object) { -- To view, visit http://gerrit.ovirt.org/19012 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I77c5bee8d71dd394fd7d4b51645bb0b296788780 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Vitor de Lima <vitor.l...@eldorado.org.br> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches