Allon Mureinik has uploaded a new change for review. Change subject: core, webadmin: Warn about incompatible upgrade ......................................................................
core, webadmin: Warn about incompatible upgrade When upgrading a DC, a warning is issued if this upgrade would cause upgrading the domains' storage format. This patch improves that message by adding information that this upgrade will cause the domains to be unusable with products of version XYZ. The patch includes: 1. A method in VersionStorageFormatUtil to retrieve the earliest supported version of a given format. 2. A unit test for said method 3. Migrating the message from UIConstants to UIMessages, and adding a version parameter. 4. The call in DataCenterListModel for said message. Change-Id: I3fa7345caad8603c03fb042dec2cebf6fdc03f44 Bug-Url: https://bugzilla.redhat.com/957939 Signed-off-by: Allon Mureinik <[email protected]> --- M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/VersionStorageFormatUtil.java M backend/manager/modules/common/src/test/java/org/ovirt/engine/core/common/utils/VersionStorageFormatUtilTest.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/datacenters/DataCenterListModel.java M frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java M frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIMessages.java 5 files changed, 44 insertions(+), 7 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/28/24028/1 diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/VersionStorageFormatUtil.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/VersionStorageFormatUtil.java index fd0883e..16cf146 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/VersionStorageFormatUtil.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/VersionStorageFormatUtil.java @@ -1,7 +1,9 @@ package org.ovirt.engine.core.common.utils; -import java.util.HashMap; +import java.util.ArrayList; +import java.util.List; import java.util.Map; +import java.util.TreeMap; import org.ovirt.engine.core.common.businessentities.StorageFormatType; import org.ovirt.engine.core.common.businessentities.StorageType; @@ -50,7 +52,7 @@ } private static final Map<Version, StorageFormatTypeMapper> versionToFormat = - new HashMap<Version, StorageFormatTypeMapper>() { + new TreeMap<Version, StorageFormatTypeMapper>() { { put(Version.v2_2, new ConstantStorageFormatTypeMapper(StorageFormatType.V1)); put(Version.v3_0, new V2FormatTypeMapper()); @@ -61,6 +63,24 @@ } }; + private static final Map<StorageFormatType, Version> earliestVersionSupported = + new TreeMap<StorageFormatType, Version>() { + { + // Since versionToFormat is sorted in ascending order of versions, we'll always put + // the earliest version at the end, overriding the lower ones + // This is in fact cheaper than iterating the other way and checking if the key already + // exists in the map + List<Map.Entry<Version, StorageFormatTypeMapper>> entries = + new ArrayList<Map.Entry<Version, StorageFormatTypeMapper>>(versionToFormat.entrySet()); + for (int i = entries.size() - 1; i >= 0; --i) { + Map.Entry<Version, StorageFormatTypeMapper> entry = entries.get(i); + // iSCSI is always the strictest storage type. + // If this assumption is broken, the flow should be revisited + put(entry.getValue().getRequired(StorageType.ISCSI), entry.getKey()); + } + } + }; + public static StorageFormatType getPreferredForVersion(Version v, StorageType type) { return versionToFormat.get(v).getPreferred(type); } @@ -68,4 +88,8 @@ public static StorageFormatType getRequiredForVersion(Version v, StorageType type) { return versionToFormat.get(v).getRequired(type); } + + public static Version getEarliestVersionSupported (StorageFormatType type) { + return earliestVersionSupported.get(type); + } } diff --git a/backend/manager/modules/common/src/test/java/org/ovirt/engine/core/common/utils/VersionStorageFormatUtilTest.java b/backend/manager/modules/common/src/test/java/org/ovirt/engine/core/common/utils/VersionStorageFormatUtilTest.java index b66b2b8..bf13bea 100644 --- a/backend/manager/modules/common/src/test/java/org/ovirt/engine/core/common/utils/VersionStorageFormatUtilTest.java +++ b/backend/manager/modules/common/src/test/java/org/ovirt/engine/core/common/utils/VersionStorageFormatUtilTest.java @@ -32,5 +32,15 @@ assertNotNull(String.format("Missing required format for version %s in type %s", v, t), required); assertTrue("Preferred version shouldn't be smaller than the required one", preferred.compareTo(required) >= 0); + + Version earliestSupported = VersionStorageFormatUtil.getEarliestVersionSupported(required); + assertNotNull(String.format("Missing earliest version for format %s", required), earliestSupported); + + assertTrue( + String.format( + "Earliest supported version (%s) should no be later than the version requiring this type (%s)", + earliestSupported, v + ), + v.compareTo(earliestSupported) >= 0); } } diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/datacenters/DataCenterListModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/datacenters/DataCenterListModel.java index c917fa5..7533004 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/datacenters/DataCenterListModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/datacenters/DataCenterListModel.java @@ -29,6 +29,7 @@ import org.ovirt.engine.core.common.utils.VersionStorageFormatUtil; import org.ovirt.engine.core.compat.Guid; import org.ovirt.engine.core.compat.StringHelper; +import org.ovirt.engine.core.compat.Version; import org.ovirt.engine.core.searchbackend.SearchObjects; import org.ovirt.engine.ui.frontend.AsyncQuery; import org.ovirt.engine.ui.frontend.Frontend; @@ -648,9 +649,10 @@ .getConstants() .youAreAboutChangeDcCompatibilityVersionMsg()); } else { + Version v = VersionStorageFormatUtil.getEarliestVersionSupported(newFormat); confirmModel.setMessage(ConstantsManager.getInstance() - .getConstants() - .youAreAboutChangeDcCompatibilityVersionWithUpgradeMsg()); + .getMessages() + .youAreAboutChangeDcCompatibilityVersionWithUpgradeMsg(v.getValue())); } ((DataCenterListModel) model).stopProgress(); } 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 66e6e58..99219e5 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 @@ -725,9 +725,6 @@ @DefaultStringValue("You are about to change the Data Center Compatibility Version. Are you sure you want to continue?") String youAreAboutChangeDcCompatibilityVersionMsg(); - @DefaultStringValue("You are about to change the Data Center Compatibility Version. This will upgrade all the Storage Domains belonging to the Data Center. Are you sure you want to continue?") - String youAreAboutChangeDcCompatibilityVersionWithUpgradeMsg(); - @DefaultStringValue("You are about to attach the network to all the selected clusters and to detach the network from all the unselected clusters.\n\nAre you sure you want to continue?") String youAreAboutToAttachDetachNetworkToFromTheClustersMsg(); diff --git a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIMessages.java b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIMessages.java index a9634b0..78ad7c8 100644 --- a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIMessages.java +++ b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIMessages.java @@ -342,4 +342,8 @@ @DefaultMessage("{0} (Thin/Dependent)") String vmTemplateWithThinProvisioning(String templateName); + @DefaultMessage("You are about to change the Data Center Compatibility Version. This will upgrade all the " + + "Storage Domains belonging to the Data Center, and make them unusable with versions older than {0}. " + + "Are you sure you want to continue?") + String youAreAboutChangeDcCompatibilityVersionWithUpgradeMsg(String version); } -- To view, visit http://gerrit.ovirt.org/24028 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I3fa7345caad8603c03fb042dec2cebf6fdc03f44 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Allon Mureinik <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
