Leonardo Bianconi has uploaded a new change for review. Change subject: webadmin: Fix Default OS selection for PPC ......................................................................
webadmin: Fix Default OS selection for PPC The change 23809 introduced a problem with the default OS for PPC64, since the id 0 was fixed in the AsyncDataProvider class. This change was supposed to fix a possible issue, that happens when the OS id added to a VM is missing in the OSInfo property file. I reverted the solution that was using the class MapWithDafults, because there are two default OSes (one for each architecture), not only one. I couldn't figure out how to fix this issue, maybe when starting the system and exit with an error or show error on event log. It deserves more discussion. Change-Id: I02843c1af1b3aecf2d3966bf836395550b0be554 Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1062344 Signed-off-by: Leonardo Bianconi <leonardo.bianc...@eldorado.org.br> --- D frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/MapWithDefaults.java 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/vms/UnitVmModel.java 3 files changed, 12 insertions(+), 54 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/00/24200/1 diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/MapWithDefaults.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/MapWithDefaults.java deleted file mode 100644 index 10d6c8d..0000000 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/MapWithDefaults.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.ovirt.engine.ui.uicommonweb; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -/** - * Simple map that supports default value when requested key doesn't exist. - * @param <K> key type - * @param <V> value type - */ -public class MapWithDefaults<K, V> { - - private Map<K, V> data; - private V defaultValue; - - public MapWithDefaults(Map<K, V> data, V defaultValue) { - this.data = new HashMap<K, V>(); - this.data.putAll(data); - this.defaultValue = defaultValue; - } - - /** - * Retrieves value under specific key. If the key doesn't exist, returns default value instead. - */ - public V get(K key) { - return (data.containsKey(key)) - ? data.get(key) - : defaultValue; - } - - /** - * Returns unmodifiable set of keys. - */ - public Set<K> keySet() { - return Collections.unmodifiableSet(data.keySet()); - } - -} 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 ee7bddd..f02bed0 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 @@ -35,6 +35,7 @@ import org.ovirt.engine.core.common.businessentities.IVdcQueryable; import org.ovirt.engine.core.common.businessentities.ImageFileType; import org.ovirt.engine.core.common.businessentities.LUNs; +import org.ovirt.engine.core.common.businessentities.Permissions; import org.ovirt.engine.core.common.businessentities.Provider; import org.ovirt.engine.core.common.businessentities.ProviderType; import org.ovirt.engine.core.common.businessentities.Quota; @@ -61,7 +62,6 @@ import org.ovirt.engine.core.common.businessentities.VmTemplateStatus; import org.ovirt.engine.core.common.businessentities.VolumeFormat; import org.ovirt.engine.core.common.businessentities.VolumeType; -import org.ovirt.engine.core.common.businessentities.Permissions; import org.ovirt.engine.core.common.businessentities.comparators.LexoNumericComparator; import org.ovirt.engine.core.common.businessentities.comparators.NameableComparator; import org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity; @@ -70,6 +70,7 @@ import org.ovirt.engine.core.common.businessentities.gluster.GlusterServerService; import org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity; import org.ovirt.engine.core.common.businessentities.gluster.ServiceType; +import org.ovirt.engine.core.common.businessentities.network.ExternalSubnet.IpVersion; import org.ovirt.engine.core.common.businessentities.network.Network; import org.ovirt.engine.core.common.businessentities.network.NetworkQoS; import org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface; @@ -77,7 +78,6 @@ import org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface; import org.ovirt.engine.core.common.businessentities.network.VnicProfile; import org.ovirt.engine.core.common.businessentities.network.VnicProfileView; -import org.ovirt.engine.core.common.businessentities.network.ExternalSubnet.IpVersion; import org.ovirt.engine.core.common.interfaces.SearchType; import org.ovirt.engine.core.common.mode.ApplicationMode; import org.ovirt.engine.core.common.queries.CommandVersionsInfo; @@ -127,7 +127,6 @@ import org.ovirt.engine.core.common.queries.gluster.GlusterServiceQueryParameters; import org.ovirt.engine.core.common.queries.gluster.GlusterVolumeAdvancedDetailsParameters; import org.ovirt.engine.core.common.queries.gluster.GlusterVolumeQueriesParameters; -import org.ovirt.engine.ui.uicommonweb.MapWithDefaults; import org.ovirt.engine.core.common.utils.Pair; import org.ovirt.engine.core.common.utils.SimpleDependecyInjector; import org.ovirt.engine.core.compat.Guid; @@ -159,8 +158,6 @@ private static final String GENERAL = "general"; //$NON-NLS-1$ - public static final int DEFAULT_OS_ID = 0; - // dictionary to hold cache of all config values (per version) queried by client, if the request for them succeeded. private static HashMap<KeyValuePairCompat<ConfigurationValues, String>, Object> cachedConfigValues = new HashMap<KeyValuePairCompat<ConfigurationValues, String>, Object>(); @@ -171,7 +168,7 @@ private static String _defaultConfigurationVersion = null; // cached OS names - private static MapWithDefaults<Integer, String> osNames; + private static HashMap<Integer, String> osNames; // cached list of os ids private static List<Integer> osIds; @@ -196,7 +193,7 @@ private static HashMap<ArchitectureType, Integer> defaultOSes; // cached os's support for display types (given compatibility version) - private static MapWithDefaults<Integer, Map<Version, List<DisplayType>>> displayTypes; + private static HashMap<Integer, Map<Version, List<DisplayType>>> displayTypes; public static String getDefaultConfigurationVersion() { return _defaultConfigurationVersion; @@ -3321,9 +3318,7 @@ callback.asyncCallback = new INewAsyncCallback() { @Override public void onSuccess(Object model, Object returnValue) { - HashMap<Integer, String> result = ((VdcQueryReturnValue) returnValue).getReturnValue(); - String defaultValue = result.get(DEFAULT_OS_ID); - osNames = new MapWithDefaults<Integer, String>(result, defaultValue); + osNames = (HashMap<Integer, String>) ((VdcQueryReturnValue) returnValue).getReturnValue(); initOsIds(); } }; @@ -3377,9 +3372,7 @@ callback.asyncCallback = new INewAsyncCallback() { @Override public void onSuccess(Object model, Object returnValue) { - Map<Integer, Map<Version, List<DisplayType>>> result = - ((VdcQueryReturnValue) returnValue).getReturnValue(); - displayTypes = new MapWithDefaults<Integer, Map<Version, List<DisplayType>>>(result, result.get(DEFAULT_OS_ID)); + displayTypes = ((VdcQueryReturnValue) returnValue).getReturnValue(); } }; Frontend.getInstance().runQuery(VdcQueryType.OsRepository, new OsQueryParameters(OsRepositoryVerb.GetDisplayTypes), callback); diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java index b7363af..b68625a 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java @@ -1363,7 +1363,12 @@ @Override public void setSelectedItem(Integer value) { if (!AsyncDataProvider.osNameExists(value)) { - super.setSelectedItem(AsyncDataProvider.DEFAULT_OS_ID); + DataCenterWithCluster dataCenterWithCluster = getDataCenterWithClustersList().getSelectedItem(); + VDSGroup cluster = dataCenterWithCluster == null ? null : dataCenterWithCluster.getCluster(); + if (cluster == null) { + return; + } + super.setSelectedItem(AsyncDataProvider.getDefaultOs(cluster.getArchitecture())); } else { super.setSelectedItem(value); } -- To view, visit http://gerrit.ovirt.org/24200 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I02843c1af1b3aecf2d3966bf836395550b0be554 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Leonardo Bianconi <leonardo.bianc...@eldorado.org.br> Gerrit-Reviewer: Alexander Wels <aw...@redhat.com> Gerrit-Reviewer: Daniel Erez <de...@redhat.com> Gerrit-Reviewer: Eli Mesika <emes...@redhat.com> Gerrit-Reviewer: Frank Kobzik <fkob...@redhat.com> Gerrit-Reviewer: Gustavo Frederico Temple Pedrosa <gustavo.pedr...@eldorado.org.br> Gerrit-Reviewer: Itamar Heim <ih...@redhat.com> Gerrit-Reviewer: Juan Hernandez <juan.hernan...@redhat.com> Gerrit-Reviewer: Liran Zelkha <lzel...@redhat.com> Gerrit-Reviewer: Omer Frenkel <ofren...@redhat.com> Gerrit-Reviewer: Roy Golan <rgo...@redhat.com> Gerrit-Reviewer: Tomas Jelinek <tjeli...@redhat.com> Gerrit-Reviewer: Vitor de Lima <vitor.l...@eldorado.org.br> Gerrit-Reviewer: automat...@ovirt.org Gerrit-Reviewer: oVirt Jenkins CI Server _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches