Disable creation of SR-IOV network if the feature is disabled.

Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
This commit is contained in:
Konstantina Chremmou 2018-05-09 12:38:26 +01:00
parent 4346de5eb8
commit 3fc14c5344
4 changed files with 33 additions and 8 deletions

View File

@ -104,21 +104,25 @@ namespace XenAdmin.Wizards.NewNetworkWizard_Pages
bool hasNicCanEnableSriov = pool.Connection.Cache.PIFs.Any(pif => pif.IsPhysical() && pif.SriovCapable() && !pif.IsSriovPhysicalPIF()); bool hasNicCanEnableSriov = pool.Connection.Cache.PIFs.Any(pif => pif.IsPhysical() && pif.SriovCapable() && !pif.IsSriovPhysicalPIF());
bool sriovFeatureForbidden = Helpers.FeatureForbidden(connection, Host.RestrictSriovNetwork); bool sriovFeatureForbidden = Helpers.FeatureForbidden(connection, Host.RestrictSriovNetwork);
if( !Helpers.KolkataOrGreater(pool.Connection)) if (!Helpers.KolkataOrGreater(pool.Connection))
{ {
iconWarningSriovOption.Visible = labelWarningSriovOption.Visible = false; iconWarningSriovOption.Visible = labelWarningSriovOption.Visible = false;
rbtnSriov.Visible = labelSriov.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.Checked = false;
rbtnSriov.Enabled = labelSriov.Enabled = false; rbtnSriov.Enabled = labelSriov.Enabled = false;
labelWarningSriovOption.Text = sriovFeatureForbidden ? labelWarningSriovOption.Text =
String.Format(Messages.FEATURE_DISABLED, Messages.NETWORK_SRIOV) : Helpers.FeatureForbidden(pool.Connection, Host.SriovNetworkDisabled)
pool.HasSriovNic() ? ? String.Format(Messages.FEATURE_EXPERIMENTAL, Messages.NETWORK_SRIOV)
Messages.NICS_ARE_SRIOV_ENABLED : : sriovFeatureForbidden
Messages.SRIOV_NEED_NICSUPPORT; ? String.Format(Messages.FEATURE_DISABLED, Messages.NETWORK_SRIOV)
: pool.HasSriovNic()
? Messages.NICS_ARE_SRIOV_ENABLED
: Messages.SRIOV_NEED_NICSUPPORT;
iconWarningSriovOption.Visible = labelWarningSriovOption.Visible = true; iconWarningSriovOption.Visible = labelWarningSriovOption.Visible = true;
} }

View File

@ -15288,6 +15288,15 @@ namespace XenAdmin {
} }
} }
/// <summary>
/// Looks up a localized string similar to Feature &apos;{0}&apos; must be enabled on all hosts in the pool before use. See release notes..
/// </summary>
public static string FEATURE_EXPERIMENTAL {
get {
return ResourceManager.GetString("FEATURE_EXPERIMENTAL", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to &amp;Next Section. /// Looks up a localized string similar to &amp;Next Section.
/// </summary> /// </summary>

View File

@ -5369,6 +5369,9 @@ Warning: to prevent data loss you must ensure that the LUN is not in use by any
<data name="FEATURE_DISABLED_IN_REGISTER" xml:space="preserve"> <data name="FEATURE_DISABLED_IN_REGISTER" xml:space="preserve">
<value>Feature disabled in the registry</value> <value>Feature disabled in the registry</value>
</data> </data>
<data name="FEATURE_EXPERIMENTAL" xml:space="preserve">
<value>Feature '{0}' must be enabled on all hosts in the pool before use. See release notes.</value>
</data>
<data name="FETCHED_POSSIBLE_HOSTS" xml:space="preserve"> <data name="FETCHED_POSSIBLE_HOSTS" xml:space="preserve">
<value>Fetched possible hosts of VM {0}</value> <value>Fetched possible hosts of VM {0}</value>
</data> </data>

View File

@ -455,12 +455,19 @@ namespace XenAPI
{ {
return BoolKeyPreferTrue(h.license_params, "restrict_corosync"); return BoolKeyPreferTrue(h.license_params, "restrict_corosync");
} }
#region Experimental Features
public static bool CorosyncDisabled(Host h) public static bool CorosyncDisabled(Host h)
{ {
return RestrictCorosync(h) && FeatureDisabled(h, "corosync"); 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) public static bool FeatureDisabled(Host h, string featureName)
{ {
foreach (var feature in h.Connection.ResolveAll(h.features)) foreach (var feature in h.Connection.ResolveAll(h.features))
@ -471,6 +478,8 @@ namespace XenAPI
return false; return false;
} }
#endregion
public bool HasPBDTo(SR sr) public bool HasPBDTo(SR sr)
{ {
foreach (XenRef<PBD> pbd in PBDs) foreach (XenRef<PBD> pbd in PBDs)