From d3fa68e210d64d0f36690578b68555cd652a12e3 Mon Sep 17 00:00:00 2001 From: Mihaela Stoica Date: Fri, 23 Mar 2018 11:56:54 +0000 Subject: [PATCH] CA-286582: Hide the Provisioning method page if the feature is not present or disabled Signed-off-by: Mihaela Stoica --- XenAdmin/Wizards/NewSRWizard.cs | 6 ++++-- .../NewSRWizard_Pages/Frontends/LVMoFCoE.cs | 1 + .../NewSRWizard_Pages/Frontends/LVMoHBA.cs | 1 + .../NewSRWizard_Pages/Frontends/LVMoISCSI.cs | 1 + XenModel/Network/Cache.cs | 6 ++++++ XenModel/Network/ICache.cs | 1 + XenModel/XenAPI-Extensions/Host.cs | 15 +++++++++++++++ 7 files changed, 29 insertions(+), 2 deletions(-) diff --git a/XenAdmin/Wizards/NewSRWizard.cs b/XenAdmin/Wizards/NewSRWizard.cs index df49f42f8..79fcf3bc6 100644 --- a/XenAdmin/Wizards/NewSRWizard.cs +++ b/XenAdmin/Wizards/NewSRWizard.cs @@ -284,12 +284,14 @@ namespace XenAdmin.Wizards AddPage(xenTabPageVhdoNFS); else if (m_srWizardType is SrWizardType_Iscsi) { - AddPage(xenTabPageChooseSrProv); + if (Helpers.KolkataOrGreater(xenConnection) && !Helpers.FeatureForbidden(xenConnection, Host.CorosyncDisabled)) + AddPage(xenTabPageChooseSrProv); AddPage(xenTabPageLvmoIscsi); } else if (m_srWizardType is SrWizardType_Hba) { - AddPage(xenTabPageChooseSrProv); + if (Helpers.KolkataOrGreater(xenConnection) && !Helpers.FeatureForbidden(xenConnection, Host.CorosyncDisabled)) + AddPage(xenTabPageChooseSrProv); AddPage(xenTabPageLvmoHba); AddPage(xenTabPageLvmoHbaSummary); } diff --git a/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/LVMoFCoE.cs b/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/LVMoFCoE.cs index ae68432d8..239f72583 100644 --- a/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/LVMoFCoE.cs +++ b/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/LVMoFCoE.cs @@ -38,6 +38,7 @@ namespace XenAdmin.Wizards.NewSRWizard_Pages.Frontends public LVMoFCoE() { InitializeComponent(); + SrType = SR.SRTypes.lvmofcoe; } #region LVMoHBA overrides diff --git a/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/LVMoHBA.cs b/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/LVMoHBA.cs index c27512de5..6c0243f96 100644 --- a/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/LVMoHBA.cs +++ b/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/LVMoHBA.cs @@ -54,6 +54,7 @@ namespace XenAdmin.Wizards.NewSRWizard_Pages.Frontends public LVMoHBA() { InitializeComponent(); + SrType = SR.SRTypes.lvmohba; } public virtual SR.SRTypes SrType { get; set; } diff --git a/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/LVMoISCSI.cs b/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/LVMoISCSI.cs index bb2178738..ff5aa863d 100644 --- a/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/LVMoISCSI.cs +++ b/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/LVMoISCSI.cs @@ -107,6 +107,7 @@ namespace XenAdmin.Wizards.NewSRWizard_Pages.Frontends public LVMoISCSI() { InitializeComponent(); + SrType = SR.SRTypes.lvmoiscsi; } #region XentabPage overrides diff --git a/XenModel/Network/Cache.cs b/XenModel/Network/Cache.cs index ba875b706..ae2c6f131 100755 --- a/XenModel/Network/Cache.cs +++ b/XenModel/Network/Cache.cs @@ -52,6 +52,7 @@ namespace XenAdmin.Network private readonly ChangeableDictionary, Cluster> _cluster = new ChangeableDictionary, Cluster>(); private readonly ChangeableDictionary, Cluster_host> _cluster_host = new ChangeableDictionary, Cluster_host>(); private readonly ChangeableDictionary, XenAPI.Console> _console = new ChangeableDictionary, XenAPI.Console>(); + private readonly ChangeableDictionary, Feature> _feature = new ChangeableDictionary, Feature>(); private readonly ChangeableDictionary, Folder> _folders = new ChangeableDictionary, Folder>(); private readonly ChangeableDictionary, DockerContainer> _dockerContainers = new ChangeableDictionary, DockerContainer>(); @@ -141,6 +142,11 @@ namespace XenAdmin.Network get { return contents(_cluster_host); } } + public Feature[] Features + { + get { return contents(_feature); } + } + public Folder[] Folders { get { return contents(_folders); } diff --git a/XenModel/Network/ICache.cs b/XenModel/Network/ICache.cs index b821be2a8..9f4e35b48 100644 --- a/XenModel/Network/ICache.cs +++ b/XenModel/Network/ICache.cs @@ -91,5 +91,6 @@ namespace XenAdmin.Network void CheckDockerContainersBatchChange(); Cluster[] Clusters { get; } Cluster_host[] Cluster_hosts { get; } + Feature[] Features { get; } } } diff --git a/XenModel/XenAPI-Extensions/Host.cs b/XenModel/XenAPI-Extensions/Host.cs index 4856ab1c5..57d7c468d 100644 --- a/XenModel/XenAPI-Extensions/Host.cs +++ b/XenModel/XenAPI-Extensions/Host.cs @@ -439,6 +439,21 @@ namespace XenAPI { return BoolKeyPreferTrue(h.license_params, "restrict_corosync"); } + + public static bool CorosyncDisabled(Host h) + { + return RestrictCorosync(h) && FeatureDisabled(h, "corosync"); + } + + public static bool FeatureDisabled(Host h, string featureName) + { + foreach (var feature in h.Connection.ResolveAll(h.features)) + { + if (feature.name_label.Equals(featureName, StringComparison.OrdinalIgnoreCase)) + return !feature.enabled; + } + return false; + } public bool HasPBDTo(SR sr) {