From 3fc14c53441f1f4932dad7f00201b2f2f9a6d1b2 Mon Sep 17 00:00:00 2001 From: Konstantina Chremmou Date: Wed, 9 May 2018 12:38:26 +0100 Subject: [PATCH] Disable creation of SR-IOV network if the feature is disabled. Signed-off-by: Konstantina Chremmou --- .../NewNetworkWizard_Pages/NetWTypeSelect.cs | 18 +++++++++++------- XenModel/Messages.Designer.cs | 9 +++++++++ XenModel/Messages.resx | 3 +++ XenModel/XenAPI-Extensions/Host.cs | 11 ++++++++++- 4 files changed, 33 insertions(+), 8 deletions(-) diff --git a/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWTypeSelect.cs b/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWTypeSelect.cs index 303f5f657..1ba20d2ab 100644 --- a/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWTypeSelect.cs +++ b/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWTypeSelect.cs @@ -104,21 +104,25 @@ namespace XenAdmin.Wizards.NewNetworkWizard_Pages bool hasNicCanEnableSriov = pool.Connection.Cache.PIFs.Any(pif => pif.IsPhysical() && pif.SriovCapable() && !pif.IsSriovPhysicalPIF()); bool sriovFeatureForbidden = Helpers.FeatureForbidden(connection, Host.RestrictSriovNetwork); - if( !Helpers.KolkataOrGreater(pool.Connection)) + if (!Helpers.KolkataOrGreater(pool.Connection)) { iconWarningSriovOption.Visible = labelWarningSriovOption.Visible = false; rbtnSriov.Visible = labelSriov.Visible = false; } - else if (sriovFeatureForbidden || !pool.HasSriovNic() || !hasNicCanEnableSriov) + else if (Helpers.FeatureForbidden(pool.Connection, Host.SriovNetworkDisabled) || + sriovFeatureForbidden || !pool.HasSriovNic() || !hasNicCanEnableSriov) { rbtnSriov.Checked = false; rbtnSriov.Enabled = labelSriov.Enabled = false; - labelWarningSriovOption.Text = sriovFeatureForbidden ? - String.Format(Messages.FEATURE_DISABLED, Messages.NETWORK_SRIOV) : - pool.HasSriovNic() ? - Messages.NICS_ARE_SRIOV_ENABLED : - Messages.SRIOV_NEED_NICSUPPORT; + labelWarningSriovOption.Text = + Helpers.FeatureForbidden(pool.Connection, Host.SriovNetworkDisabled) + ? String.Format(Messages.FEATURE_EXPERIMENTAL, Messages.NETWORK_SRIOV) + : sriovFeatureForbidden + ? String.Format(Messages.FEATURE_DISABLED, Messages.NETWORK_SRIOV) + : pool.HasSriovNic() + ? Messages.NICS_ARE_SRIOV_ENABLED + : Messages.SRIOV_NEED_NICSUPPORT; iconWarningSriovOption.Visible = labelWarningSriovOption.Visible = true; } diff --git a/XenModel/Messages.Designer.cs b/XenModel/Messages.Designer.cs index 9a46df4a6..a112080e9 100755 --- a/XenModel/Messages.Designer.cs +++ b/XenModel/Messages.Designer.cs @@ -15288,6 +15288,15 @@ namespace XenAdmin { } } + /// + /// Looks up a localized string similar to Feature '{0}' must be enabled on all hosts in the pool before use. See release notes.. + /// + public static string FEATURE_EXPERIMENTAL { + get { + return ResourceManager.GetString("FEATURE_EXPERIMENTAL", resourceCulture); + } + } + /// /// Looks up a localized string similar to &Next Section. /// diff --git a/XenModel/Messages.resx b/XenModel/Messages.resx index 5385f7472..86a872ee5 100755 --- a/XenModel/Messages.resx +++ b/XenModel/Messages.resx @@ -5369,6 +5369,9 @@ Warning: to prevent data loss you must ensure that the LUN is not in use by any Feature disabled in the registry + + Feature '{0}' must be enabled on all hosts in the pool before use. See release notes. + Fetched possible hosts of VM {0} diff --git a/XenModel/XenAPI-Extensions/Host.cs b/XenModel/XenAPI-Extensions/Host.cs index 6c2e748b0..d123fba6d 100644 --- a/XenModel/XenAPI-Extensions/Host.cs +++ b/XenModel/XenAPI-Extensions/Host.cs @@ -455,12 +455,19 @@ namespace XenAPI { return BoolKeyPreferTrue(h.license_params, "restrict_corosync"); } - + + #region Experimental Features + public static bool CorosyncDisabled(Host h) { return RestrictCorosync(h) && FeatureDisabled(h, "corosync"); } + public static bool SriovNetworkDisabled(Host h) + { + return RestrictSriovNetwork(h) && FeatureDisabled(h, "network_sriov"); + } + public static bool FeatureDisabled(Host h, string featureName) { foreach (var feature in h.Connection.ResolveAll(h.features)) @@ -471,6 +478,8 @@ namespace XenAPI return false; } + #endregion + public bool HasPBDTo(SR sr) { foreach (XenRef pbd in PBDs)