From 501970dec557654229d22bb40f5e2881c343afa1 Mon Sep 17 00:00:00 2001 From: Konstantina Chremmou Date: Mon, 10 Feb 2020 15:45:16 +0000 Subject: [PATCH 01/10] Name explicitly the control to be focused on page load. No need to search through all the controls of the page. Signed-off-by: Konstantina Chremmou --- XenAdmin/Core/HelpersGUI.cs | 39 ------------------- .../NewNetworkWizard_Pages/NetWBondDetails.cs | 6 --- .../NewNetworkWizard_Pages/NetWChinDetails.cs | 2 +- .../NewNetworkWizard_Pages/NetWDetails.cs | 2 +- .../NewNetworkWizard_Pages/NetWName.cs | 2 +- .../NewSRWizard_Pages/Frontends/LVMoISCSI.cs | 2 +- .../NewSRWizard_Pages/Frontends/NFS_ISO.cs | 2 +- .../NewSRWizard_Pages/NewSrWizardNamePage.cs | 2 +- 8 files changed, 6 insertions(+), 51 deletions(-) diff --git a/XenAdmin/Core/HelpersGUI.cs b/XenAdmin/Core/HelpersGUI.cs index 79e397ec8..1fff8f345 100644 --- a/XenAdmin/Core/HelpersGUI.cs +++ b/XenAdmin/Core/HelpersGUI.cs @@ -158,45 +158,6 @@ namespace XenAdmin.Core f.Activate(); } - public static bool FocusFirstControl(Control.ControlCollection cc) - { - bool found = false; - - List controls = new List(); - foreach (Control control in cc) - controls.Add(control); - controls.Sort((c1, c2) => c1.TabIndex.CompareTo(c2.TabIndex)); - if (controls.Count > 0) - { - foreach (Control control in controls) - { - if (control.HasChildren) - { - found = FocusFirstControl(control.Controls); - } - - if (!found) - { - if (control is Label) - continue; - - if (control is TextBox && (control as TextBox).ReadOnly) - continue; - - if (control.CanSelect) - { - found = control.Focus(); - } - } - - if (found) - break; - } - } - - return found; - } - public static Dictionary CheckHostIQNsDiffer() { Dictionary hosts = new Dictionary(); diff --git a/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWBondDetails.cs b/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWBondDetails.cs index 626118d47..b48f2e0bd 100644 --- a/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWBondDetails.cs +++ b/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWBondDetails.cs @@ -32,7 +32,6 @@ using System; using System.Collections.Generic; using XenAdmin.Controls; -using XenAdmin.Core; using XenAPI; @@ -56,11 +55,6 @@ namespace XenAdmin.Wizards.NewNetworkWizard_Pages return Details.Valid; } - protected override void PageLoadedCore(PageLoadedDirection direction) - { - HelpersGUI.FocusFirstControl(Controls); - } - protected override void PageLeaveCore(PageLoadedDirection direction, ref bool cancel) { if (direction == PageLoadedDirection.Forward) diff --git a/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWChinDetails.cs b/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWChinDetails.cs index 550d95aa3..a197f1cd4 100644 --- a/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWChinDetails.cs +++ b/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWChinDetails.cs @@ -66,7 +66,7 @@ namespace XenAdmin.Wizards.NewNetworkWizard_Pages protected override void PageLoadedCore(PageLoadedDirection direction) { - HelpersGUI.FocusFirstControl(Controls); + comboInterfaces.Focus(); } public override void PopulatePage() diff --git a/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWDetails.cs b/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWDetails.cs index 6c653b4f9..6c3ff5c40 100644 --- a/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWDetails.cs +++ b/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWDetails.cs @@ -68,7 +68,7 @@ namespace XenAdmin.Wizards.NewNetworkWizard_Pages protected override void PageLoadedCore(PageLoadedDirection direction) { - HelpersGUI.FocusFirstControl(Controls); + comboBoxNICList.Focus(); } public override void PopulatePage() diff --git a/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWName.cs b/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWName.cs index 2e1c8c3d1..3d9edbf4d 100644 --- a/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWName.cs +++ b/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWName.cs @@ -61,7 +61,7 @@ namespace XenAdmin.Wizards.NewNetworkWizard_Pages protected override void PageLoadedCore(PageLoadedDirection direction) { - HelpersGUI.FocusFirstControl(Controls); + txtName.Focus(); } protected override void PageLeaveCore(PageLoadedDirection direction, ref bool cancel) diff --git a/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/LVMoISCSI.cs b/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/LVMoISCSI.cs index cef0ce681..3b089297b 100644 --- a/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/LVMoISCSI.cs +++ b/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/LVMoISCSI.cs @@ -122,7 +122,7 @@ namespace XenAdmin.Wizards.NewSRWizard_Pages.Frontends HelpersGUI.PerformIQNCheck(); if (direction == PageLoadedDirection.Forward) - HelpersGUI.FocusFirstControl(Controls); + textBoxIscsiHost.Focus(); } protected override void PageLeaveCore(PageLoadedDirection direction, ref bool cancel) diff --git a/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/NFS_ISO.cs b/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/NFS_ISO.cs index 0f5be15f6..748cd9b56 100644 --- a/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/NFS_ISO.cs +++ b/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/NFS_ISO.cs @@ -109,7 +109,7 @@ namespace XenAdmin.Wizards.NewSRWizard_Pages.Frontends protected override void PageLoadedCore(PageLoadedDirection direction) { if (direction == PageLoadedDirection.Forward) - HelpersGUI.FocusFirstControl(Controls); + NfsServerPathComboBox.Focus(); } #endregion diff --git a/XenAdmin/Wizards/NewSRWizard_Pages/NewSrWizardNamePage.cs b/XenAdmin/Wizards/NewSRWizard_Pages/NewSrWizardNamePage.cs index 09c7e96ac..bf5d7cf57 100644 --- a/XenAdmin/Wizards/NewSRWizard_Pages/NewSrWizardNamePage.cs +++ b/XenAdmin/Wizards/NewSRWizard_Pages/NewSrWizardNamePage.cs @@ -74,7 +74,7 @@ namespace XenAdmin.Wizards.NewSRWizard_Pages protected override void PageLoadedCore(PageLoadedDirection direction) { if (direction == PageLoadedDirection.Forward) - HelpersGUI.FocusFirstControl(Controls); + textBoxName.Focus(); } public override void PopulatePage() From 4ff42f51f30bcf51f6f30a77661f73824a381f11 Mon Sep 17 00:00:00 2001 From: Konstantina Chremmou Date: Tue, 11 Feb 2020 15:34:55 +0000 Subject: [PATCH 02/10] Modifications on the NewNetwork wizard (includes CA-192746). - NetworkDetails page: reworked it to fix NumericUpdown validation and messages (CA-192746). - SelectNetworkType page: moved warnings closer to the corresponding network types, fixed wrong label enabled state and made enablement logic more explicit. - All pages: property modernisation and control layout tweaks (mostly margins). Signed-off-by: Konstantina Chremmou --- XenAdmin/Controls/DiskSpinner.cs | 4 +- XenAdmin/Wizards/NewNetworkWizard.cs | 17 +- XenAdmin/Wizards/NewNetworkWizard.resx | 2 +- .../NetWBondDetails.resx | 20 +- .../NetWChinDetails.Designer.cs | 1 - .../NewNetworkWizard_Pages/NetWChinDetails.cs | 29 +- .../NetWChinDetails.resx | 123 ++-- .../NetWDetails.Designer.cs | 225 +++---- .../NewNetworkWizard_Pages/NetWDetails.cs | 323 ++++----- .../NewNetworkWizard_Pages/NetWDetails.resx | 631 ++++++++---------- .../NetWName.Designer.cs | 68 +- .../NewNetworkWizard_Pages/NetWName.cs | 25 +- .../NewNetworkWizard_Pages/NetWName.resx | 258 +++---- .../NetWSriovDetails.cs | 10 +- .../NetWSriovDetails.resx | 2 +- .../NetWTypeSelect.Designer.cs | 103 +-- .../NewNetworkWizard_Pages/NetWTypeSelect.cs | 89 ++- .../NetWTypeSelect.resx | 522 +++++++-------- XenModel/Messages.Designer.cs | 47 +- XenModel/Messages.resx | 17 +- 20 files changed, 1171 insertions(+), 1345 deletions(-) diff --git a/XenAdmin/Controls/DiskSpinner.cs b/XenAdmin/Controls/DiskSpinner.cs index 49d9449a1..1b328f9b9 100644 --- a/XenAdmin/Controls/DiskSpinner.cs +++ b/XenAdmin/Controls/DiskSpinner.cs @@ -119,7 +119,7 @@ namespace XenAdmin.Controls if (!decimal.TryParse(DiskSizeNumericUpDown.Text.Trim(), out decimal result) || result < 0) { - SetError(Messages.INVALID_NUMBER); + SetError(Messages.INVALID_DISK_SIZE); IsSizeValid = false; return; } @@ -142,7 +142,7 @@ namespace XenAdmin.Controls if (SelectedSize > DEFAULT_MAXIMUM) { - SetError(Messages.INVALID_NUMBER); + SetError(Messages.INVALID_DISK_SIZE); IsSizeValid = false; return; } diff --git a/XenAdmin/Wizards/NewNetworkWizard.cs b/XenAdmin/Wizards/NewNetworkWizard.cs index bcc56c26d..1aac00f0f 100644 --- a/XenAdmin/Wizards/NewNetworkWizard.cs +++ b/XenAdmin/Wizards/NewNetworkWizard.cs @@ -230,11 +230,8 @@ namespace XenAdmin.Wizards nic = pageNetworkDetails.SelectedHostNic; } - - long vlan = pageNetworkDetails.VLAN; - NetworkAction action = pageNetworkType.SelectedNetworkType == NetworkTypes.External - ? new NetworkAction(xenConnection, network, nic, vlan) + ? new NetworkAction(xenConnection, network, nic, pageNetworkDetails.VLAN) : new NetworkAction(xenConnection, network, true); action.RunAsync(); } @@ -251,14 +248,18 @@ namespace XenAdmin.Wizards var autoPlug = pageNetworkType.SelectedNetworkType == NetworkTypes.CHIN ? pageChinDetails.isAutomaticAddNicToVM : pageNetworkType.SelectedNetworkType == NetworkTypes.SRIOV - ? pageSriovDetails.isAutomaticAddNicToVM - : pageNetworkDetails.isAutomaticAddNicToVM; + ? pageSriovDetails.AddNicToVmsAutomatically + : pageNetworkDetails.AddNicToVmsAutomatically; result.SetAutoPlug(autoPlug); if (pageNetworkType.SelectedNetworkType == NetworkTypes.CHIN) result.MTU = pageChinDetails.MTU; - else if (pageNetworkDetails.MTU.HasValue) //Custom MTU may not be allowed if we are making a virtual network or something - result.MTU = pageNetworkDetails.MTU.Value; + else + { + int mtu = pageNetworkDetails.MTU; + if (mtu != -1) //Custom MTU may not be allowed if we are making a virtual network or something + result.MTU = mtu; + } return result; } diff --git a/XenAdmin/Wizards/NewNetworkWizard.resx b/XenAdmin/Wizards/NewNetworkWizard.resx index 392fc969f..97477c445 100644 --- a/XenAdmin/Wizards/NewNetworkWizard.resx +++ b/XenAdmin/Wizards/NewNetworkWizard.resx @@ -161,7 +161,7 @@ Tahoma, 8pt - 775, 535 + 790, 560 NewNetworkWizard diff --git a/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWBondDetails.resx b/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWBondDetails.resx index 4b847ddff..38ee26598 100644 --- a/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWBondDetails.resx +++ b/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWBondDetails.resx @@ -112,26 +112,26 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + 1 True - + Fill NoControl - + 0, 0 @@ -154,7 +154,7 @@ label1 - System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 tableLayoutPanel1 @@ -175,7 +175,7 @@ 433, 385 - 0 + 1 Details @@ -205,13 +205,13 @@ 433, 426 - 1 + 0 tableLayoutPanel1 - System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 $this @@ -222,7 +222,7 @@ <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="label1" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="Details" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /></Controls><Columns Styles="Percent,100" /><Rows Styles="AutoSize,0,Percent,100" /></TableLayoutSettings> - + True diff --git a/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWChinDetails.Designer.cs b/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWChinDetails.Designer.cs index 4b68f554d..8518e8a9e 100644 --- a/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWChinDetails.Designer.cs +++ b/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWChinDetails.Designer.cs @@ -89,7 +89,6 @@ this.tableLayoutPanel1.SetColumnSpan(this.tableLayoutPanelMTUWarning, 2); this.tableLayoutPanelMTUWarning.Controls.Add(this.pictureBox1, 0, 0); this.tableLayoutPanelMTUWarning.Controls.Add(this.labelMTUWarning, 1, 0); - this.tableLayoutPanelMTUWarning.MinimumSize = new System.Drawing.Size(0, 40); this.tableLayoutPanelMTUWarning.Name = "tableLayoutPanelMTUWarning"; // // pictureBox1 diff --git a/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWChinDetails.cs b/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWChinDetails.cs index a197f1cd4..08d2fa1f2 100644 --- a/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWChinDetails.cs +++ b/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWChinDetails.cs @@ -31,13 +31,7 @@ using System; using System.Collections.Generic; -using System.ComponentModel; -using System.Drawing; -using System.Data; -using System.Text; -using System.Windows.Forms; using XenAdmin.Controls; -using XenAdmin.Core; using XenAdmin.Network; using XenAPI; @@ -55,9 +49,9 @@ namespace XenAdmin.Wizards.NewNetworkWizard_Pages numericUpDownMTU.Visible = labelMTU.Visible = tableLayoutPanelMTUWarning.Visible = false; } - public override string Text { get { return Messages.NETW_DETAILS_TEXT; } } - - public override string PageTitle { get { return Messages.NETW_CHIN_DETAILS_TITLE; } } + public override string Text => Messages.NETW_DETAILS_TEXT; + + public override string PageTitle => Messages.NETW_CHIN_DETAILS_TITLE; public override bool EnableNext() { @@ -77,20 +71,11 @@ namespace XenAdmin.Wizards.NewNetworkWizard_Pages public Host Host { private get; set; } public Pool Pool { private get; set; } - public XenAPI.Network SelectedInterface - { - get { return (XenAPI.Network)comboInterfaces.SelectedItem; } - } + public XenAPI.Network SelectedInterface => (XenAPI.Network)comboInterfaces.SelectedItem; - public bool isAutomaticAddNicToVM - { - get { return cbxAutomatic.Checked; } - } + public bool isAutomaticAddNicToVM => cbxAutomatic.Checked; - public long MTU - { - get { return (long)numericUpDownMTU.Value; } - } + public long MTU => (long)numericUpDownMTU.Value; private void PopulateInterfaces(Pool pool, Host host, IXenConnection connection) { @@ -116,7 +101,7 @@ namespace XenAdmin.Wizards.NewNetworkWizard_Pages } } } - comboInterfaces.SelectedIndexChanged += new EventHandler(comboInterfaces_SelectedIndexChanged); + comboInterfaces.SelectedIndexChanged += comboInterfaces_SelectedIndexChanged; if (comboInterfaces.Items.Count > 0) comboInterfaces.SelectedIndex = 0; diff --git a/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWChinDetails.resx b/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWChinDetails.resx index cd417bf70..0790569d7 100644 --- a/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWChinDetails.resx +++ b/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWChinDetails.resx @@ -112,40 +112,37 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + True - - - TopLeft - 2 True - + NoControl + - 0, 0 + 3, 0 - 0, 0, 0, 30 + 3, 0, 3, 30 - 491, 26 + 461, 26 - 101 + 0 Select a management interface for the new network to use and configure any additional settings before proceeding. @@ -158,7 +155,7 @@ lblNicHelp - System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 tableLayoutPanel1 @@ -170,22 +167,19 @@ Top, Left, Right - 119, 56 - - - 0, 0, 0, 0 + 125, 59 - 374, 21 + 365, 21 - 1 + 2 comboInterfaces - System.Windows.Forms.ComboBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 tableLayoutPanel1 @@ -193,23 +187,20 @@ 1 + + Left + True - - Fill - - 0, 56 - - - 0, 0, 3, 0 + 3, 63 - 116, 21 + 116, 13 - 0 + 1 &Management interface: @@ -221,7 +212,7 @@ label2 - System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 tableLayoutPanel1 @@ -236,17 +227,11 @@ 2 - 0, 0 - - - 0, 0, 3, 0 + 3, 3 16, 16 - - AutoSize - 1 @@ -254,7 +239,7 @@ pictureBox1 - System.Windows.Forms.PictureBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Windows.Forms.PictureBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 tableLayoutPanelMTUWarning @@ -266,19 +251,16 @@ True - Fill + Top NoControl - 19, 0 - - - 0, 0, 0, 0 + 25, 0 - 474, 45 + 465, 26 0 @@ -290,7 +272,7 @@ labelMTUWarning - System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 tableLayoutPanelMTUWarning @@ -307,14 +289,17 @@ 0, 0, 0, 0 + + 0, 40 + 1 - 493, 45 + 493, 40 - 102 + 5 False @@ -323,7 +308,7 @@ tableLayoutPanelMTUWarning - System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 tableLayoutPanel1 @@ -334,23 +319,20 @@ <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="pictureBox1" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="labelMTUWarning" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /></Controls><Columns Styles="AutoSize,50,Percent,50" /><Rows Styles="Percent,50" /></TableLayoutSettings> + + Left + True - - Fill - - 0, 84 - - - 0, 7, 3, 5 + 3, 89 - 116, 20 + 34, 13 - 2 + 3 MTU: @@ -362,7 +344,7 @@ labelMTU - System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 tableLayoutPanel1 @@ -371,22 +353,19 @@ 5 - 119, 84 - - - 0, 7, 0, 5 + 125, 86 96, 20 - 3 + 4 numericUpDownMTU - System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 tableLayoutPanel1 @@ -407,13 +386,13 @@ 493, 276 - 5 + 0 tableLayoutPanel1 - System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 $this @@ -422,22 +401,22 @@ 0 - <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="lblNicHelp" Row="0" RowSpan="1" Column="0" ColumnSpan="2" /><Control Name="comboInterfaces" Row="1" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="label2" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="cbxAutomatic" Row="4" RowSpan="1" Column="0" ColumnSpan="2" /><Control Name="tableLayoutPanelMTUWarning" Row="3" RowSpan="1" Column="0" ColumnSpan="2" /><Control Name="labelMTU" Row="2" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="numericUpDownMTU" Row="2" RowSpan="1" Column="1" ColumnSpan="1" /></Controls><Columns Styles="AutoSize,0,Percent,100" /><Rows Styles="AutoSize,0,AutoSize,0,AutoSize,0,Absolute,45,Percent,100,Absolute,20" /></TableLayoutSettings> + <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="lblNicHelp" Row="0" RowSpan="1" Column="0" ColumnSpan="2" /><Control Name="comboInterfaces" Row="1" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="label2" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="cbxAutomatic" Row="4" RowSpan="1" Column="0" ColumnSpan="2" /><Control Name="tableLayoutPanelMTUWarning" Row="3" RowSpan="1" Column="0" ColumnSpan="2" /><Control Name="labelMTU" Row="2" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="numericUpDownMTU" Row="2" RowSpan="1" Column="1" ColumnSpan="1" /></Controls><Columns Styles="AutoSize,0,Percent,100" /><Rows Styles="AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,Percent,100" /></TableLayoutSettings> NoControl - 3, 161 + 3, 159 - 3, 7, 3, 3 + 3, 10, 3, 3 286, 17 - 4 + 6 &Automatically add this network to new virtual machines. @@ -449,7 +428,7 @@ cbxAutomatic - System.Windows.Forms.CheckBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 tableLayoutPanel1 @@ -457,7 +436,7 @@ 3 - + True diff --git a/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWDetails.Designer.cs b/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWDetails.Designer.cs index 6cc3cfb9e..6130ddc7f 100644 --- a/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWDetails.Designer.cs +++ b/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWDetails.Designer.cs @@ -29,112 +29,66 @@ namespace XenAdmin.Wizards.NewNetworkWizard_Pages private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(NetWDetails)); - this.panel1 = new System.Windows.Forms.Panel(); this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); - this.infoMtuPanel = new System.Windows.Forms.Panel(); - this.infoMtuMessage = new System.Windows.Forms.Label(); - this.pictureBox2 = new System.Windows.Forms.PictureBox(); + this.labelExternal = new System.Windows.Forms.Label(); + this.labelInternal = new System.Windows.Forms.Label(); this.labelNIC = new System.Windows.Forms.Label(); - this.labelVLAN = new System.Windows.Forms.Label(); - this.lblNicHelp = new System.Windows.Forms.Label(); - this.numericUpDownVLAN = new System.Windows.Forms.NumericUpDown(); this.comboBoxNICList = new System.Windows.Forms.ComboBox(); + this.labelVLAN = new System.Windows.Forms.Label(); + this.numericUpDownVLAN = new System.Windows.Forms.NumericUpDown(); + this.infoVlanPanel = new System.Windows.Forms.TableLayoutPanel(); + this.pictureBoxVlan = new System.Windows.Forms.PictureBox(); + this.labelVlanMessage = new System.Windows.Forms.Label(); this.labelMTU = new System.Windows.Forms.Label(); this.numericUpDownMTU = new System.Windows.Forms.NumericUpDown(); - this.panelVLANInfo = new System.Windows.Forms.Panel(); - this.labelVlanError = new System.Windows.Forms.Label(); - this.labelVLAN0Info = new System.Windows.Forms.Label(); - this.checkBoxAutomatic = new System.Windows.Forms.CheckBox(); + this.infoMtuPanel = new System.Windows.Forms.TableLayoutPanel(); + this.pictureBoxMtu = new System.Windows.Forms.PictureBox(); + this.labelMtuMessage = new System.Windows.Forms.Label(); this.checkBoxSriov = new System.Windows.Forms.CheckBox(); - this.panel1.SuspendLayout(); + this.checkBoxAutomatic = new System.Windows.Forms.CheckBox(); this.tableLayoutPanel1.SuspendLayout(); - this.infoMtuPanel.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDownVLAN)).BeginInit(); + this.infoVlanPanel.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxVlan)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMTU)).BeginInit(); - this.panelVLANInfo.SuspendLayout(); + this.infoMtuPanel.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxMtu)).BeginInit(); this.SuspendLayout(); // - // panel1 - // - resources.ApplyResources(this.panel1, "panel1"); - this.panel1.BackColor = System.Drawing.SystemColors.Control; - this.panel1.Controls.Add(this.tableLayoutPanel1); - this.panel1.Name = "panel1"; - // // tableLayoutPanel1 // resources.ApplyResources(this.tableLayoutPanel1, "tableLayoutPanel1"); - this.tableLayoutPanel1.Controls.Add(this.infoMtuPanel, 2, 3); - this.tableLayoutPanel1.Controls.Add(this.labelNIC, 0, 1); - this.tableLayoutPanel1.Controls.Add(this.labelVLAN, 0, 2); - this.tableLayoutPanel1.Controls.Add(this.lblNicHelp, 0, 0); - this.tableLayoutPanel1.Controls.Add(this.numericUpDownVLAN, 1, 2); - this.tableLayoutPanel1.Controls.Add(this.comboBoxNICList, 1, 1); - this.tableLayoutPanel1.Controls.Add(this.labelMTU, 0, 3); - this.tableLayoutPanel1.Controls.Add(this.numericUpDownMTU, 1, 3); - this.tableLayoutPanel1.Controls.Add(this.panelVLANInfo, 2, 2); - this.tableLayoutPanel1.Controls.Add(this.checkBoxAutomatic, 0, 5); - this.tableLayoutPanel1.Controls.Add(this.checkBoxSriov, 0, 4); + this.tableLayoutPanel1.Controls.Add(this.labelExternal, 0, 0); + this.tableLayoutPanel1.Controls.Add(this.labelInternal, 0, 1); + this.tableLayoutPanel1.Controls.Add(this.labelNIC, 0, 2); + this.tableLayoutPanel1.Controls.Add(this.comboBoxNICList, 1, 2); + this.tableLayoutPanel1.Controls.Add(this.labelVLAN, 0, 3); + this.tableLayoutPanel1.Controls.Add(this.numericUpDownVLAN, 1, 3); + this.tableLayoutPanel1.Controls.Add(this.infoVlanPanel, 2, 3); + this.tableLayoutPanel1.Controls.Add(this.labelMTU, 0, 4); + this.tableLayoutPanel1.Controls.Add(this.numericUpDownMTU, 1, 4); + this.tableLayoutPanel1.Controls.Add(this.infoMtuPanel, 2, 4); + this.tableLayoutPanel1.Controls.Add(this.checkBoxSriov, 0, 5); + this.tableLayoutPanel1.Controls.Add(this.checkBoxAutomatic, 0, 6); this.tableLayoutPanel1.Name = "tableLayoutPanel1"; // - // infoMtuPanel + // labelExternal // - resources.ApplyResources(this.infoMtuPanel, "infoMtuPanel"); - this.tableLayoutPanel1.SetColumnSpan(this.infoMtuPanel, 2); - this.infoMtuPanel.Controls.Add(this.infoMtuMessage); - this.infoMtuPanel.Controls.Add(this.pictureBox2); - this.infoMtuPanel.Name = "infoMtuPanel"; + resources.ApplyResources(this.labelExternal, "labelExternal"); + this.tableLayoutPanel1.SetColumnSpan(this.labelExternal, 4); + this.labelExternal.Name = "labelExternal"; // - // infoMtuMessage + // labelInternal // - resources.ApplyResources(this.infoMtuMessage, "infoMtuMessage"); - this.infoMtuMessage.Name = "infoMtuMessage"; - // - // pictureBox2 - // - resources.ApplyResources(this.pictureBox2, "pictureBox2"); - this.pictureBox2.Image = global::XenAdmin.Properties.Resources._000_Info3_h32bit_16; - this.pictureBox2.Name = "pictureBox2"; - this.pictureBox2.TabStop = false; + resources.ApplyResources(this.labelInternal, "labelInternal"); + this.tableLayoutPanel1.SetColumnSpan(this.labelInternal, 4); + this.labelInternal.Name = "labelInternal"; // // labelNIC // resources.ApplyResources(this.labelNIC, "labelNIC"); this.labelNIC.Name = "labelNIC"; // - // labelVLAN - // - resources.ApplyResources(this.labelVLAN, "labelVLAN"); - this.labelVLAN.Name = "labelVLAN"; - // - // lblNicHelp - // - resources.ApplyResources(this.lblNicHelp, "lblNicHelp"); - this.tableLayoutPanel1.SetColumnSpan(this.lblNicHelp, 4); - this.lblNicHelp.Name = "lblNicHelp"; - // - // numericUpDownVLAN - // - resources.ApplyResources(this.numericUpDownVLAN, "numericUpDownVLAN"); - this.numericUpDownVLAN.Maximum = new decimal(new int[] { - 4094, - 0, - 0, - 0}); - this.numericUpDownVLAN.Minimum = new decimal(new int[] { - 1, - 0, - 0, - 0}); - this.numericUpDownVLAN.Name = "numericUpDownVLAN"; - this.numericUpDownVLAN.Value = new decimal(new int[] { - 1, - 0, - 0, - 0}); - this.numericUpDownVLAN.ValueChanged += new System.EventHandler(this.nudVLAN_ValueChanged); - // // comboBoxNICList // this.tableLayoutPanel1.SetColumnSpan(this.comboBoxNICList, 2); @@ -146,6 +100,37 @@ namespace XenAdmin.Wizards.NewNetworkWizard_Pages this.comboBoxNICList.Sorted = true; this.comboBoxNICList.SelectedIndexChanged += new System.EventHandler(this.cmbHostNicList_SelectedIndexChanged); // + // labelVLAN + // + resources.ApplyResources(this.labelVLAN, "labelVLAN"); + this.labelVLAN.Name = "labelVLAN"; + // + // numericUpDownVLAN + // + resources.ApplyResources(this.numericUpDownVLAN, "numericUpDownVLAN"); + this.numericUpDownVLAN.Name = "numericUpDownVLAN"; + this.numericUpDownVLAN.ValueChanged += new System.EventHandler(this.numericUpDownVLAN_ValueChanged); + this.numericUpDownVLAN.Leave += new System.EventHandler(this.numericUpDownVLAN_Leave); + // + // infoVlanPanel + // + resources.ApplyResources(this.infoVlanPanel, "infoVlanPanel"); + this.tableLayoutPanel1.SetColumnSpan(this.infoVlanPanel, 2); + this.infoVlanPanel.Controls.Add(this.pictureBoxVlan, 0, 0); + this.infoVlanPanel.Controls.Add(this.labelVlanMessage, 1, 0); + this.infoVlanPanel.Name = "infoVlanPanel"; + // + // pictureBoxVlan + // + resources.ApplyResources(this.pictureBoxVlan, "pictureBoxVlan"); + this.pictureBoxVlan.Name = "pictureBoxVlan"; + this.pictureBoxVlan.TabStop = false; + // + // labelVlanMessage + // + resources.ApplyResources(this.labelVlanMessage, "labelVlanMessage"); + this.labelVlanMessage.Name = "labelVlanMessage"; + // // labelMTU // resources.ApplyResources(this.labelMTU, "labelMTU"); @@ -155,33 +140,27 @@ namespace XenAdmin.Wizards.NewNetworkWizard_Pages // resources.ApplyResources(this.numericUpDownMTU, "numericUpDownMTU"); this.numericUpDownMTU.Name = "numericUpDownMTU"; + this.numericUpDownMTU.ValueChanged += new System.EventHandler(this.numericUpDownMTU_ValueChanged); + this.numericUpDownMTU.Leave += new System.EventHandler(this.numericUpDownMTU_Leave); // - // panelVLANInfo + // infoMtuPanel // - resources.ApplyResources(this.panelVLANInfo, "panelVLANInfo"); - this.tableLayoutPanel1.SetColumnSpan(this.panelVLANInfo, 2); - this.panelVLANInfo.Controls.Add(this.labelVlanError); - this.panelVLANInfo.Controls.Add(this.labelVLAN0Info); - this.panelVLANInfo.Name = "panelVLANInfo"; + resources.ApplyResources(this.infoMtuPanel, "infoMtuPanel"); + this.tableLayoutPanel1.SetColumnSpan(this.infoMtuPanel, 2); + this.infoMtuPanel.Controls.Add(this.pictureBoxMtu, 0, 0); + this.infoMtuPanel.Controls.Add(this.labelMtuMessage, 1, 0); + this.infoMtuPanel.Name = "infoMtuPanel"; // - // labelVlanError + // pictureBoxMtu // - resources.ApplyResources(this.labelVlanError, "labelVlanError"); - this.labelVlanError.ForeColor = System.Drawing.Color.Red; - this.labelVlanError.Name = "labelVlanError"; + resources.ApplyResources(this.pictureBoxMtu, "pictureBoxMtu"); + this.pictureBoxMtu.Name = "pictureBoxMtu"; + this.pictureBoxMtu.TabStop = false; // - // labelVLAN0Info + // labelMtuMessage // - resources.ApplyResources(this.labelVLAN0Info, "labelVLAN0Info"); - this.labelVLAN0Info.ForeColor = System.Drawing.SystemColors.ControlText; - this.labelVLAN0Info.Name = "labelVLAN0Info"; - // - // checkBoxAutomatic - // - resources.ApplyResources(this.checkBoxAutomatic, "checkBoxAutomatic"); - this.tableLayoutPanel1.SetColumnSpan(this.checkBoxAutomatic, 4); - this.checkBoxAutomatic.Name = "checkBoxAutomatic"; - this.checkBoxAutomatic.UseVisualStyleBackColor = true; + resources.ApplyResources(this.labelMtuMessage, "labelMtuMessage"); + this.labelMtuMessage.Name = "labelMtuMessage"; // // checkBoxSriov // @@ -191,45 +170,51 @@ namespace XenAdmin.Wizards.NewNetworkWizard_Pages this.checkBoxSriov.UseVisualStyleBackColor = true; this.checkBoxSriov.CheckedChanged += new System.EventHandler(this.checkBoxSriov_CheckedChanged); // + // checkBoxAutomatic + // + resources.ApplyResources(this.checkBoxAutomatic, "checkBoxAutomatic"); + this.tableLayoutPanel1.SetColumnSpan(this.checkBoxAutomatic, 4); + this.checkBoxAutomatic.Name = "checkBoxAutomatic"; + this.checkBoxAutomatic.UseVisualStyleBackColor = true; + // // NetWDetails // resources.ApplyResources(this, "$this"); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; this.BackColor = System.Drawing.SystemColors.Control; - this.Controls.Add(this.panel1); + this.Controls.Add(this.tableLayoutPanel1); this.Name = "NetWDetails"; - this.panel1.ResumeLayout(false); this.tableLayoutPanel1.ResumeLayout(false); this.tableLayoutPanel1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownVLAN)).EndInit(); + this.infoVlanPanel.ResumeLayout(false); + this.infoVlanPanel.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxVlan)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMTU)).EndInit(); this.infoMtuPanel.ResumeLayout(false); this.infoMtuPanel.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownVLAN)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMTU)).EndInit(); - this.panelVLANInfo.ResumeLayout(false); - this.panelVLANInfo.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxMtu)).EndInit(); this.ResumeLayout(false); } #endregion - - private System.Windows.Forms.Panel panel1; private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; private System.Windows.Forms.Label labelNIC; private System.Windows.Forms.ComboBox comboBoxNICList; - private System.Windows.Forms.NumericUpDown numericUpDownVLAN; private System.Windows.Forms.Label labelVLAN; - private System.Windows.Forms.Label lblNicHelp; + private System.Windows.Forms.Label labelInternal; private System.Windows.Forms.CheckBox checkBoxAutomatic; - private System.Windows.Forms.Label labelVlanError; private System.Windows.Forms.Label labelMTU; - private System.Windows.Forms.NumericUpDown numericUpDownMTU; - private System.Windows.Forms.Panel panelVLANInfo; - private System.Windows.Forms.Label labelVLAN0Info; - private System.Windows.Forms.Panel infoMtuPanel; - private System.Windows.Forms.Label infoMtuMessage; - private System.Windows.Forms.PictureBox pictureBox2; + private System.Windows.Forms.Label labelMtuMessage; + private System.Windows.Forms.PictureBox pictureBoxMtu; private System.Windows.Forms.CheckBox checkBoxSriov; + private System.Windows.Forms.Label labelExternal; + private System.Windows.Forms.TableLayoutPanel infoMtuPanel; + private System.Windows.Forms.TableLayoutPanel infoVlanPanel; + private System.Windows.Forms.PictureBox pictureBoxVlan; + private System.Windows.Forms.Label labelVlanMessage; + private System.Windows.Forms.NumericUpDown numericUpDownVLAN; + private System.Windows.Forms.NumericUpDown numericUpDownMTU; } } diff --git a/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWDetails.cs b/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWDetails.cs index 6c3ff5c40..522b41625 100644 --- a/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWDetails.cs +++ b/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWDetails.cs @@ -40,56 +40,84 @@ namespace XenAdmin.Wizards.NewNetworkWizard_Pages { public partial class NetWDetails : XenTabPage { - List vlans; + private List vlans; + private bool _vlanError; + private bool _mtuError; + private bool _populatingNics; public NetWDetails() { InitializeComponent(); - numericUpDownVLAN.LostFocus += checkVLAN; + //non-browsable events numericUpDownVLAN.TextChanged += numericUpDownVLAN_TextChanged; + numericUpDownMTU.TextChanged += numericUpDownMTU_TextChanged; + numericUpDownMTU.Maximum = XenAPI.Network.MTU_MAX; numericUpDownMTU.Minimum = XenAPI.Network.MTU_MIN; numericUpDownMTU.Value = XenAPI.Network.MTU_DEFAULT; + numericUpDownVLAN.Maximum = 4094; } - public override string Text { get { return Messages.NETW_DETAILS_TEXT; } } + public override string Text => Messages.NETW_DETAILS_TEXT; - public override string PageTitle { get - { - return SelectedNetworkType == NetworkTypes.External - ? Messages.NETW_EXTERNAL_DETAILS_TITLE - : Messages.NETW_INTERNAL_DETAILS_TITLE; - } } + public override string PageTitle => + SelectedNetworkType == NetworkTypes.External + ? Messages.NETW_EXTERNAL_DETAILS_TITLE + : Messages.NETW_INTERNAL_DETAILS_TITLE; public override bool EnableNext() { - return (SelectedHostNic != null || !comboBoxNICList.Visible) && !labelVlanError.Visible; - } + if (_vlanError || _mtuError) + return false; - protected override void PageLoadedCore(PageLoadedDirection direction) - { - comboBoxNICList.Focus(); + return SelectedHostNic != null || !comboBoxNICList.Visible; } public override void PopulatePage() { - PopulateHostNicList(Host, Connection); - UpdateEnablement(SelectedNetworkType == NetworkTypes.External, Host); - //set minimum value for VLAN - numericUpDownVLAN.Minimum = Helpers.VLAN0Allowed(Connection) ? 0 : 1; - } + var external = SelectedNetworkType == NetworkTypes.External; - private int CurrentVLANValue - { - get { return Convert.ToInt32(Math.Round(numericUpDownVLAN.Value, MidpointRounding.AwayFromZero)); } - } + labelExternal.Visible = external; + labelInternal.Visible = !external; + labelNIC.Visible = external; + comboBoxNICList.Visible = external; - private void checkVLAN(object sender, EventArgs e) - { - if (numericUpDownVLAN.Text == "") + if (comboBoxNICList.Visible) { - numericUpDownVLAN.Text = CurrentVLANValue.ToString(); + try + { + _populatingNics = true; + comboBoxNICList.Items.Clear(); + + foreach (PIF ThePIF in Connection.Cache.PIFs) + { + if (ThePIF.host.opaque_ref == Host.opaque_ref && ThePIF.IsPhysical() && + (Properties.Settings.Default.ShowHiddenVMs || ThePIF.Show(Properties.Settings.Default.ShowHiddenVMs)) && + !ThePIF.IsBondSlave()) + { + comboBoxNICList.Items.Add(ThePIF); + } + } + } + finally + { + _populatingNics = false; + } + + if (comboBoxNICList.Items.Count > 0) + comboBoxNICList.SelectedIndex = 0; + + comboBoxNICList.Focus(); } + + labelVLAN.Visible = external; + numericUpDownVLAN.Visible = external; + numericUpDownVLAN.Minimum = Helpers.VLAN0Allowed(Connection) ? 0 : 1; + numericUpDownMTU.Visible = labelMTU.Visible = infoMtuPanel.Visible = external; + + checkBoxSriov.Visible = SelectedHostNic != null && SelectedHostNic.IsSriovPhysicalPIF(); + + OnPageUpdated(); } #region Accessors @@ -98,191 +126,186 @@ namespace XenAdmin.Wizards.NewNetworkWizard_Pages public Host Host { private get; set; } - public PIF SelectedHostNic - { - get { return (PIF)comboBoxNICList.SelectedItem; } - } + public PIF SelectedHostNic => comboBoxNICList.SelectedItem as PIF; - public long VLAN - { - get { return CurrentVLANValue; } - } + public int VLAN => Convert.ToInt32(Math.Round(numericUpDownVLAN.Value, MidpointRounding.AwayFromZero)); - public bool isAutomaticAddNicToVM - { - get { return checkBoxAutomatic.Checked; } - } + public bool AddNicToVmsAutomatically => checkBoxAutomatic.Checked; - public bool CreateVlanOnSriovNetwork - { - get { return checkBoxSriov.Visible && checkBoxSriov.Checked; } - } + public bool CreateVlanOnSriovNetwork => checkBoxSriov.Visible && checkBoxSriov.Checked; /// - /// Null if the custom MTU option is disabled + /// Returns -1 if the custom MTU option is disabled /// - public long? MTU - { - get - { - if (numericUpDownMTU.Enabled) - return (long)numericUpDownMTU.Value; - else - return null; - } - } + public int MTU => numericUpDownMTU.Visible && numericUpDownMTU.Enabled + ? Convert.ToInt32(Math.Round(numericUpDownMTU.Value, MidpointRounding.AwayFromZero)) + : -1; #endregion - private void UpdateEnablement(bool external, Host host) + private List GetVLANList(PIF nic) { - lblNicHelp.Text = external ? Messages.WIZARD_DESC_NETWORK_SETTINGS_EXTERNAL : Messages.WIZARD_DESC_NETWORK_SETTINGS_INTERNAL; - comboBoxNICList.Visible = external; - labelVLAN.Visible = external; - numericUpDownVLAN.Visible = external; - numericUpDownMTU.Visible = labelMTU.Visible = infoMtuPanel.Visible = external; - labelNIC.Visible = external; - if (comboBoxNICList.Items.Count > 0) - comboBoxNICList.SelectedIndex = external ? comboBoxNICList.Items.Count - 1 : -1; - checkBoxSriov.Visible = SelectedHostNic != null && SelectedHostNic.IsSriovPhysicalPIF(); + List vlans = new List(); + foreach (PIF pif in nic.Connection.Cache.PIFs) + { + if (pif.device == nic.device) + { + var pifIsSriov = pif.NetworkSriov() != null; + if ((CreateVlanOnSriovNetwork && pifIsSriov) || (!CreateVlanOnSriovNetwork && !pifIsSriov)) + vlans.Add((int)pif.VLAN); + } + } + + return vlans; + } + + private void ValidateVLANValue() + { + //CA-192746: do not call numericUpDown.Value or properties/methods that call it + //in the validation method, because it auto-corrects what the user has typed + + _vlanError = false; + string msg = null; + + if (!int.TryParse(numericUpDownVLAN.Text.Trim(), out int currentValue)) + { + _vlanError = true; + msg = Messages.INVALID_NUMBER; + } + else if (currentValue < numericUpDownVLAN.Minimum || numericUpDownVLAN.Maximum < currentValue) + { + _vlanError = true; + msg = string.Format(Messages.NETW_DETAILS_VLAN_RANGE, numericUpDownVLAN.Minimum, numericUpDownVLAN.Maximum); + } + else if (vlans != null && vlans.Contains(currentValue)) + { + _vlanError = true; + msg = Messages.NETW_DETAILS_VLAN_NUMBER_IN_USE; + } + else if (currentValue == 0) + { + msg = Messages.NETW_VLAN_ZERO; + } + + if (_vlanError) + { + pictureBoxVlan.Image = Images.StaticImages._000_error_h32bit_16; + labelVlanMessage.Text = msg; + infoVlanPanel.Visible = true; + } + else if (!string.IsNullOrEmpty(msg)) + { + pictureBoxVlan.Image = Images.StaticImages._000_Info3_h32bit_16; + labelVlanMessage.Text = msg; + infoVlanPanel.Visible = true; + } + else + infoVlanPanel.Visible = false; OnPageUpdated(); } - private void PopulateHostNicList(Host host, IXenConnection conn) + private void ValidateMtuValue() { - comboBoxNICList.Items.Clear(); + //CA-192746: do not call numericUpDown.Value or properties/methods that call it + //in the validation method, because it auto-corrects what the user has typed - foreach (PIF ThePIF in conn.Cache.PIFs) + _mtuError = false; + + if (!int.TryParse(numericUpDownMTU.Text.Trim(), out int currentValue)) { - if (ThePIF.host.opaque_ref == host.opaque_ref && ThePIF.IsPhysical() && (Properties.Settings.Default.ShowHiddenVMs || ThePIF.Show(Properties.Settings.Default.ShowHiddenVMs)) && !ThePIF.IsBondSlave()) - { - comboBoxNICList.Items.Add(ThePIF); - } + _mtuError = true; + pictureBoxMtu.Image = Images.StaticImages._000_error_h32bit_16; + labelMtuMessage.Text = Messages.INVALID_NUMBER; } - if (comboBoxNICList.Items.Count > 0) - comboBoxNICList.SelectedIndex = 0; - - cmbHostNicList_SelectedIndexChanged(null, null); - } - - private List GetVLANList(PIF nic) - { - List vlans = new List(); - foreach (PIF pif in nic.Connection.Cache.PIFs) - { - if (pif.device == nic.device) - { - var pifIsSriov = pif.NetworkSriov() != null; - if ((CreateVlanOnSriovNetwork && pifIsSriov) || (!CreateVlanOnSriovNetwork && !pifIsSriov)) - vlans.Add((int)pif.VLAN); - } - } - - return vlans; - } - - private int GetFirstAvailableVLAN(List vlans) - { - //CA-19111: VLAN values should only go up to the numericUpDownVLAN.Maximum (4094) - for (int i = 1; i <= numericUpDownVLAN.Maximum; i++) + else { - if (!vlans.Contains(i)) - return i; + if (currentValue < numericUpDownMTU.Minimum || numericUpDownMTU.Maximum < currentValue) + _mtuError = true; + + pictureBoxMtu.Image = Images.StaticImages._000_Info3_h32bit_16; + labelMtuMessage.Text = numericUpDownMTU.Minimum == numericUpDownMTU.Maximum + ? string.Format(Messages.ALLOWED_MTU_VALUE, numericUpDownMTU.Minimum) + : string.Format(Messages.ALLOWED_MTU_RANGE, numericUpDownMTU.Minimum, numericUpDownMTU.Maximum); } - return -1; + infoMtuPanel.Visible = true; + OnPageUpdated(); } + #region Event Handlers + private void cmbHostNicList_SelectedIndexChanged(object sender, EventArgs e) { - OnPageUpdated(); - - if (SelectedHostNic == null) + if (_populatingNics || SelectedHostNic == null) return; checkBoxSriov.Visible = SelectedHostNic.IsSriovPhysicalPIF(); numericUpDownMTU.Maximum = Math.Min(SelectedHostNic.MTU, XenAPI.Network.MTU_MAX); - numericUpDownMTU.Enabled = numericUpDownMTU.Minimum != numericUpDownMTU.Maximum; - - infoMtuMessage.Text = numericUpDownMTU.Minimum == numericUpDownMTU.Maximum - ? string.Format(Messages.ALLOWED_MTU_VALUE, numericUpDownMTU.Minimum) - : string.Format(Messages.ALLOWED_MTU_RANGE, numericUpDownMTU.Minimum, numericUpDownMTU.Maximum); + ValidateMtuValue(); vlans = GetVLANList(SelectedHostNic); //CA-72484: check whether the currently selected VLAN is available and keep it - int curVlan = CurrentVLANValue; - if (!vlans.Contains(curVlan)) + if (!vlans.Contains(VLAN)) { - SetError(null); + ValidateVLANValue(); return; } - int avail_vlan = GetFirstAvailableVLAN(vlans); + //CA-19111: VLAN values should only go up to the numericUpDownVLAN.Maximum (4094) + for (int i = 1; i <= numericUpDownVLAN.Maximum; i++) + { + if (!vlans.Contains(i)) + { + numericUpDownVLAN.Value = i; + break; + } + } - if (avail_vlan == -1) - return; - - numericUpDownVLAN.Value = avail_vlan; + OnPageUpdated(); } - private void nudVLAN_ValueChanged(object sender, EventArgs e) + private void numericUpDownVLAN_Leave(object sender, EventArgs e) + { + if (numericUpDownVLAN.Text == "") + numericUpDownVLAN.Text = VLAN.ToString(); + } + + private void numericUpDownVLAN_TextChanged(object sender, EventArgs e) { ValidateVLANValue(); } - void numericUpDownVLAN_TextChanged(object sender, EventArgs e) + private void numericUpDownVLAN_ValueChanged(object sender, EventArgs e) { ValidateVLANValue(); } - private void SetError(string error) + private void numericUpDownMTU_Leave(object sender, EventArgs e) { - bool visible = !string.IsNullOrEmpty(error); - bool updatePage = labelVlanError.Visible != visible; - labelVlanError.Visible = visible; - if (visible) - labelVlanError.Text = error; - labelVLAN0Info.Visible = !visible && numericUpDownVLAN.Value == 0; - if (updatePage) - OnPageUpdated(); + if (numericUpDownMTU.Text == "") + numericUpDownMTU.Text = MTU.ToString(); } - private bool VLANValidNumber() + private void numericUpDownMTU_TextChanged(object sender, EventArgs e) { - int result; - return int.TryParse(numericUpDownVLAN.Text.Trim(), out result); + ValidateMtuValue(); } - private bool VLANNumberUnique() + private void numericUpDownMTU_ValueChanged(object sender, EventArgs e) { - if (vlans == null) - return true; - return !vlans.Contains(CurrentVLANValue); - } - - private void ValidateVLANValue() - { - if (!VLANValidNumber()) - { - SetError(Messages.INVALID_NUMBER); - return; - } - if (!VLANNumberUnique()) - { - SetError(Messages.NETW_DETAILS_VLAN_NUMBER_IN_USE); - return; - } - SetError(null); + ValidateMtuValue(); } private void checkBoxSriov_CheckedChanged(object sender, EventArgs e) { - vlans = GetVLANList(SelectedHostNic); + vlans = GetVLANList(SelectedHostNic); ValidateVLANValue(); } + + #endregion } } diff --git a/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWDetails.resx b/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWDetails.resx index 84a0b4649..27b5af945 100644 --- a/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWDetails.resx +++ b/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWDetails.resx @@ -117,141 +117,102 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Top, Bottom, Left, Right - 4 - - Left - - + True - - True - - - Fill - - - NoControl + + + Top - - 16, 0 + + 3, 0 - - 0, 0, 0, 0 + + 3, 0, 3, 25 - - 3, 2, 0, 0 + + 523, 26 - - 294, 15 - - + 0 - - MTU cannot be changed (the only valid value is already set) + + Your new network will be mapped to an existing physical network interface and assigned a VLAN number to use on that interface. You can select the physical interface you would like to use below. - - infoMtuMessage + + labelExternal - + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - infoMtuPanel - - - 0 - - - Left - - - NoControl - - - 0, 0 - - - 16, 15 - - - AutoSize - - - 0 - - - pictureBox2 - - - System.Windows.Forms.PictureBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - infoMtuPanel - - - 1 - - - 164, 136 - - - 6, 0, 0, 2 - - - 310, 15 - - - 17 - - - infoMtuPanel - - - System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - + tableLayoutPanel1 - + 0 + + True + + + NoControl + + + 3, 51 + + + 3, 0, 3, 25 + + + 367, 13 + + + 1 + + + Select whether you would like to automatically add this network to new VMs. + + + MiddleLeft + + + labelInternal + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tableLayoutPanel1 + + + 1 + + + Left + True - - Fill - NoControl - 0, 72 - - - 0, 0, 3, 0 + 3, 96 - 35, 27 + 28, 13 - 0 + 2 NI&C: - - MiddleLeft - labelNIC @@ -262,28 +223,46 @@ tableLayoutPanel1 - 1 + 2 + + + 47, 92 + + + 241, 21 + + + 3 + + + comboBoxNICList + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tableLayoutPanel1 + + + 3 + + + Left True - - Fill - NoControl - 0, 110 - - - 0, 11, 0, 7 + 3, 123 - 38, 18 + 38, 13 - 2 + 4 &VLAN: @@ -298,61 +277,16 @@ tableLayoutPanel1 - 2 - - - True - - - Fill - - - NoControl - - - 0, 0 - - - 0, 0, 0, 7 - - - 493, 65 - - - 0 - - - Your new external network will be mapped to an existing physical network interface and assigned a VLAN number for that interface. - - -Select the physical interface you would like to use: - - - MiddleLeft - - - lblNicHelp - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tableLayoutPanel1 - - - 3 + 4 - 41, 108 - - - 3, 9, 0, 7 + 47, 119 - 117, 20 + 114, 20 - 3 + 5 numericUpDownVLAN @@ -364,49 +298,115 @@ Select the physical interface you would like to use: tableLayoutPanel1 - 4 + 5 - - 41, 75 + + True - - 241, 21 + + GrowAndShrink - + + 2 + + + 3, 3 + + + 16, 16 + + + 0 + + + pictureBoxVlan + + + System.Windows.Forms.PictureBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + infoVlanPanel + + + 0 + + + Left, Right + + + True + + + NoControl + + + 25, 4 + + + 331, 13 + + + 0 + + + labelVlanMessage + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + infoVlanPanel + + 1 - - comboBoxNICList + + Fill - - System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 167, 119 - + + 1 + + + 359, 22 + + + 6 + + + infoVlanPanel + + + System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + tableLayoutPanel1 - - 5 + + 6 + + + <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="pictureBoxVlan" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="labelVlanMessage" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /></Controls><Columns Styles="AutoSize,0,Percent,100,Absolute,20" /><Rows Styles="Percent,100" /></TableLayoutSettings> + + + Left True - - Fill - NoControl - 0, 137 - - - 0, 2, 3, 0 + 3, 151 - 35, 18 + 34, 13 - 4 + 7 &MTU: @@ -421,19 +421,16 @@ Select the physical interface you would like to use: tableLayoutPanel1 - 6 + 7 - 41, 135 - - - 3, 0, 0, 0 + 47, 147 - 117, 20 + 114, 20 - 5 + 8 numericUpDownMTU @@ -445,127 +442,136 @@ Select the physical interface you would like to use: tableLayoutPanel1 - 7 + 8 - + + Left, Right + + True - - True + + GrowAndShrink - - Left + + 2 - - Microsoft Sans Serif, 8.25pt - - + NoControl - - 0, 0 + + 3, 3 - - 0, 0, 0, 0 + + 16, 16 - - 174, 13 + + AutoSize - - 6 - - - This VLAN number is already in use - - - MiddleLeft - - - False - - - labelVlanError - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - panelVLANInfo - - + 0 - + + pictureBoxMtu + + + System.Windows.Forms.PictureBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + infoMtuPanel + + + 0 + + + Left, Right + + True - - Fill - - - Microsoft Sans Serif, 8.25pt - - + NoControl - - 0, 0 + + 25, 4 - - 0, 0, 0, 0 + + 331, 13 - - 252, 13 + + 0 - - 7 + + labelMtuMessage - - VLAN 0 will receive all traffic not on any other VLAN - - - MiddleLeft - - - False - - - labelVLAN0Info - - + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - panelVLANInfo + + infoMtuPanel - + 1 - - Fill + + 167, 147 - - 161, 112 + + 1 - - 3, 13, 0, 0 + + 359, 22 - - 332, 23 + + 9 - - 16 + + infoMtuPanel - - panelVLANInfo + + System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - + tableLayoutPanel1 - - 8 + + 9 + + + <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="pictureBoxMtu" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="labelMtuMessage" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /></Controls><Columns Styles="AutoSize,0,Percent,100" /><Rows Styles="AutoSize,0" /></TableLayoutSettings> + + + True + + + NoControl + + + 3, 192 + + + 3, 20, 3, 3 + + + 219, 17 + + + 10 + + + Create the VLAN on the &SR-IOV network + + + checkBoxSriov + + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tableLayoutPanel1 + + + 10 True @@ -577,16 +583,16 @@ Select the physical interface you would like to use: NoControl - 4, 209 + 3, 232 - 4, 24, 0, 0 + 3, 20, 3, 3 283, 17 - 7 + 11 &Automatically add this network to new virtual machines @@ -604,40 +610,7 @@ Select the physical interface you would like to use: tableLayoutPanel1 - 9 - - - True - - - NoControl - - - 4, 165 - - - 4, 10, 3, 3 - - - 219, 17 - - - 6 - - - Create the VLAN on the &SR-IOV network - - - checkBoxSriov - - - System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tableLayoutPanel1 - - - 10 + 11 Fill @@ -646,10 +619,10 @@ Select the physical interface you would like to use: 0, 0 - 6 + 7 - 493, 276 + 529, 319 0 @@ -661,37 +634,13 @@ Select the physical interface you would like to use: System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - panel1 + $this 0 - <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="infoMtuPanel" Row="3" RowSpan="1" Column="2" ColumnSpan="2" /><Control Name="labelNIC" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="labelVLAN" Row="2" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lblNicHelp" Row="0" RowSpan="1" Column="0" ColumnSpan="4" /><Control Name="numericUpDownVLAN" Row="2" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="comboBoxNICList" Row="1" RowSpan="1" Column="1" ColumnSpan="2" /><Control Name="labelMTU" Row="3" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="numericUpDownMTU" Row="3" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="panelVLANInfo" Row="2" RowSpan="1" Column="2" ColumnSpan="2" /><Control Name="checkBoxAutomatic" Row="5" RowSpan="1" Column="0" ColumnSpan="4" /><Control Name="checkBoxSriov" Row="4" RowSpan="1" Column="0" ColumnSpan="4" /></Controls><Columns Styles="AutoSize,0,Absolute,120,Absolute,127,Percent,100" /><Rows Styles="AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,Percent,100,Absolute,20" /></TableLayoutSettings> - - - 0, 0 - - - 0, 0, 0, 0 - - - 493, 276 - - - 0 - - - panel1 - - - System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 0 + <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="labelExternal" Row="0" RowSpan="1" Column="0" ColumnSpan="4" /><Control Name="labelInternal" Row="1" RowSpan="1" Column="0" ColumnSpan="4" /><Control Name="labelNIC" Row="2" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="comboBoxNICList" Row="2" RowSpan="1" Column="1" ColumnSpan="2" /><Control Name="labelVLAN" Row="3" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="numericUpDownVLAN" Row="3" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="infoVlanPanel" Row="3" RowSpan="1" Column="2" ColumnSpan="2" /><Control Name="labelMTU" Row="4" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="numericUpDownMTU" Row="4" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="infoMtuPanel" Row="4" RowSpan="1" Column="2" ColumnSpan="2" /><Control Name="checkBoxSriov" Row="5" RowSpan="1" Column="0" ColumnSpan="4" /><Control Name="checkBoxAutomatic" Row="6" RowSpan="1" Column="0" ColumnSpan="4" /></Controls><Columns Styles="AutoSize,0,Absolute,120,Absolute,127,Percent,100" /><Rows Styles="AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,Percent,100,Absolute,20" /></TableLayoutSettings> True @@ -703,7 +652,7 @@ Select the physical interface you would like to use: 0, 0, 0, 0 - 493, 276 + 529, 319 Interface diff --git a/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWName.Designer.cs b/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWName.Designer.cs index a2fe1eaaf..7939b7d81 100644 --- a/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWName.Designer.cs +++ b/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWName.Designer.cs @@ -29,71 +29,59 @@ namespace XenAdmin.Wizards.NewNetworkWizard_Pages private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(NetWName)); - this.panel1 = new System.Windows.Forms.Panel(); this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); - this.txtName = new System.Windows.Forms.TextBox(); - this.txtDescription = new System.Windows.Forms.TextBox(); - this.lblDescription = new System.Windows.Forms.Label(); - this.lblName = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label(); - this.panel1.SuspendLayout(); + this.lblName = new System.Windows.Forms.Label(); + this.txtName = new System.Windows.Forms.TextBox(); + this.lblDescription = new System.Windows.Forms.Label(); + this.txtDescription = new System.Windows.Forms.TextBox(); this.tableLayoutPanel1.SuspendLayout(); this.SuspendLayout(); // - // panel1 - // - resources.ApplyResources(this.panel1, "panel1"); - this.panel1.BackColor = System.Drawing.SystemColors.Control; - this.panel1.Controls.Add(this.tableLayoutPanel1); - this.panel1.Name = "panel1"; - // // tableLayoutPanel1 // resources.ApplyResources(this.tableLayoutPanel1, "tableLayoutPanel1"); - this.tableLayoutPanel1.Controls.Add(this.txtName, 1, 1); - this.tableLayoutPanel1.Controls.Add(this.txtDescription, 1, 3); - this.tableLayoutPanel1.Controls.Add(this.lblDescription, 0, 3); - this.tableLayoutPanel1.Controls.Add(this.lblName, 0, 1); this.tableLayoutPanel1.Controls.Add(this.label1, 0, 0); + this.tableLayoutPanel1.Controls.Add(this.lblName, 0, 1); + this.tableLayoutPanel1.Controls.Add(this.txtName, 1, 1); + this.tableLayoutPanel1.Controls.Add(this.lblDescription, 0, 3); + this.tableLayoutPanel1.Controls.Add(this.txtDescription, 1, 3); this.tableLayoutPanel1.Name = "tableLayoutPanel1"; // - // txtName + // label1 // - this.tableLayoutPanel1.SetColumnSpan(this.txtName, 2); - resources.ApplyResources(this.txtName, "txtName"); - this.txtName.Name = "txtName"; - this.txtName.TextChanged += new System.EventHandler(this.txtName_TextChanged); - // - // txtDescription - // - this.tableLayoutPanel1.SetColumnSpan(this.txtDescription, 2); - resources.ApplyResources(this.txtDescription, "txtDescription"); - this.txtDescription.Name = "txtDescription"; - // - // lblDescription - // - resources.ApplyResources(this.lblDescription, "lblDescription"); - this.lblDescription.Name = "lblDescription"; + resources.ApplyResources(this.label1, "label1"); + this.tableLayoutPanel1.SetColumnSpan(this.label1, 3); + this.label1.Name = "label1"; // // lblName // resources.ApplyResources(this.lblName, "lblName"); this.lblName.Name = "lblName"; // - // label1 + // txtName // - resources.ApplyResources(this.label1, "label1"); - this.tableLayoutPanel1.SetColumnSpan(this.label1, 4); - this.label1.Name = "label1"; + resources.ApplyResources(this.txtName, "txtName"); + this.txtName.Name = "txtName"; + this.txtName.TextChanged += new System.EventHandler(this.txtName_TextChanged); + // + // lblDescription + // + resources.ApplyResources(this.lblDescription, "lblDescription"); + this.lblDescription.Name = "lblDescription"; + // + // txtDescription + // + resources.ApplyResources(this.txtDescription, "txtDescription"); + this.txtDescription.Name = "txtDescription"; // // NetWName // resources.ApplyResources(this, "$this"); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; this.BackColor = System.Drawing.SystemColors.Control; - this.Controls.Add(this.panel1); + this.Controls.Add(this.tableLayoutPanel1); this.Name = "NetWName"; - this.panel1.ResumeLayout(false); this.tableLayoutPanel1.ResumeLayout(false); this.tableLayoutPanel1.PerformLayout(); this.ResumeLayout(false); @@ -101,8 +89,6 @@ namespace XenAdmin.Wizards.NewNetworkWizard_Pages } #endregion - - private System.Windows.Forms.Panel panel1; private System.Windows.Forms.Label lblName; private System.Windows.Forms.TextBox txtName; private System.Windows.Forms.Label lblDescription; diff --git a/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWName.cs b/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWName.cs index 3d9edbf4d..403ab0474 100644 --- a/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWName.cs +++ b/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWName.cs @@ -31,11 +31,6 @@ using System; using System.Collections.Generic; -using System.ComponentModel; -using System.Drawing; -using System.Data; -using System.Text; -using System.Windows.Forms; using XenAdmin.Controls; using XenAdmin.Core; using XenAdmin.Network; @@ -50,9 +45,9 @@ namespace XenAdmin.Wizards.NewNetworkWizard_Pages InitializeComponent(); } - public override string Text { get { return Messages.NETW_NAME_TEXT; } } + public override string Text => Messages.NETW_NAME_TEXT; - public override string PageTitle { get { return Messages.NETW_NAME_TITLE; } } + public override string PageTitle => Messages.NETW_NAME_TITLE; public override bool EnableNext() { @@ -77,21 +72,9 @@ namespace XenAdmin.Wizards.NewNetworkWizard_Pages public NetworkTypes SelectedNetworkType { private get; set; } - public string NetworkName - { - get - { - return this.txtName.Text; - } - } + public string NetworkName => txtName.Text; - public string NetworkDescription - { - get - { - return this.txtDescription.Text; - } - } + public string NetworkDescription => txtDescription.Text; private string GetNetworkName(NetworkTypes network_type) { diff --git a/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWName.resx b/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWName.resx index 96acbabfb..213c8185f 100644 --- a/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWName.resx +++ b/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWName.resx @@ -112,127 +112,61 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Top, Bottom, Left, Right - - + - 4 - - - Fill - - - - 66, 43 - - - 0, 0, 0, 0 - - - 294, 20 - - 3 - - New Network (1) - - - txtName - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tableLayoutPanel1 - - - 0 - - - Fill - - - 66, 68 - - - 0, 0, 0, 0 - - - 294, 20 - - - 5 - - - txtDescription - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tableLayoutPanel1 - - - 1 - - + True - + + Fill - - 0, 68 + + + 3, 0 - - 0, 0, 3, 0 + + 3, 0, 3, 30 - - 63, 20 + + 394, 13 - - 4 + + 1 - - &Description: + + Provide a name and optional description for the new network. - - MiddleLeft + + label1 - - lblDescription + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - + tableLayoutPanel1 - - 2 + + 0 + + + Left True - - Fill - - 0, 43 - - - 0, 0, 0, 0 + 3, 49 - 66, 20 + 38, 13 2 @@ -247,48 +181,96 @@ lblName - System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 tableLayoutPanel1 - 3 + 1 - - True - - + Fill - - 0, 0 + + 72, 46 - - 0, 0, 0, 0 + + 285, 20 - - 0, 0, 0, 30 + + 3 - - 400, 43 + + New Network (1) - - 6 + + txtName - - Provide a name and optional description for the new network. + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - label1 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - + tableLayoutPanel1 - + + 2 + + + Left + + + True + + + 3, 80 + + + 63, 13 + + + 4 + + + &Description: + + + MiddleLeft + + + lblDescription + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tableLayoutPanel1 + + + 3 + + + Fill + + + 72, 77 + + + 285, 20 + + + 5 + + + txtDescription + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tableLayoutPanel1 + + 4 @@ -307,48 +289,24 @@ 400, 300 - 3 + 0 tableLayoutPanel1 - System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - panel1 + $this 0 - <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="txtName" Row="1" RowSpan="1" Column="1" ColumnSpan="2" /><Control Name="txtDescription" Row="3" RowSpan="1" Column="1" ColumnSpan="2" /><Control Name="lblDescription" Row="3" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lblName" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="label1" Row="0" RowSpan="1" Column="0" ColumnSpan="4" /></Controls><Columns Styles="AutoSize,0,Percent,100,Absolute,40,Absolute,40" /><Rows Styles="AutoSize,0,AutoSize,0,Absolute,5,AutoSize,0,Percent,100" /></TableLayoutSettings> + <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="label1" Row="0" RowSpan="1" Column="0" ColumnSpan="3" /><Control Name="lblName" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="txtName" Row="1" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="lblDescription" Row="3" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="txtDescription" Row="3" RowSpan="1" Column="1" ColumnSpan="1" /></Controls><Columns Styles="AutoSize,0,Percent,100,Absolute,40,Absolute,20" /><Rows Styles="AutoSize,0,AutoSize,0,Absolute,5,AutoSize,0,Percent,100" /></TableLayoutSettings> - - 0, 0 - - - 0, 0, 0, 0 - - - 400, 300 - - - 0 - - - panel1 - - - System.Windows.Forms.Panel, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 0 - - + True diff --git a/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWSriovDetails.cs b/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWSriovDetails.cs index 2cf44252a..538f43afc 100644 --- a/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWSriovDetails.cs +++ b/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWSriovDetails.cs @@ -100,15 +100,9 @@ namespace XenAdmin.Wizards.NewNetworkWizard_Pages OnPageUpdated(); } - public PIF SelectedHostNic - { - get { return (PIF)comboBoxNicList.SelectedItem; } - } + public PIF SelectedHostNic => (PIF)comboBoxNicList.SelectedItem; - public bool isAutomaticAddNicToVM - { - get { return cbxAutomatic.Checked; } - } + public bool AddNicToVmsAutomatically => cbxAutomatic.Checked; private void comboBoxNicList_SelectedIndexChanged(object sender, EventArgs e) { diff --git a/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWSriovDetails.resx b/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWSriovDetails.resx index dbd9f554e..ce5540463 100644 --- a/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWSriovDetails.resx +++ b/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWSriovDetails.resx @@ -139,7 +139,7 @@ 286, 17 - 5 + 3 &Automatically add this network to new virtual machines. diff --git a/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWTypeSelect.Designer.cs b/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWTypeSelect.Designer.cs index 1a699ab5c..8b456695f 100644 --- a/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWTypeSelect.Designer.cs +++ b/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWTypeSelect.Designer.cs @@ -31,7 +31,6 @@ namespace XenAdmin.Wizards.NewNetworkWizard_Pages this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(NetWTypeSelect)); this.toolTip = new System.Windows.Forms.ToolTip(this.components); - this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); this.lblNetTypeSel = new System.Windows.Forms.Label(); this.rbtnExternalNetwork = new System.Windows.Forms.RadioButton(); this.labelExternalNetwork = new System.Windows.Forms.Label(); @@ -43,50 +42,35 @@ namespace XenAdmin.Wizards.NewNetworkWizard_Pages this.labelCHIN = new System.Windows.Forms.Label(); this.rbtnSriov = new System.Windows.Forms.RadioButton(); this.labelSriov = new System.Windows.Forms.Label(); - this.warningsTable = new System.Windows.Forms.TableLayoutPanel(); - this.iconWarningChinOption = new System.Windows.Forms.PictureBox(); + this.warningTableChin = new System.Windows.Forms.TableLayoutPanel(); this.labelWarningChinOption = new System.Windows.Forms.Label(); + this.iconWarningChinOption = new System.Windows.Forms.PictureBox(); this.warningTableSriov = new System.Windows.Forms.TableLayoutPanel(); - this.iconWarningSriovOption = new System.Windows.Forms.PictureBox(); this.labelWarningSriovOption = new System.Windows.Forms.Label(); - this.flowLayoutPanel1.SuspendLayout(); - this.warningsTable.SuspendLayout(); + this.iconWarningSriovOption = new System.Windows.Forms.PictureBox(); + this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.warningTableChin.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.iconWarningChinOption)).BeginInit(); this.warningTableSriov.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.iconWarningSriovOption)).BeginInit(); + this.tableLayoutPanel1.SuspendLayout(); this.SuspendLayout(); // // toolTip // this.toolTip.ShowAlways = true; // - // flowLayoutPanel1 - // - resources.ApplyResources(this.flowLayoutPanel1, "flowLayoutPanel1"); - this.flowLayoutPanel1.Controls.Add(this.lblNetTypeSel); - this.flowLayoutPanel1.Controls.Add(this.rbtnExternalNetwork); - this.flowLayoutPanel1.Controls.Add(this.labelExternalNetwork); - this.flowLayoutPanel1.Controls.Add(this.rbtnInternalNetwork); - this.flowLayoutPanel1.Controls.Add(this.label1); - this.flowLayoutPanel1.Controls.Add(this.rbtnBondedNetwork); - this.flowLayoutPanel1.Controls.Add(this.label3); - this.flowLayoutPanel1.Controls.Add(this.rbtnCHIN); - this.flowLayoutPanel1.Controls.Add(this.labelCHIN); - this.flowLayoutPanel1.Controls.Add(this.rbtnSriov); - this.flowLayoutPanel1.Controls.Add(this.labelSriov); - this.flowLayoutPanel1.Controls.Add(this.warningsTable); - this.flowLayoutPanel1.Controls.Add(this.warningTableSriov); - this.flowLayoutPanel1.Name = "flowLayoutPanel1"; - // // lblNetTypeSel // resources.ApplyResources(this.lblNetTypeSel, "lblNetTypeSel"); + this.tableLayoutPanel1.SetColumnSpan(this.lblNetTypeSel, 2); this.lblNetTypeSel.Name = "lblNetTypeSel"; // // rbtnExternalNetwork // resources.ApplyResources(this.rbtnExternalNetwork, "rbtnExternalNetwork"); this.rbtnExternalNetwork.Checked = true; + this.tableLayoutPanel1.SetColumnSpan(this.rbtnExternalNetwork, 2); this.rbtnExternalNetwork.Name = "rbtnExternalNetwork"; this.rbtnExternalNetwork.TabStop = true; this.rbtnExternalNetwork.UseVisualStyleBackColor = true; @@ -99,6 +83,7 @@ namespace XenAdmin.Wizards.NewNetworkWizard_Pages // rbtnInternalNetwork // resources.ApplyResources(this.rbtnInternalNetwork, "rbtnInternalNetwork"); + this.tableLayoutPanel1.SetColumnSpan(this.rbtnInternalNetwork, 2); this.rbtnInternalNetwork.Name = "rbtnInternalNetwork"; this.rbtnInternalNetwork.UseVisualStyleBackColor = true; // @@ -110,6 +95,7 @@ namespace XenAdmin.Wizards.NewNetworkWizard_Pages // rbtnBondedNetwork // resources.ApplyResources(this.rbtnBondedNetwork, "rbtnBondedNetwork"); + this.tableLayoutPanel1.SetColumnSpan(this.rbtnBondedNetwork, 2); this.rbtnBondedNetwork.Name = "rbtnBondedNetwork"; this.rbtnBondedNetwork.UseVisualStyleBackColor = true; // @@ -121,6 +107,7 @@ namespace XenAdmin.Wizards.NewNetworkWizard_Pages // rbtnCHIN // resources.ApplyResources(this.rbtnCHIN, "rbtnCHIN"); + this.tableLayoutPanel1.SetColumnSpan(this.rbtnCHIN, 2); this.rbtnCHIN.Name = "rbtnCHIN"; this.rbtnCHIN.UseVisualStyleBackColor = true; // @@ -132,6 +119,7 @@ namespace XenAdmin.Wizards.NewNetworkWizard_Pages // rbtnSriov // resources.ApplyResources(this.rbtnSriov, "rbtnSriov"); + this.tableLayoutPanel1.SetColumnSpan(this.rbtnSriov, 2); this.rbtnSriov.Name = "rbtnSriov"; this.rbtnSriov.UseVisualStyleBackColor = true; // @@ -140,12 +128,17 @@ namespace XenAdmin.Wizards.NewNetworkWizard_Pages resources.ApplyResources(this.labelSriov, "labelSriov"); this.labelSriov.Name = "labelSriov"; // - // warningsTable + // warningTableChin // - resources.ApplyResources(this.warningsTable, "warningsTable"); - this.warningsTable.Controls.Add(this.iconWarningChinOption, 0, 1); - this.warningsTable.Controls.Add(this.labelWarningChinOption, 1, 1); - this.warningsTable.Name = "warningsTable"; + resources.ApplyResources(this.warningTableChin, "warningTableChin"); + this.warningTableChin.Controls.Add(this.labelWarningChinOption, 1, 0); + this.warningTableChin.Controls.Add(this.iconWarningChinOption, 0, 0); + this.warningTableChin.Name = "warningTableChin"; + // + // labelWarningChinOption + // + resources.ApplyResources(this.labelWarningChinOption, "labelWarningChinOption"); + this.labelWarningChinOption.Name = "labelWarningChinOption"; // // iconWarningChinOption // @@ -154,18 +147,18 @@ namespace XenAdmin.Wizards.NewNetworkWizard_Pages this.iconWarningChinOption.Name = "iconWarningChinOption"; this.iconWarningChinOption.TabStop = false; // - // labelWarningChinOption - // - resources.ApplyResources(this.labelWarningChinOption, "labelWarningChinOption"); - this.labelWarningChinOption.Name = "labelWarningChinOption"; - // // warningTableSriov // resources.ApplyResources(this.warningTableSriov, "warningTableSriov"); - this.warningTableSriov.Controls.Add(this.iconWarningSriovOption, 0, 1); - this.warningTableSriov.Controls.Add(this.labelWarningSriovOption, 1, 1); + this.warningTableSriov.Controls.Add(this.labelWarningSriovOption, 1, 0); + this.warningTableSriov.Controls.Add(this.iconWarningSriovOption, 0, 0); this.warningTableSriov.Name = "warningTableSriov"; // + // labelWarningSriovOption + // + resources.ApplyResources(this.labelWarningSriovOption, "labelWarningSriovOption"); + this.labelWarningSriovOption.Name = "labelWarningSriovOption"; + // // iconWarningSriovOption // resources.ApplyResources(this.iconWarningSriovOption, "iconWarningSriovOption"); @@ -173,27 +166,39 @@ namespace XenAdmin.Wizards.NewNetworkWizard_Pages this.iconWarningSriovOption.Name = "iconWarningSriovOption"; this.iconWarningSriovOption.TabStop = false; // - // labelWarningSriovOption + // tableLayoutPanel1 // - resources.ApplyResources(this.labelWarningSriovOption, "labelWarningSriovOption"); - this.labelWarningSriovOption.Name = "labelWarningSriovOption"; + resources.ApplyResources(this.tableLayoutPanel1, "tableLayoutPanel1"); + this.tableLayoutPanel1.Controls.Add(this.lblNetTypeSel, 0, 0); + this.tableLayoutPanel1.Controls.Add(this.rbtnExternalNetwork, 0, 1); + this.tableLayoutPanel1.Controls.Add(this.labelExternalNetwork, 1, 2); + this.tableLayoutPanel1.Controls.Add(this.rbtnInternalNetwork, 0, 3); + this.tableLayoutPanel1.Controls.Add(this.label1, 1, 4); + this.tableLayoutPanel1.Controls.Add(this.rbtnBondedNetwork, 0, 5); + this.tableLayoutPanel1.Controls.Add(this.label3, 1, 6); + this.tableLayoutPanel1.Controls.Add(this.rbtnCHIN, 0, 7); + this.tableLayoutPanel1.Controls.Add(this.labelCHIN, 1, 8); + this.tableLayoutPanel1.Controls.Add(this.warningTableChin, 1, 9); + this.tableLayoutPanel1.Controls.Add(this.rbtnSriov, 0, 10); + this.tableLayoutPanel1.Controls.Add(this.labelSriov, 1, 11); + this.tableLayoutPanel1.Controls.Add(this.warningTableSriov, 1, 12); + this.tableLayoutPanel1.Name = "tableLayoutPanel1"; // // NetWTypeSelect // resources.ApplyResources(this, "$this"); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; - this.Controls.Add(this.flowLayoutPanel1); + this.Controls.Add(this.tableLayoutPanel1); this.Name = "NetWTypeSelect"; - this.flowLayoutPanel1.ResumeLayout(false); - this.flowLayoutPanel1.PerformLayout(); - this.warningsTable.ResumeLayout(false); - this.warningsTable.PerformLayout(); + this.warningTableChin.ResumeLayout(false); + this.warningTableChin.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.iconWarningChinOption)).EndInit(); this.warningTableSriov.ResumeLayout(false); this.warningTableSriov.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.iconWarningSriovOption)).EndInit(); + this.tableLayoutPanel1.ResumeLayout(false); + this.tableLayoutPanel1.PerformLayout(); this.ResumeLayout(false); - this.PerformLayout(); } @@ -208,15 +213,15 @@ namespace XenAdmin.Wizards.NewNetworkWizard_Pages private System.Windows.Forms.Label label3; private System.Windows.Forms.Label labelCHIN; private System.Windows.Forms.RadioButton rbtnCHIN; - private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1; private System.Windows.Forms.ToolTip toolTip; - private System.Windows.Forms.TableLayoutPanel warningsTable; - private System.Windows.Forms.PictureBox iconWarningChinOption; - private System.Windows.Forms.Label labelWarningChinOption; + private System.Windows.Forms.TableLayoutPanel warningTableChin; private System.Windows.Forms.RadioButton rbtnSriov; private System.Windows.Forms.Label labelSriov; private System.Windows.Forms.TableLayoutPanel warningTableSriov; private System.Windows.Forms.PictureBox iconWarningSriovOption; private System.Windows.Forms.Label labelWarningSriovOption; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; + private System.Windows.Forms.Label labelWarningChinOption; + private System.Windows.Forms.PictureBox iconWarningChinOption; } } diff --git a/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWTypeSelect.cs b/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWTypeSelect.cs index 1ba20d2ab..2b3a74b51 100644 --- a/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWTypeSelect.cs +++ b/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWTypeSelect.cs @@ -32,12 +32,10 @@ using System; using System.Linq; using XenAdmin.Core; -using XenAdmin.Network; using XenAPI; using XenAdmin.Controls; - namespace XenAdmin.Wizards.NewNetworkWizard_Pages { public partial class NetWTypeSelect : XenTabPage @@ -45,91 +43,84 @@ namespace XenAdmin.Wizards.NewNetworkWizard_Pages public NetWTypeSelect() { InitializeComponent(); - this.rbtnExternalNetwork.Checked = true; + rbtnExternalNetwork.Checked = true; } - public override string Text { get { return Messages.NETW_TYPE_SELECT_TEXT; } } + public override string Text => Messages.NETW_TYPE_SELECT_TEXT; + + public override string PageTitle => Messages.NETW_TYPE_SELECT_TITLE; + + public NetworkTypes SelectedNetworkType => + rbtnBondedNetwork.Checked + ? NetworkTypes.Bonded + : rbtnExternalNetwork.Checked + ? NetworkTypes.External + : rbtnCHIN.Checked + ? NetworkTypes.CHIN + : rbtnSriov.Checked + ? NetworkTypes.SRIOV + : NetworkTypes.Internal; - public override string PageTitle { get { return Messages.NETW_TYPE_SELECT_TITLE; } } public override void PopulatePage() { - Update(Connection); - } - - public NetworkTypes SelectedNetworkType - { - get - { - return rbtnBondedNetwork.Checked - ? NetworkTypes.Bonded - : rbtnExternalNetwork.Checked - ? NetworkTypes.External - : rbtnCHIN.Checked - ? NetworkTypes.CHIN - : rbtnSriov.Checked - ? NetworkTypes.SRIOV - : NetworkTypes.Internal; - } - } - - private void Update(IXenConnection connection) - { - Host master = Helpers.GetMaster(connection); - if (master == null) + Pool pool = Helpers.GetPoolOfOne(Connection); + if (pool == null) return; - Pool pool = Helpers.GetPoolOfOne(connection); - labelCHIN.Visible = rbtnCHIN.Visible = !HiddenFeatures.CrossServerPrivateNetworkHidden; - if (!pool.vSwitchController()) + if (HiddenFeatures.CrossServerPrivateNetworkHidden) { - rbtnCHIN.Checked = false; + rbtnCHIN.Visible = labelCHIN.Visible = false; + warningTableChin.Visible = false; + } + else if (!pool.vSwitchController()) + { + rbtnCHIN.Visible = labelCHIN.Visible = true; rbtnCHIN.Enabled = labelCHIN.Enabled = false; - labelWarningChinOption.Text = - Helpers.FeatureForbidden(connection, Host.RestrictVSwitchController) ? - String.Format(Messages.FEATURE_DISABLED, Messages.CHIN) : - Messages.CHINS_NEED_VSWITCHCONTROLLER; + labelWarningChinOption.Text = Helpers.FeatureForbidden(Connection, Host.RestrictVSwitchController) + ? string.Format(Messages.FEATURE_DISABLED, Messages.CHIN) + : Messages.CHINS_NEED_VSWITCHCONTROLLER; - iconWarningChinOption.Visible = labelWarningChinOption.Visible = !HiddenFeatures.CrossServerPrivateNetworkHidden; - - rbtnExternalNetwork.Checked = true; + warningTableChin.Visible = true; } else { + rbtnCHIN.Visible = labelCHIN.Visible = true; rbtnCHIN.Enabled = labelCHIN.Enabled = true; - iconWarningChinOption.Visible = labelWarningChinOption.Visible = false; + warningTableChin.Visible = false; } 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)) { - iconWarningSriovOption.Visible = labelWarningSriovOption.Visible = false; rbtnSriov.Visible = labelSriov.Visible = false; + warningTableSriov.Visible = false; } else if (Helpers.FeatureForbidden(pool.Connection, Host.SriovNetworkDisabled) || - sriovFeatureForbidden || !pool.HasSriovNic() || !hasNicCanEnableSriov) + sriovFeatureForbidden || !pool.HasSriovNic() || !hasNicCanEnableSriov) { - rbtnSriov.Checked = false; + rbtnSriov.Visible = labelSriov.Visible = true; rbtnSriov.Enabled = labelSriov.Enabled = false; labelWarningSriovOption.Text = Helpers.FeatureForbidden(pool.Connection, Host.SriovNetworkDisabled) - ? String.Format(Messages.FEATURE_EXPERIMENTAL, Messages.NETWORK_SRIOV) + ? string.Format(Messages.FEATURE_EXPERIMENTAL, Messages.NETWORK_SRIOV) : sriovFeatureForbidden - ? String.Format(Messages.FEATURE_DISABLED, Messages.NETWORK_SRIOV) + ? string.Format(Messages.FEATURE_DISABLED, Messages.NETWORK_SRIOV) : pool.HasSriovNic() ? Messages.NICS_ARE_SRIOV_ENABLED : Messages.SRIOV_NEED_NICSUPPORT; - iconWarningSriovOption.Visible = labelWarningSriovOption.Visible = true; + warningTableSriov.Visible = true; } else { - rbtnSriov.Enabled = labelCHIN.Enabled = true; - iconWarningSriovOption.Visible = labelWarningSriovOption.Visible = false; + rbtnSriov.Visible = labelSriov.Visible = true; + rbtnSriov.Enabled = labelSriov.Enabled = true; + warningTableSriov.Visible = false; } } } diff --git a/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWTypeSelect.resx b/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWTypeSelect.resx index 76f5270f2..dbca0af47 100644 --- a/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWTypeSelect.resx +++ b/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWTypeSelect.resx @@ -121,61 +121,28 @@ 17, 17 - - True - True - - - NoControl - - - - 3, 3 - - - 3, 3, 3, 3 - - - 279, 13 - - - 0 - - - Select the type of new network you would like to create: - - - MiddleLeft - - - lblNetTypeSel - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - flowLayoutPanel1 - - - 0 + + 2 True + Tahoma, 8.25pt, style=Bold + NoControl - 20, 29 + 3, 23 - 20, 10, 3, 3 + 3, 10, 3, 3 122, 17 @@ -193,28 +160,25 @@ System.Windows.Forms.RadioButton, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - flowLayoutPanel1 + tableLayoutPanel1 1 - - Top, Left, Right - True + + Fill + NoControl - 46, 49 - - - 46, 0, 3, 3 + 18, 43 - 359, 13 + 409, 13 2 @@ -229,7 +193,7 @@ System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - flowLayoutPanel1 + tableLayoutPanel1 2 @@ -244,10 +208,10 @@ NoControl - 20, 71 + 3, 66 - 20, 6, 3, 3 + 3, 10, 3, 3 196, 17 @@ -265,7 +229,7 @@ System.Windows.Forms.RadioButton, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - flowLayoutPanel1 + tableLayoutPanel1 3 @@ -273,17 +237,17 @@ True + + Fill + NoControl - 46, 91 - - - 46, 0, 3, 3 + 18, 86 - 359, 26 + 409, 26 4 @@ -299,7 +263,7 @@ This can be used as a private connection between VMs on the same host. System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - flowLayoutPanel1 + tableLayoutPanel1 4 @@ -314,10 +278,10 @@ This can be used as a private connection between VMs on the same host. NoControl - 20, 126 + 3, 122 - 20, 6, 3, 3 + 3, 10, 3, 3 117, 17 @@ -335,7 +299,7 @@ This can be used as a private connection between VMs on the same host. System.Windows.Forms.RadioButton, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - flowLayoutPanel1 + tableLayoutPanel1 5 @@ -343,17 +307,17 @@ This can be used as a private connection between VMs on the same host. True + + Fill + NoControl - 46, 146 - - - 46, 0, 3, 3 + 18, 142 - 320, 26 + 409, 26 6 @@ -369,7 +333,7 @@ This will create a single higher performing channel. System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - flowLayoutPanel1 + tableLayoutPanel1 6 @@ -384,10 +348,10 @@ This will create a single higher performing channel. NoControl - 20, 181 + 3, 178 - 20, 6, 3, 3 + 3, 10, 3, 3 193, 17 @@ -405,28 +369,25 @@ This will create a single higher performing channel. System.Windows.Forms.RadioButton, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - flowLayoutPanel1 + tableLayoutPanel1 7 - - Top, Left, Right - True + + Fill + NoControl - 46, 201 - - - 46, 0, 3, 3 + 18, 198 - 359, 39 + 409, 39 8 @@ -443,92 +404,50 @@ This type of network requires the vSwitch Controller to be running. System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - flowLayoutPanel1 + tableLayoutPanel1 8 - + True - - Tahoma, 8.25pt, style=Bold - - - NoControl - - - 20, 249 - - - 20, 6, 3, 3 - - - 115, 17 - - - 9 - - - S&R-IOV Network - - - rbtnSriov - - - System.Windows.Forms.RadioButton, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - flowLayoutPanel1 - - - 9 - - - Top, Left, Right - - - True - - - NoControl - - - 46, 269 - - - 46, 0, 3, 3 - - - 359, 13 - - - 10 - - - Enable SR-IOV on a NIC and create an SR-IOV network on that NIC. - - - labelSriov - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - flowLayoutPanel1 - - - 10 - - - True - - + 2 - + Left + + True + + + NoControl + + + 25, 4 + + + 45, 13 + + + 0 + + + warning + + + labelWarningChinOption + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + warningTableChin + + + 0 + @@ -557,86 +476,146 @@ This type of network requires the vSwitch Controller to be running. System.Windows.Forms.PictureBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - warningsTable + warningTableChin - 0 - - - Left - - - True - - - NoControl - - - 25, 4 - - - 3, 3, 3, 3 - - - 45, 13 - - - 0 - - - warning - - - labelWarningChinOption - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - warningsTable - - 1 - - 3, 291 + + Fill - - 3, 6, 3, 1 + + 18, 240 - - 2 + + 1 - - 73, 22 + + 409, 22 - - 11 + + 9 - - warningsTable + + warningTableChin - + System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - flowLayoutPanel1 + + tableLayoutPanel1 - + + 9 + + + <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="labelWarningChinOption" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="iconWarningChinOption" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /></Controls><Columns Styles="AutoSize,0,Percent,100" /><Rows Styles="AutoSize,0" /></TableLayoutSettings> + + + True + + + Tahoma, 8.25pt, style=Bold + + + NoControl + + + 3, 275 + + + 3, 10, 3, 3 + + + 115, 17 + + + 10 + + + S&R-IOV Network + + + rbtnSriov + + + System.Windows.Forms.RadioButton, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tableLayoutPanel1 + + + 10 + + + True + + + Fill + + + NoControl + + + 18, 295 + + + 409, 13 + + 11 - - <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="iconWarningChinOption" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="labelWarningChinOption" Row="1" RowSpan="1" Column="1" ColumnSpan="1" /></Controls><Columns Styles="AutoSize,0,Percent,100" /><Rows Styles="AutoSize,0,AutoSize,0,Absolute,20" /></TableLayoutSettings> + + Enable SR-IOV on a NIC and create an SR-IOV network on that NIC. - - True + + labelSriov + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tableLayoutPanel1 + + + 11 2 - + Left + + True + + + NoControl + + + 25, 4 + + + 45, 13 + + + 0 + + + warning + + + labelWarningSriovOption + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + warningTableSriov + + + 0 + @@ -668,55 +647,19 @@ This type of network requires the vSwitch Controller to be running. warningTableSriov - 0 - - - Left - - - True - - - NoControl - - - 25, 4 - - - 3, 3, 3, 3 - - - 45, 13 - - - 0 - - - warning - - - labelWarningSriovOption - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - warningTableSriov - - 1 - - 3, 314 + + Top - - 3, 0, 3, 12 + + 18, 311 - 2 + 1 - 73, 22 + 409, 22 12 @@ -728,36 +671,72 @@ This type of network requires the vSwitch Controller to be running. System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - flowLayoutPanel1 + tableLayoutPanel1 12 - <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="iconWarningSriovOption" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="labelWarningSriovOption" Row="1" RowSpan="1" Column="1" ColumnSpan="1" /></Controls><Columns Styles="AutoSize,0,Percent,100" /><Rows Styles="AutoSize,0,AutoSize,0" /></TableLayoutSettings> + <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="labelWarningSriovOption" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="iconWarningSriovOption" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /></Controls><Columns Styles="AutoSize,0,Percent,100" /><Rows Styles="AutoSize,0,Absolute,20" /></TableLayoutSettings> - - TopDown + + Fill - + 0, 0 - - 504, 395 + + 13 - - 9 + + 430, 360 - - flowLayoutPanel1 + + 0 - - System.Windows.Forms.FlowLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + tableLayoutPanel1 - + + System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + $this - + + 0 + + + <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="lblNetTypeSel" Row="0" RowSpan="1" Column="0" ColumnSpan="2" /><Control Name="rbtnExternalNetwork" Row="1" RowSpan="1" Column="0" ColumnSpan="2" /><Control Name="labelExternalNetwork" Row="2" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="rbtnInternalNetwork" Row="3" RowSpan="1" Column="0" ColumnSpan="2" /><Control Name="label1" Row="4" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="rbtnBondedNetwork" Row="5" RowSpan="1" Column="0" ColumnSpan="2" /><Control Name="label3" Row="6" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="rbtnCHIN" Row="7" RowSpan="1" Column="0" ColumnSpan="2" /><Control Name="labelCHIN" Row="8" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="warningTableChin" Row="9" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="rbtnSriov" Row="10" RowSpan="1" Column="0" ColumnSpan="2" /><Control Name="labelSriov" Row="11" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="warningTableSriov" Row="12" RowSpan="1" Column="1" ColumnSpan="1" /></Controls><Columns Styles="Absolute,15,Percent,100" /><Rows Styles="AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0" /></TableLayoutSettings> + + + NoControl + + + 3, 0 + + + 279, 13 + + + 0 + + + Select the type of new network you would like to create: + + + MiddleLeft + + + lblNetTypeSel + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tableLayoutPanel1 + + 0 @@ -769,11 +748,8 @@ This type of network requires the vSwitch Controller to be running. Tahoma, 8.25pt - - 0, 32, 0, 0 - - 430, 358 + 430, 360 Select Type diff --git a/XenModel/Messages.Designer.cs b/XenModel/Messages.Designer.cs index b9294005a..4d285f246 100755 --- a/XenModel/Messages.Designer.cs +++ b/XenModel/Messages.Designer.cs @@ -21000,6 +21000,15 @@ namespace XenAdmin { } } + /// + /// Looks up a localized string similar to Invalid disk size. + /// + public static string INVALID_DISK_SIZE { + get { + return ResourceManager.GetString("INVALID_DISK_SIZE", resourceCulture); + } + } + /// /// Looks up a localized string similar to Invalid hostname. /// @@ -21010,7 +21019,7 @@ namespace XenAdmin { } /// - /// Looks up a localized string similar to Invalid disk size. + /// Looks up a localized string similar to Invalid number. /// public static string INVALID_NUMBER { get { @@ -24536,6 +24545,15 @@ namespace XenAdmin { } } + /// + /// Looks up a localized string similar to Allowed VLAN range: {0} to {1}. + /// + public static string NETW_DETAILS_VLAN_RANGE { + get { + return ResourceManager.GetString("NETW_DETAILS_VLAN_RANGE", resourceCulture); + } + } + /// /// Looks up a localized string similar to Configure the new network. /// @@ -24590,6 +24608,15 @@ namespace XenAdmin { } } + /// + /// Looks up a localized string similar to VLAN 0 will receive all traffic not on any other VLAN. + /// + public static string NETW_VLAN_ZERO { + get { + return ResourceManager.GetString("NETW_VLAN_ZERO", resourceCulture); + } + } + /// /// Looks up a localized string similar to Network. /// @@ -39562,24 +39589,6 @@ namespace XenAdmin { } } - /// - /// Looks up a localized string similar to Your new network will be mapped to an existing physical network interface and assigned a VLAN number to use on that interface. You can select the physical interface you would like to use below.. - /// - public static string WIZARD_DESC_NETWORK_SETTINGS_EXTERNAL { - get { - return ResourceManager.GetString("WIZARD_DESC_NETWORK_SETTINGS_EXTERNAL", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Check the box below if you would like to automatically add this network to new VMs.. - /// - public static string WIZARD_DESC_NETWORK_SETTINGS_INTERNAL { - get { - return ResourceManager.GetString("WIZARD_DESC_NETWORK_SETTINGS_INTERNAL", resourceCulture); - } - } - /// /// Looks up a localized string similar to There was an internal error completing this wizard. Please see the logs for more information.. /// diff --git a/XenModel/Messages.resx b/XenModel/Messages.resx index 19ca172b1..5e117695a 100755 --- a/XenModel/Messages.resx +++ b/XenModel/Messages.resx @@ -7295,11 +7295,14 @@ This might result in failure to migrate VMs to this server during the RPU or to Interfaces: {0} + + Invalid disk size + Invalid hostname - Invalid disk size + Invalid number Invalid parameter @@ -8663,6 +8666,9 @@ You should only proceed if you have verified that these settings are correct. This VLAN number is already in use + + Allowed VLAN range: {0} to {1} + Configure the new network @@ -8681,6 +8687,9 @@ You should only proceed if you have verified that these settings are correct. Choose the type of network to create + + VLAN 0 will receive all traffic not on any other VLAN + Never @@ -13662,12 +13671,6 @@ Schedule: &Next > - - Your new network will be mapped to an existing physical network interface and assigned a VLAN number to use on that interface. You can select the physical interface you would like to use below. - - - Check the box below if you would like to automatically add this network to new VMs. - There was an internal error completing this wizard. Please see the logs for more information. From ebcbf9cabcac179024390e6d4ff33c90110519b8 Mon Sep 17 00:00:00 2001 From: Konstantina Chremmou Date: Fri, 14 Feb 2020 10:56:05 +0000 Subject: [PATCH 03/10] CP-32947: Hide CHIN network type and do not restrict QoS options. Signed-off-by: Konstantina Chremmou --- XenAdmin/Dialogs/VIFDialog.cs | 29 +++---------------- .../NewNetworkWizard_Pages/NetWTypeSelect.cs | 2 +- 2 files changed, 5 insertions(+), 26 deletions(-) diff --git a/XenAdmin/Dialogs/VIFDialog.cs b/XenAdmin/Dialogs/VIFDialog.cs index d34d09ede..e17ce68dd 100644 --- a/XenAdmin/Dialogs/VIFDialog.cs +++ b/XenAdmin/Dialogs/VIFDialog.cs @@ -76,7 +76,7 @@ namespace XenAdmin.Dialogs { // Check if vSwitch Controller is configured for the pool (CA-46299) Pool pool = Helpers.GetPoolOfOne(connection); - var vSwitchController = pool != null && pool.vSwitchController(); + var vSwitchController = !Helpers.StockholmOrGreater(connection) && pool != null && pool.vSwitchController(); if (vSwitchController) { @@ -203,21 +203,9 @@ namespace XenAdmin.Dialogs comboBoxNetwork.SelectedIndex = 0; } - private XenAPI.Network SelectedNetwork - { - get - { - return ((NetworkComboBoxItem)comboBoxNetwork.SelectedItem).Network; - } - } + private XenAPI.Network SelectedNetwork => (comboBoxNetwork.SelectedItem as NetworkComboBoxItem)?.Network; - private string SelectedMac - { - get - { - return radioButtonAutogenerate.Checked ? "" : promptTextBoxMac.Text; - } - } + private string SelectedMac => radioButtonAutogenerate.Checked ? "" : promptTextBoxMac.Text; public VIF NewVif() { @@ -387,16 +375,7 @@ namespace XenAdmin.Dialogs #endregion - internal override string HelpName - { - get - { - if (ExistingVif != null) - return "EditVmNetworkSettingsDialog"; - else - return "VIFDialog"; - } - } + internal override string HelpName => ExistingVif == null ? "VIFDialog" : "EditVmNetworkSettingsDialog"; } public class NetworkComboBoxItem : IEquatable diff --git a/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWTypeSelect.cs b/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWTypeSelect.cs index 2b3a74b51..8b5dc1be9 100644 --- a/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWTypeSelect.cs +++ b/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWTypeSelect.cs @@ -68,7 +68,7 @@ namespace XenAdmin.Wizards.NewNetworkWizard_Pages if (pool == null) return; - if (HiddenFeatures.CrossServerPrivateNetworkHidden) + if (HiddenFeatures.CrossServerPrivateNetworkHidden || Helpers.StockholmOrGreater(Connection)) { rbtnCHIN.Visible = labelCHIN.Visible = false; warningTableChin.Visible = false; From d3c5769a70bdd21754b235a00cd1bcbc7db5a2e6 Mon Sep 17 00:00:00 2001 From: Konstantina Chremmou Date: Mon, 24 Feb 2020 12:59:39 +0000 Subject: [PATCH 04/10] CP-32844: Check and warn if DVSC is configured when updating or upgrading a pool. Signed-off-by: Konstantina Chremmou --- Branding/Branding.resx | 3 + .../Checks/HostMemoryPostUpgradeCheck.cs | 23 +---- .../Checks/VSwitchControllerCheck.cs | 94 +++++++++++++++++++ .../PoolProblem/VSwitchControllerProblem.cs | 81 ++++++++++++++++ XenAdmin/Diagnostics/Problems/Problem.cs | 28 ++++++ .../PatchingWizard_PrecheckPage.cs | 12 ++- .../RollingUpgradeWizardPrecheckPage.cs | 7 ++ XenAdmin/XenAdmin.csproj | 2 + XenModel/BrandManager.cs | 2 + XenModel/Messages.Designer.cs | 54 +++++++++++ XenModel/Messages.resx | 18 ++++ XenModel/XenAPI-Extensions/Host.cs | 24 ++++- 12 files changed, 325 insertions(+), 23 deletions(-) create mode 100644 XenAdmin/Diagnostics/Checks/VSwitchControllerCheck.cs create mode 100644 XenAdmin/Diagnostics/Problems/PoolProblem/VSwitchControllerProblem.cs diff --git a/Branding/Branding.resx b/Branding/Branding.resx index d382cbd1c..9ed882e3d 100644 --- a/Branding/Branding.resx +++ b/Branding/Branding.resx @@ -177,4 +177,7 @@ 8.1 + + 8.2 + \ No newline at end of file diff --git a/XenAdmin/Diagnostics/Checks/HostMemoryPostUpgradeCheck.cs b/XenAdmin/Diagnostics/Checks/HostMemoryPostUpgradeCheck.cs index b3cf9bd15..4da07da3b 100644 --- a/XenAdmin/Diagnostics/Checks/HostMemoryPostUpgradeCheck.cs +++ b/XenAdmin/Diagnostics/Checks/HostMemoryPostUpgradeCheck.cs @@ -31,7 +31,6 @@ using System; using System.Collections.Generic; -using System.Web.Script.Serialization; using XenAdmin.Core; using XenAdmin.Diagnostics.Problems; using XenAdmin.Diagnostics.Problems.HostProblem; @@ -50,6 +49,7 @@ namespace XenAdmin.Diagnostics.Checks { this.installMethodConfig = installMethodConfig; } + public override string Description => Messages.CHECKING_HOST_MEMORY_POST_UPGRADE_DESCRIPTION; protected override Problem RunHostCheck() @@ -73,7 +73,7 @@ namespace XenAdmin.Diagnostics.Checks string upgradePlatformVersion = null; string upgradeProductVersion = null; if (installMethodConfig != null) - TryGetUpgradeVersion(out upgradePlatformVersion, out upgradeProductVersion); + Host.TryGetUpgradeVersion(Host, installMethodConfig, out upgradePlatformVersion, out upgradeProductVersion); if (Helpers.NaplesOrGreater(upgradePlatformVersion)) { @@ -102,24 +102,5 @@ namespace XenAdmin.Diagnostics.Checks return false; } } - - private bool TryGetUpgradeVersion(out string platformVersion, out string productVersion) - { - platformVersion = productVersion = null; - try - { - var result = Host.call_plugin(Host.Connection.Session, Host.opaque_ref, "prepare_host_upgrade.py", "getVersion", installMethodConfig); - var serializer = new JavaScriptSerializer(); - var version = (Dictionary)serializer.DeserializeObject(result); - platformVersion = version.ContainsKey("platform-version") ? (string)version["platform-version"] : null; - productVersion = version.ContainsKey("product-version") ? (string)version["product-version"] : null; - return platformVersion != null || productVersion != null; - } - catch (Exception exception) - { - log.WarnFormat("Plugin call prepare_host_upgrade.getVersion on {0} failed with {1}", Host.Name(), exception.Message); - return false; - } - } } } diff --git a/XenAdmin/Diagnostics/Checks/VSwitchControllerCheck.cs b/XenAdmin/Diagnostics/Checks/VSwitchControllerCheck.cs new file mode 100644 index 000000000..ea9ea5c07 --- /dev/null +++ b/XenAdmin/Diagnostics/Checks/VSwitchControllerCheck.cs @@ -0,0 +1,94 @@ +/* Copyright (c) Citrix Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, + * with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above + * copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the + * following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using XenAdmin.Core; +using XenAdmin.Diagnostics.Problems; +using XenAdmin.Diagnostics.Problems.PoolProblem; +using XenAPI; + +namespace XenAdmin.Diagnostics.Checks +{ + class VSwitchControllerCheck : HostPostLivenessCheck + { + private readonly Dictionary _installMethodConfig; + private readonly Pool _pool; + private XenServerVersion _newVersion; + + public VSwitchControllerCheck(Host host, XenServerVersion newVersion) + : base(host) + { + _newVersion = newVersion; + _pool = Helpers.GetPoolOfOne(Host?.Connection); + } + + public VSwitchControllerCheck(Host host, Dictionary installMethodConfig) + : base(host) + { + _installMethodConfig = installMethodConfig; + _pool = Helpers.GetPoolOfOne(Host?.Connection); + } + + public override string Description => Messages.CHECKING_VSWITCH_CONTROLLER; + + protected override Problem RunHostCheck() + { + if (!_pool.vSwitchController() || Helpers.StockholmOrGreater(Host)) + return null; + + //update case + if (_newVersion != null) + { + if (_newVersion.Version.CompareTo(new Version(BrandManager.ProductVersion82)) >= 0) + return new VSwitchControllerProblem(this, _pool); + return null; + } + + //upgrade case + string upgradePlatformVersion = null; + + if (_installMethodConfig != null) + Host.TryGetUpgradeVersion(Host, _installMethodConfig, out upgradePlatformVersion, out _); + + // we don't know the upgrade version, so add generic warning + // (this is the case of the manual upgrade or when the rpu plugin doesn't have the function) + if (string.IsNullOrEmpty(upgradePlatformVersion)) + return new VSwitchControllerWarning(this, _pool); + + // we know they are upgrading to Stockholm or greater, so block them + if (Helpers.StockholmOrGreater(upgradePlatformVersion)) + return new VSwitchControllerProblem(this, _pool); + + return null; + } + } +} diff --git a/XenAdmin/Diagnostics/Problems/PoolProblem/VSwitchControllerProblem.cs b/XenAdmin/Diagnostics/Problems/PoolProblem/VSwitchControllerProblem.cs new file mode 100644 index 000000000..663352689 --- /dev/null +++ b/XenAdmin/Diagnostics/Problems/PoolProblem/VSwitchControllerProblem.cs @@ -0,0 +1,81 @@ +/* Copyright (c) Citrix Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, + * with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above + * copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the + * following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +using XenAdmin.Actions; +using XenAdmin.Core; +using XenAdmin.Diagnostics.Checks; +using XenAPI; + + +namespace XenAdmin.Diagnostics.Problems.PoolProblem +{ + class VSwitchControllerProblem : ProblemWithMoreInfo + { + private Pool _pool; + + public VSwitchControllerProblem(Check check, Pool pool) + : base(check) + { + _pool = pool; + } + + public override string Title => Check.Description; + + public override string Description => + string.Format(Messages.PROBLEM_VSWITCH_CONTROLLER_DESCRIPTION, _pool, + string.Format(Messages.XENSERVER_8_2, BrandManager.ProductVersion82)); + + public override string Message => + string.Format(Messages.PROBLEM_VSWITCH_CONTROLLER_INFO, + string.Format(Messages.XENSERVER_8_2, BrandManager.ProductVersion82)); + } + + class VSwitchControllerWarning : WarningWithMoreInfo + { + private readonly Pool pool; + + public VSwitchControllerWarning(Check check, Pool pool) + : base(check) + { + this.pool = pool; + } + + public override string Title => Check.Description; + + public override string Description => + string.Format(Messages.PROBLEM_VSWITCH_CONTROLLER_DESCRIPTION, pool, + string.Format(Messages.XENSERVER_8_2, BrandManager.ProductVersion82)); + + public override string Message => + string.Format(Messages.PROBLEM_VSWITCH_CONTROLLER_INFO, + string.Format(Messages.XENSERVER_8_2, BrandManager.ProductVersion82)); + } +} diff --git a/XenAdmin/Diagnostics/Problems/Problem.cs b/XenAdmin/Diagnostics/Problems/Problem.cs index 923d6712a..ff5f795b7 100644 --- a/XenAdmin/Diagnostics/Problems/Problem.cs +++ b/XenAdmin/Diagnostics/Problems/Problem.cs @@ -33,6 +33,7 @@ using System; using System.Drawing; using XenAdmin.Actions; using XenAdmin.Diagnostics.Checks; +using XenAdmin.Dialogs; namespace XenAdmin.Diagnostics.Problems { @@ -152,4 +153,31 @@ namespace XenAdmin.Diagnostics.Problems #endregion } + + public abstract class ProblemWithMoreInfo : Problem + { + protected ProblemWithMoreInfo(Check check) + : base(check) + { + } + + public override string HelpMessage => Messages.MORE_INFO; + + public abstract string Message { get; } + + protected override AsyncAction CreateAction(out bool cancelled) + { + Program.Invoke(Program.MainWindow, delegate () + { + using (var dlg = new ThreeButtonDialog( + new ThreeButtonDialog.Details(SystemIcons.Error, Message))) + { + dlg.ShowDialog(); + } + }); + + cancelled = true; + return null; + } + } } diff --git a/XenAdmin/Wizards/PatchingWizard/PatchingWizard_PrecheckPage.cs b/XenAdmin/Wizards/PatchingWizard/PatchingWizard_PrecheckPage.cs index 155a4e1df..c8c212fa0 100644 --- a/XenAdmin/Wizards/PatchingWizard/PatchingWizard_PrecheckPage.cs +++ b/XenAdmin/Wizards/PatchingWizard/PatchingWizard_PrecheckPage.cs @@ -490,9 +490,9 @@ namespace XenAdmin.Wizards.PatchingWizard } - //PVGuestsCheck checks if (highestNewVersion != null || UpdateAlert?.NewServerVersion != null) { + //PVGuestsCheck checks var pvChecks = new List(); foreach (var pool in SelectedPools.Where(p => Helpers.NaplesOrGreater(p.Connection))) { @@ -501,6 +501,16 @@ namespace XenAdmin.Wizards.PatchingWizard } if (pvChecks.Count > 0) groups.Add(new CheckGroup(Messages.CHECKING_PV_GUESTS, pvChecks)); + + //vSwitch controller check - for each pool + var vSwitchChecks = (from Pool pool in SelectedPools.Where( + p => Helpers.NaplesOrGreater(p.Connection) && !Helpers.StockholmOrGreater(p.Connection)) + let master = pool.Connection.Resolve(pool.master) + where master != null + select new VSwitchControllerCheck(master, highestNewVersion ?? UpdateAlert?.NewServerVersion) as Check).ToList(); + + if (vSwitchChecks.Count > 0) + groups.Add(new CheckGroup(Messages.CHECKING_VSWITCH_CONTROLLER_GROUP, vSwitchChecks)); } return groups; diff --git a/XenAdmin/Wizards/RollingUpgradeWizard/RollingUpgradeWizardPrecheckPage.cs b/XenAdmin/Wizards/RollingUpgradeWizard/RollingUpgradeWizardPrecheckPage.cs index b4d3bdf3c..7ecb01b82 100644 --- a/XenAdmin/Wizards/RollingUpgradeWizard/RollingUpgradeWizardPrecheckPage.cs +++ b/XenAdmin/Wizards/RollingUpgradeWizard/RollingUpgradeWizardPrecheckPage.cs @@ -199,6 +199,13 @@ namespace XenAdmin.Wizards.RollingUpgradeWizard groups.Add(new CheckGroup(Messages.CHECKING_SAFE_TO_UPGRADE, safeToUpgradeChecks)); } + //vSwitch controller check - for each pool + var vswitchChecks = (from Host server in SelectedMasters.Where(m => !Helpers.StockholmOrGreater(m)) + select new VSwitchControllerCheck(server, InstallMethodConfig) as Check).ToList(); + + if (vswitchChecks.Count > 0) + groups.Add(new CheckGroup(Messages.CHECKING_VSWITCH_CONTROLLER_GROUP, vswitchChecks)); + //HA checks - for each pool var haChecks = (from Host server in SelectedMasters select new HAOffCheck(server) as Check).ToList(); diff --git a/XenAdmin/XenAdmin.csproj b/XenAdmin/XenAdmin.csproj index c773ed3ee..134a7eeae 100755 --- a/XenAdmin/XenAdmin.csproj +++ b/XenAdmin/XenAdmin.csproj @@ -241,6 +241,7 @@ + @@ -257,6 +258,7 @@ + diff --git a/XenModel/BrandManager.cs b/XenModel/BrandManager.cs index 6196c7ccf..c5528d2a8 100644 --- a/XenModel/BrandManager.cs +++ b/XenModel/BrandManager.cs @@ -63,6 +63,8 @@ namespace XenAdmin.Core public static string ProductVersion81 => Get("PRODUCT_VERSION_8_1"); + public static string ProductVersion82 => Get("PRODUCT_VERSION_8_2"); + public const string PRODUCT_BRAND = "[XenServer product]"; public const string COMPANY_NAME_SHORT = "[Citrix]"; diff --git a/XenModel/Messages.Designer.cs b/XenModel/Messages.Designer.cs index 4d285f246..f47915cc7 100755 --- a/XenModel/Messages.Designer.cs +++ b/XenModel/Messages.Designer.cs @@ -7293,6 +7293,24 @@ namespace XenAdmin { } } + /// + /// Looks up a localized string similar to vSwitch Controller check. + /// + public static string CHECKING_VSWITCH_CONTROLLER { + get { + return ResourceManager.GetString("CHECKING_VSWITCH_CONTROLLER", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Checking vSwitch Controller configuration. + /// + public static string CHECKING_VSWITCH_CONTROLLER_GROUP { + get { + return ResourceManager.GetString("CHECKING_VSWITCH_CONTROLLER_GROUP", resourceCulture); + } + } + /// /// Looks up a localized string similar to Checking [XenCenter] version. /// @@ -30566,6 +30584,33 @@ namespace XenAdmin { } } + /// + /// Looks up a localized string similar to {0}: Support for the vSwitch Controller is dropped as of {1}. + /// + public static string PROBLEM_VSWITCH_CONTROLLER_DESCRIPTION { + get { + return ResourceManager.GetString("PROBLEM_VSWITCH_CONTROLLER_DESCRIPTION", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Deconfigure vSwitch Controller. + /// + public static string PROBLEM_VSWITCH_CONTROLLER_HELP { + get { + return ResourceManager.GetString("PROBLEM_VSWITCH_CONTROLLER_HELP", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to If you are upgrading to {0} and above, you will need to deconfigure the vSwitch Controller, otherwise you may end up with an unstable, even vulnerable, system.. + /// + public static string PROBLEM_VSWITCH_CONTROLLER_INFO { + get { + return ResourceManager.GetString("PROBLEM_VSWITCH_CONTROLLER_INFO", resourceCulture); + } + } + /// /// Looks up a localized string similar to [XenCenter] version. /// @@ -41720,6 +41765,15 @@ namespace XenAdmin { } } + /// + /// Looks up a localized string similar to [XenServer] {0}. + /// + public static string XENSERVER_8_2 { + get { + return ResourceManager.GetString("XENSERVER_8_2", resourceCulture); + } + } + /// /// Looks up a localized string similar to [XenServer] Templates. /// diff --git a/XenModel/Messages.resx b/XenModel/Messages.resx index 5e117695a..d72921aca 100755 --- a/XenModel/Messages.resx +++ b/XenModel/Messages.resx @@ -2616,6 +2616,12 @@ Do you want to assign it to the schedule '{2}' instead? Host partition layout check + + vSwitch Controller check + + + Checking vSwitch Controller configuration + Checking reboots required @@ -10565,6 +10571,15 @@ Please reconnect the host and try again Server '{0}' + + {0}: Support for the vSwitch Controller is dropped as of {1} + + + Deconfigure vSwitch Controller + + + If you are upgrading to {0} and above, you will need to deconfigure the vSwitch Controller, otherwise you may end up with an unstable, even vulnerable, system. + The MAC address entered has already been assigned to the VM: {1} @@ -14380,6 +14395,9 @@ Are you sure you want to enable automated power management for this Host? [XenServer] {0} + + [XenServer] {0} + [XenServer] Templates diff --git a/XenModel/XenAPI-Extensions/Host.cs b/XenModel/XenAPI-Extensions/Host.cs index d42a7131c..8091bb591 100644 --- a/XenModel/XenAPI-Extensions/Host.cs +++ b/XenModel/XenAPI-Extensions/Host.cs @@ -39,6 +39,7 @@ using XenAdmin; using XenAdmin.Core; using XenAdmin.Network; using System.Diagnostics; +using System.Web.Script.Serialization; namespace XenAPI @@ -1225,7 +1226,6 @@ namespace XenAPI return vm != null ? vm.memory_static_max - vm.memory_static_min : 0; } - /// /// Friendly string showing memory usage on the host /// @@ -1582,6 +1582,28 @@ namespace XenAPI !Helpers.FeatureForbidden(Connection, RestrictIntegratedGpuPassthrough); } + public static bool TryGetUpgradeVersion(Host host, Dictionary installMethodConfig, + out string platformVersion, out string productVersion) + { + platformVersion = productVersion = null; + + try + { + var result = call_plugin(host.Connection.Session, host.opaque_ref, + "prepare_host_upgrade.py", "getVersion", installMethodConfig); + var serializer = new JavaScriptSerializer(); + var version = (Dictionary)serializer.DeserializeObject(result); + platformVersion = version.ContainsKey("platform-version") ? (string)version["platform-version"] : null; + productVersion = version.ContainsKey("product-version") ? (string)version["product-version"] : null; + return platformVersion != null || productVersion != null; + } + catch (Exception exception) + { + log.WarnFormat("Plugin call prepare_host_upgrade.getVersion on {0} failed with {1}", host.Name(), exception.Message); + return false; + } + } + #region IEquatable Members /// From 00cc547aaff23e43de6e6472fe873b0ef659aec3 Mon Sep 17 00:00:00 2001 From: Konstantina Chremmou Date: Fri, 28 Feb 2020 13:40:25 +0000 Subject: [PATCH 05/10] Warning and error corrections. Signed-off-by: Konstantina Chremmou --- .../PoolProblem/PoolHasPVGuestWarningUrl.cs | 7 ++- .../PoolProblem/VSwitchControllerProblem.cs | 11 +++- XenAdmin/Diagnostics/Problems/Problem.cs | 9 +++ .../Problems/WarningWithMoreInfo.cs | 11 +++- .../Dialogs/ThreeButtonDialog.Designer.cs | 14 ++++- XenAdmin/Dialogs/ThreeButtonDialog.cs | 24 ++++++++ XenAdmin/Dialogs/ThreeButtonDialog.resx | 60 +++++++++++++------ XenModel/Messages.Designer.cs | 18 +++--- XenModel/Messages.resx | 14 ++--- 9 files changed, 127 insertions(+), 41 deletions(-) diff --git a/XenAdmin/Diagnostics/Problems/PoolProblem/PoolHasPVGuestWarningUrl.cs b/XenAdmin/Diagnostics/Problems/PoolProblem/PoolHasPVGuestWarningUrl.cs index a43e960af..7adc6d88f 100644 --- a/XenAdmin/Diagnostics/Problems/PoolProblem/PoolHasPVGuestWarningUrl.cs +++ b/XenAdmin/Diagnostics/Problems/PoolProblem/PoolHasPVGuestWarningUrl.cs @@ -31,6 +31,7 @@ using XenAdmin.Diagnostics.Checks; using System; +using XenAdmin.Core; using XenAPI; namespace XenAdmin.Diagnostics.Problems.PoolProblem @@ -48,7 +49,11 @@ namespace XenAdmin.Diagnostics.Problems.PoolProblem private string PVGuestCheckUrl => string.Format(InvisibleMessages.PV_GUESTS_CHECK_URL); public override Uri UriToLaunch => new Uri(PVGuestCheckUrl); public override string Title => Description; - public override string Description => string.Format(Messages.POOL_HAS_PV_GUEST_WARNING, _pool.Name()); + + public override string Description => + string.Format(Messages.POOL_HAS_PV_GUEST_WARNING, _pool.Name(), + string.Format(Messages.XENSERVER_8_1, BrandManager.ProductVersion81)); + public override string HelpMessage => LinkText; public override string LinkText => Messages.LEARN_MORE; } diff --git a/XenAdmin/Diagnostics/Problems/PoolProblem/VSwitchControllerProblem.cs b/XenAdmin/Diagnostics/Problems/PoolProblem/VSwitchControllerProblem.cs index 663352689..797ab528d 100644 --- a/XenAdmin/Diagnostics/Problems/PoolProblem/VSwitchControllerProblem.cs +++ b/XenAdmin/Diagnostics/Problems/PoolProblem/VSwitchControllerProblem.cs @@ -29,7 +29,6 @@ * SUCH DAMAGE. */ -using XenAdmin.Actions; using XenAdmin.Core; using XenAdmin.Diagnostics.Checks; using XenAPI; @@ -49,12 +48,15 @@ namespace XenAdmin.Diagnostics.Problems.PoolProblem public override string Title => Check.Description; + public override string LinkData => InvisibleMessages.DEPRECATION_URL; + public override string LinkText => Messages.LEARN_MORE; + public override string Description => string.Format(Messages.PROBLEM_VSWITCH_CONTROLLER_DESCRIPTION, _pool, string.Format(Messages.XENSERVER_8_2, BrandManager.ProductVersion82)); public override string Message => - string.Format(Messages.PROBLEM_VSWITCH_CONTROLLER_INFO, + string.Format(Messages.PROBLEM_VSWITCH_CONTROLLER_INFO_ERROR, string.Format(Messages.XENSERVER_8_2, BrandManager.ProductVersion82)); } @@ -70,12 +72,15 @@ namespace XenAdmin.Diagnostics.Problems.PoolProblem public override string Title => Check.Description; + public override string LinkData => InvisibleMessages.DEPRECATION_URL; + public override string LinkText => Messages.LEARN_MORE; + public override string Description => string.Format(Messages.PROBLEM_VSWITCH_CONTROLLER_DESCRIPTION, pool, string.Format(Messages.XENSERVER_8_2, BrandManager.ProductVersion82)); public override string Message => - string.Format(Messages.PROBLEM_VSWITCH_CONTROLLER_INFO, + string.Format(Messages.PROBLEM_VSWITCH_CONTROLLER_INFO_WARNING, string.Format(Messages.XENSERVER_8_2, BrandManager.ProductVersion82)); } } diff --git a/XenAdmin/Diagnostics/Problems/Problem.cs b/XenAdmin/Diagnostics/Problems/Problem.cs index ff5f795b7..56ae29fc4 100644 --- a/XenAdmin/Diagnostics/Problems/Problem.cs +++ b/XenAdmin/Diagnostics/Problems/Problem.cs @@ -165,6 +165,9 @@ namespace XenAdmin.Diagnostics.Problems public abstract string Message { get; } + public virtual string LinkData => null; + public virtual string LinkText => LinkData; + protected override AsyncAction CreateAction(out bool cancelled) { Program.Invoke(Program.MainWindow, delegate () @@ -172,6 +175,12 @@ namespace XenAdmin.Diagnostics.Problems using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details(SystemIcons.Error, Message))) { + if (!string.IsNullOrEmpty(LinkText) && !string.IsNullOrEmpty(LinkData)) + { + dlg.LinkText = LinkText; + dlg.LinkData = LinkData; + dlg.ShowLinkLabel = true; + } dlg.ShowDialog(); } }); diff --git a/XenAdmin/Diagnostics/Problems/WarningWithMoreInfo.cs b/XenAdmin/Diagnostics/Problems/WarningWithMoreInfo.cs index 190492310..1dd452cfd 100644 --- a/XenAdmin/Diagnostics/Problems/WarningWithMoreInfo.cs +++ b/XenAdmin/Diagnostics/Problems/WarningWithMoreInfo.cs @@ -45,11 +45,17 @@ namespace XenAdmin.Diagnostics.Problems protected override Actions.AsyncAction CreateAction(out bool cancelled) { - Program.Invoke(Program.MainWindow, delegate () + Program.Invoke(Program.MainWindow, () => { using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details(SystemIcons.Warning, Message))) { + if (!string.IsNullOrEmpty(LinkText) && !string.IsNullOrEmpty(LinkData)) + { + dlg.LinkText = LinkText; + dlg.LinkData = LinkData; + dlg.ShowLinkLabel = true; + } dlg.ShowDialog(); } }); @@ -59,5 +65,8 @@ namespace XenAdmin.Diagnostics.Problems } public abstract string Message { get; } + + public virtual string LinkData => null; + public virtual string LinkText => LinkData; } } diff --git a/XenAdmin/Dialogs/ThreeButtonDialog.Designer.cs b/XenAdmin/Dialogs/ThreeButtonDialog.Designer.cs index 60fef0882..d6e69e06e 100644 --- a/XenAdmin/Dialogs/ThreeButtonDialog.Designer.cs +++ b/XenAdmin/Dialogs/ThreeButtonDialog.Designer.cs @@ -37,6 +37,7 @@ namespace XenAdmin.Dialogs this.button1 = new System.Windows.Forms.Button(); this.labelMessage = new System.Windows.Forms.LinkLabel(); this.checkBoxOption = new System.Windows.Forms.CheckBox(); + this.linkLabel1 = new System.Windows.Forms.LinkLabel(); this.tableLayoutPanel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxIcon)).BeginInit(); this.flowLayoutPanel1.SuspendLayout(); @@ -46,9 +47,10 @@ namespace XenAdmin.Dialogs // resources.ApplyResources(this.tableLayoutPanel1, "tableLayoutPanel1"); this.tableLayoutPanel1.Controls.Add(this.pictureBoxIcon, 0, 0); - this.tableLayoutPanel1.Controls.Add(this.flowLayoutPanel1, 1, 2); + this.tableLayoutPanel1.Controls.Add(this.flowLayoutPanel1, 1, 3); this.tableLayoutPanel1.Controls.Add(this.labelMessage, 1, 0); - this.tableLayoutPanel1.Controls.Add(this.checkBoxOption, 1, 1); + this.tableLayoutPanel1.Controls.Add(this.checkBoxOption, 1, 2); + this.tableLayoutPanel1.Controls.Add(this.linkLabel1, 1, 1); this.tableLayoutPanel1.Name = "tableLayoutPanel1"; // // pictureBoxIcon @@ -99,6 +101,13 @@ namespace XenAdmin.Dialogs this.checkBoxOption.Name = "checkBoxOption"; this.checkBoxOption.UseVisualStyleBackColor = true; // + // linkLabel1 + // + resources.ApplyResources(this.linkLabel1, "linkLabel1"); + this.linkLabel1.Name = "linkLabel1"; + this.linkLabel1.TabStop = true; + this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel1_LinkClicked); + // // ThreeButtonDialog // resources.ApplyResources(this, "$this"); @@ -128,5 +137,6 @@ namespace XenAdmin.Dialogs private System.Windows.Forms.Button button3; private System.Windows.Forms.LinkLabel labelMessage; private System.Windows.Forms.CheckBox checkBoxOption; + private System.Windows.Forms.LinkLabel linkLabel1; } } \ No newline at end of file diff --git a/XenAdmin/Dialogs/ThreeButtonDialog.cs b/XenAdmin/Dialogs/ThreeButtonDialog.cs index b84005c44..2ef4314ae 100644 --- a/XenAdmin/Dialogs/ThreeButtonDialog.cs +++ b/XenAdmin/Dialogs/ThreeButtonDialog.cs @@ -147,6 +147,20 @@ namespace XenAdmin.Dialogs } } + public bool ShowLinkLabel + { + get { return linkLabel1.Visible; } + set { linkLabel1.Visible = value; } + } + + public string LinkText + { + get { return linkLabel1.Text; } + set { linkLabel1.Text = value; } + } + + public string LinkData { get; set; } + public bool ShowCheckbox { get { return checkBoxOption.Visible; } @@ -410,6 +424,16 @@ namespace XenAdmin.Dialogs } catch { } // Best effort } + + private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) + { + try + { + if (!string.IsNullOrEmpty(LinkData)) + System.Diagnostics.Process.Start(LinkData); + } + catch { } + } } public class NonModalThreeButtonDialog : ThreeButtonDialog diff --git a/XenAdmin/Dialogs/ThreeButtonDialog.resx b/XenAdmin/Dialogs/ThreeButtonDialog.resx index 5643cc3a0..5a054cb64 100644 --- a/XenAdmin/Dialogs/ThreeButtonDialog.resx +++ b/XenAdmin/Dialogs/ThreeButtonDialog.resx @@ -180,9 +180,6 @@ 165, 3 - - 3, 3, 0, 0 - 75, 30 @@ -213,9 +210,6 @@ 84, 3 - - 3, 3, 3, 0 - 75, 30 @@ -246,9 +240,6 @@ 3, 3 - - 3, 3, 3, 0 - 75, 30 @@ -277,13 +268,13 @@ Segoe UI, 9pt - 96, 74 + 93, 86 50, 0, 0, 0 - 240, 33 + 243, 36 2 @@ -313,10 +304,10 @@ 0, 0 - 43, 5 + 41, 0 - 5, 5, 5, 15 + 3, 0, 3, 15 409, 9999 @@ -349,7 +340,7 @@ Segoe UI, 9pt - 41, 52 + 41, 64 82, 19 @@ -375,6 +366,39 @@ 3 + + True + + + Segoe UI, 9pt + + + 41, 46 + + + 60, 15 + + + 5 + + + linkLabel1 + + + False + + + linkLabel1 + + + System.Windows.Forms.LinkLabel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tableLayoutPanel1 + + + 4 + Fill @@ -388,10 +412,10 @@ 10, 10, 10, 10 - 3 + 4 - 336, 107 + 336, 122 0 @@ -409,7 +433,7 @@ 0 - <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="pictureBoxIcon" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="flowLayoutPanel1" Row="2" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="labelMessage" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="checkBoxOption" Row="1" RowSpan="1" Column="1" ColumnSpan="1" /></Controls><Columns Styles="AutoSize,0,Percent,100" /><Rows Styles="Percent,100,AutoSize,0,AutoSize,0" /></TableLayoutSettings> + <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="pictureBoxIcon" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="flowLayoutPanel1" Row="3" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="labelMessage" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="checkBoxOption" Row="2" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="linkLabel1" Row="1" RowSpan="1" Column="1" ColumnSpan="1" /></Controls><Columns Styles="AutoSize,0,Percent,100" /><Rows Styles="Percent,100,AutoSize,0,AutoSize,0,AutoSize,0" /></TableLayoutSettings> True @@ -424,7 +448,7 @@ GrowAndShrink - 356, 127 + 356, 142 Segoe UI, 9pt diff --git a/XenModel/Messages.Designer.cs b/XenModel/Messages.Designer.cs index f47915cc7..1730c9e21 100755 --- a/XenModel/Messages.Designer.cs +++ b/XenModel/Messages.Designer.cs @@ -21383,7 +21383,7 @@ namespace XenAdmin { } /// - /// Looks up a localized string similar to Learn more. + /// Looks up a localized string similar to Learn more.... /// public static string LEARN_MORE { get { @@ -30148,7 +30148,7 @@ namespace XenAdmin { } /// - /// Looks up a localized string similar to {0}: Support for paravirtualized (PV) guests is dropped as of [XenServer] {1}. Click "Learn more" to see the list of supported guest operating systems. . + /// Looks up a localized string similar to {0}: Support for paravirtualized (PV) guests has been removed in {1}. Click Learn more to see the list of supported guest operating systems.. /// public static string POOL_HAS_PV_GUEST_WARNING { get { @@ -30585,7 +30585,7 @@ namespace XenAdmin { } /// - /// Looks up a localized string similar to {0}: Support for the vSwitch Controller is dropped as of {1}. + /// Looks up a localized string similar to {0}: Support for the vSwitch Controller has been removed in {1}.. /// public static string PROBLEM_VSWITCH_CONTROLLER_DESCRIPTION { get { @@ -30594,20 +30594,20 @@ namespace XenAdmin { } /// - /// Looks up a localized string similar to Deconfigure vSwitch Controller. + /// Looks up a localized string similar to Support for the vSwitch Controller has been removed in {0}. You must deconfigure the controller because any features that require it will no longer work. Please click the link below for more information.. /// - public static string PROBLEM_VSWITCH_CONTROLLER_HELP { + public static string PROBLEM_VSWITCH_CONTROLLER_INFO_ERROR { get { - return ResourceManager.GetString("PROBLEM_VSWITCH_CONTROLLER_HELP", resourceCulture); + return ResourceManager.GetString("PROBLEM_VSWITCH_CONTROLLER_INFO_ERROR", resourceCulture); } } /// - /// Looks up a localized string similar to If you are upgrading to {0} and above, you will need to deconfigure the vSwitch Controller, otherwise you may end up with an unstable, even vulnerable, system.. + /// Looks up a localized string similar to If you are upgrading to {0} and above, you must deconfigure the vSwitch Controller because support for it has been removed in this release and any features that require it will no longer work. Please click the link below for more information.. /// - public static string PROBLEM_VSWITCH_CONTROLLER_INFO { + public static string PROBLEM_VSWITCH_CONTROLLER_INFO_WARNING { get { - return ResourceManager.GetString("PROBLEM_VSWITCH_CONTROLLER_INFO", resourceCulture); + return ResourceManager.GetString("PROBLEM_VSWITCH_CONTROLLER_INFO_WARNING", resourceCulture); } } diff --git a/XenModel/Messages.resx b/XenModel/Messages.resx index d72921aca..7f421b88d 100755 --- a/XenModel/Messages.resx +++ b/XenModel/Messages.resx @@ -7438,7 +7438,7 @@ Size: {3} License Manager - Learn more + Learn more... Enter a user name and password with sufficient privileges to remove your machine account from AD. Authentication will be disabled even if the machine account cannot be removed. @@ -10494,7 +10494,7 @@ Please reconnect the host and try again This pool has no shared storage - {0}: Support for paravirtualized (PV) guests is dropped as of [XenServer] {1}. Click "Learn more" to see the list of supported guest operating systems. + {0}: Support for paravirtualized (PV) guests has been removed in {1}. Click Learn more to see the list of supported guest operating systems. The pool is partially licensed @@ -10572,13 +10572,13 @@ Please reconnect the host and try again Server '{0}' - {0}: Support for the vSwitch Controller is dropped as of {1} + {0}: Support for the vSwitch Controller has been removed in {1}. - - Deconfigure vSwitch Controller + + Support for the vSwitch Controller has been removed in {0}. You must deconfigure the controller because any features that require it will no longer work. Please click the link below for more information. - - If you are upgrading to {0} and above, you will need to deconfigure the vSwitch Controller, otherwise you may end up with an unstable, even vulnerable, system. + + If you are upgrading to {0} and above, you must deconfigure the vSwitch Controller because support for it has been removed in this release and any features that require it will no longer work. Please click the link below for more information. The MAC address entered has already been assigned to the VM: From 237da850b82b3e2c35c9a7fc15c6fe8bd65babf5 Mon Sep 17 00:00:00 2001 From: Konstantina Chremmou Date: Thu, 5 Mar 2020 08:34:17 +0000 Subject: [PATCH 06/10] Moved vSwitch controlller check closer to the top of the check list. Signed-off-by: Konstantina Chremmou --- .../PatchingWizard_PrecheckPage.cs | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/XenAdmin/Wizards/PatchingWizard/PatchingWizard_PrecheckPage.cs b/XenAdmin/Wizards/PatchingWizard/PatchingWizard_PrecheckPage.cs index c8c212fa0..dd65478cf 100644 --- a/XenAdmin/Wizards/PatchingWizard/PatchingWizard_PrecheckPage.cs +++ b/XenAdmin/Wizards/PatchingWizard/PatchingWizard_PrecheckPage.cs @@ -356,6 +356,19 @@ namespace XenAdmin.Wizards.PatchingWizard groups.Add(new CheckGroup(Messages.CHECKING_HOST_LIVENESS_STATUS, livenessChecks)); + if (WizardMode == WizardMode.NewVersion) + { + //vSwitch controller check - for each pool + var vSwitchChecks = (from Pool pool in SelectedPools.Where( + p => Helpers.NaplesOrGreater(p.Connection) && !Helpers.StockholmOrGreater(p.Connection)) + let master = pool.Connection.Resolve(pool.master) + where master != null + select new VSwitchControllerCheck(master, UpdateAlert?.NewServerVersion) as Check).ToList(); + + if (vSwitchChecks.Count > 0) + groups.Add(new CheckGroup(Messages.CHECKING_VSWITCH_CONTROLLER_GROUP, vSwitchChecks)); + } + //HA checks var haChecks = new List(); @@ -501,16 +514,6 @@ namespace XenAdmin.Wizards.PatchingWizard } if (pvChecks.Count > 0) groups.Add(new CheckGroup(Messages.CHECKING_PV_GUESTS, pvChecks)); - - //vSwitch controller check - for each pool - var vSwitchChecks = (from Pool pool in SelectedPools.Where( - p => Helpers.NaplesOrGreater(p.Connection) && !Helpers.StockholmOrGreater(p.Connection)) - let master = pool.Connection.Resolve(pool.master) - where master != null - select new VSwitchControllerCheck(master, highestNewVersion ?? UpdateAlert?.NewServerVersion) as Check).ToList(); - - if (vSwitchChecks.Count > 0) - groups.Add(new CheckGroup(Messages.CHECKING_VSWITCH_CONTROLLER_GROUP, vSwitchChecks)); } return groups; From 608f56fe7d08c6dcc3e720577db4b7307633d712 Mon Sep 17 00:00:00 2001 From: Konstantina Chremmou Date: Wed, 18 Mar 2020 02:01:55 +0000 Subject: [PATCH 07/10] CA-336931: Informational problems should not be resolvable. Signed-off-by: Konstantina Chremmou --- XenAdmin/Diagnostics/Problems/Problem.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/XenAdmin/Diagnostics/Problems/Problem.cs b/XenAdmin/Diagnostics/Problems/Problem.cs index 56ae29fc4..c7aaf8c54 100644 --- a/XenAdmin/Diagnostics/Problems/Problem.cs +++ b/XenAdmin/Diagnostics/Problems/Problem.cs @@ -160,7 +160,9 @@ namespace XenAdmin.Diagnostics.Problems : base(check) { } - + + public override bool IsFixable => false; + public override string HelpMessage => Messages.MORE_INFO; public abstract string Message { get; } From 888a0555ab8871089acf27b8a62a47820c1ddb13 Mon Sep 17 00:00:00 2001 From: Konstantina Chremmou Date: Thu, 26 Mar 2020 16:54:56 +0000 Subject: [PATCH 08/10] CA-337287: Skip vSwitch controller and PV guest checks with a warning if the RPU hotfix is missing. Signed-off-by: Konstantina Chremmou --- .../Diagnostics/Checks/HostHasHotfixCheck.cs | 8 +--- XenAdmin/Diagnostics/Checks/PVGuestsCheck.cs | 42 ++++++++++++------- .../Checks/VSwitchControllerCheck.cs | 16 ++++++- .../Diagnostics/Hotfixing/HotfixFactory.cs | 14 +++---- .../HostProblem/HostDoesNotHaveHotfix.cs | 39 +++++++++-------- .../RollingUpgradeWizardPrecheckPage.cs | 6 +-- XenModel/Messages.Designer.cs | 13 +++++- XenModel/Messages.resx | 5 ++- 8 files changed, 86 insertions(+), 57 deletions(-) diff --git a/XenAdmin/Diagnostics/Checks/HostHasHotfixCheck.cs b/XenAdmin/Diagnostics/Checks/HostHasHotfixCheck.cs index ce2465d53..6bf904173 100644 --- a/XenAdmin/Diagnostics/Checks/HostHasHotfixCheck.cs +++ b/XenAdmin/Diagnostics/Checks/HostHasHotfixCheck.cs @@ -39,7 +39,6 @@ namespace XenAdmin.Diagnostics.Checks { class HostHasHotfixCheck : HostPostLivenessCheck { - private readonly HotfixFactory hotfixFactory = new HotfixFactory(); public HostHasHotfixCheck(Host host) : base(host) { @@ -47,16 +46,13 @@ namespace XenAdmin.Diagnostics.Checks protected override Problem RunHostCheck() { - var hotfix = hotfixFactory.Hotfix(Host); + var hotfix = HotfixFactory.Hotfix(Host); if (hotfix != null && hotfix.ShouldBeAppliedTo(Host)) return new HostDoesNotHaveHotfix(this, Host); return null; } - public override string Description - { - get { return Messages.HOTFIX_CHECK; } - } + public override string Description => Messages.HOTFIX_CHECK; } } diff --git a/XenAdmin/Diagnostics/Checks/PVGuestsCheck.cs b/XenAdmin/Diagnostics/Checks/PVGuestsCheck.cs index 0d7654b70..48f0e9914 100644 --- a/XenAdmin/Diagnostics/Checks/PVGuestsCheck.cs +++ b/XenAdmin/Diagnostics/Checks/PVGuestsCheck.cs @@ -36,7 +36,8 @@ using XenAPI; using XenAdmin.Diagnostics.Problems; using XenAdmin.Diagnostics.Problems.PoolProblem; using System.Collections.Generic; -using System.Web.Script.Serialization; +using XenAdmin.Diagnostics.Hotfixing; +using XenAdmin.Diagnostics.Problems.HostProblem; namespace XenAdmin.Diagnostics.Checks { @@ -44,40 +45,49 @@ namespace XenAdmin.Diagnostics.Checks { private readonly Pool _pool; private readonly bool _upgrade; - private readonly Dictionary _installMethodConfig; private readonly bool _manualUpgrade; - private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private readonly Dictionary _installMethodConfig; - public PVGuestsCheck(Pool pool, bool upgrade, Dictionary installMethodConfig = null, bool manualUpgrade = false) + public PVGuestsCheck(Pool pool, bool upgrade, bool manualUpgrade = false, Dictionary installMethodConfig = null) : base(Helpers.GetMaster(pool.Connection)) { _pool = pool; _upgrade = upgrade; - _installMethodConfig = installMethodConfig; _manualUpgrade = manualUpgrade; + _installMethodConfig = installMethodConfig; } protected override Problem RunHostCheck() { - string upgradePlatformVersion; if (!_pool.Connection.Cache.VMs.Any(vm => vm.IsPvVm())) return null; - if (!_upgrade || _manualUpgrade) + + //update case + if (!_upgrade) return new PoolHasPVGuestWarningUrl(this, _pool); - try + + //upgrade case + + if (!_manualUpgrade) { - var result = Host.call_plugin(Host.Connection.Session, Host.opaque_ref, "prepare_host_upgrade.py", "getVersion", _installMethodConfig); - var serializer = new JavaScriptSerializer(); - var version = (Dictionary)serializer.DeserializeObject(result); - upgradePlatformVersion = version.ContainsKey("platform-version") ? (string)version["platform-version"] : null; + var hotfix = HotfixFactory.Hotfix(Host); + if (hotfix != null && hotfix.ShouldBeAppliedTo(Host)) + return new HostDoesNotHaveHotfixWarning(this, Host); } - catch (Exception exception) - { - log.Warn($"Plugin call prepare_host_upgrade.getVersion on {Host.Name()} threw an exception.", exception); + + string upgradePlatformVersion = null; + + if (_installMethodConfig != null) + Host.TryGetUpgradeVersion(Host, _installMethodConfig, out upgradePlatformVersion, out _); + + // we don't know the upgrade version, so add warning + // (this is the case of the manual upgrade or when the rpu plugin doesn't have the function) + if (string.IsNullOrEmpty(upgradePlatformVersion)) return new PoolHasPVGuestWarningUrl(this, _pool); - } + if (Helpers.QuebecOrGreater(upgradePlatformVersion)) return new PoolHasPVGuestWarningUrl(this, _pool); + return null; } diff --git a/XenAdmin/Diagnostics/Checks/VSwitchControllerCheck.cs b/XenAdmin/Diagnostics/Checks/VSwitchControllerCheck.cs index ea9ea5c07..7ae522bff 100644 --- a/XenAdmin/Diagnostics/Checks/VSwitchControllerCheck.cs +++ b/XenAdmin/Diagnostics/Checks/VSwitchControllerCheck.cs @@ -32,7 +32,9 @@ using System; using System.Collections.Generic; using XenAdmin.Core; +using XenAdmin.Diagnostics.Hotfixing; using XenAdmin.Diagnostics.Problems; +using XenAdmin.Diagnostics.Problems.HostProblem; using XenAdmin.Diagnostics.Problems.PoolProblem; using XenAPI; @@ -42,7 +44,8 @@ namespace XenAdmin.Diagnostics.Checks { private readonly Dictionary _installMethodConfig; private readonly Pool _pool; - private XenServerVersion _newVersion; + private readonly XenServerVersion _newVersion; + private readonly bool _manualUpgrade; public VSwitchControllerCheck(Host host, XenServerVersion newVersion) : base(host) @@ -51,10 +54,11 @@ namespace XenAdmin.Diagnostics.Checks _pool = Helpers.GetPoolOfOne(Host?.Connection); } - public VSwitchControllerCheck(Host host, Dictionary installMethodConfig) + public VSwitchControllerCheck(Host host, Dictionary installMethodConfig, bool manualUpgrade) : base(host) { _installMethodConfig = installMethodConfig; + _manualUpgrade = manualUpgrade; _pool = Helpers.GetPoolOfOne(Host?.Connection); } @@ -74,6 +78,14 @@ namespace XenAdmin.Diagnostics.Checks } //upgrade case + + if (!_manualUpgrade) + { + var hotfix = HotfixFactory.Hotfix(Host); + if (hotfix != null && hotfix.ShouldBeAppliedTo(Host)) + return new HostDoesNotHaveHotfixWarning(this, Host); + } + string upgradePlatformVersion = null; if (_installMethodConfig != null) diff --git a/XenAdmin/Diagnostics/Hotfixing/HotfixFactory.cs b/XenAdmin/Diagnostics/Hotfixing/HotfixFactory.cs index 5b39fe1f8..5412cd34f 100644 --- a/XenAdmin/Diagnostics/Hotfixing/HotfixFactory.cs +++ b/XenAdmin/Diagnostics/Hotfixing/HotfixFactory.cs @@ -35,7 +35,7 @@ using XenAPI; namespace XenAdmin.Diagnostics.Hotfixing { - internal sealed class HotfixFactory + internal static class HotfixFactory { public enum HotfixableServerVersion { @@ -44,25 +44,25 @@ namespace XenAdmin.Diagnostics.Hotfixing Naples } - private readonly Hotfix dundeeHotfix = new SingleHotfix + private static readonly Hotfix dundeeHotfix = new SingleHotfix { Filename = "RPU003", UUID = "b651dd22-df7d-45a4-8c0a-6be037bc1714" }; - private readonly Hotfix elyLimaHotfix = new SingleHotfix + private static readonly Hotfix elyLimaHotfix = new SingleHotfix { Filename = "RPU004", UUID = "1821854d-0171-4696-a9c4-01daf75a45a0" }; - private readonly Hotfix naplesHotfix = new SingleHotfix + private static readonly Hotfix naplesHotfix = new SingleHotfix { Filename = "RPU005", UUID = "b43ea62d-2804-4589-9164-f6cc5867d011" }; - public Hotfix Hotfix(Host host) + public static Hotfix Hotfix(Host host) { if (Helpers.NaplesOrGreater(host) && !Helpers.QuebecOrGreater(host)) return Hotfix(HotfixableServerVersion.Naples); @@ -73,7 +73,7 @@ namespace XenAdmin.Diagnostics.Hotfixing return null; } - public Hotfix Hotfix(HotfixableServerVersion version) + public static Hotfix Hotfix(HotfixableServerVersion version) { if (version == HotfixableServerVersion.Naples) return naplesHotfix; @@ -85,7 +85,7 @@ namespace XenAdmin.Diagnostics.Hotfixing throw new ArgumentException("A version was provided for which there is no hotfix filename"); } - public bool IsHotfixRequired(Host host) + public static bool IsHotfixRequired(Host host) { return Hotfix(host) != null; } diff --git a/XenAdmin/Diagnostics/Problems/HostProblem/HostDoesNotHaveHotfix.cs b/XenAdmin/Diagnostics/Problems/HostProblem/HostDoesNotHaveHotfix.cs index ae0e03182..3a22305e3 100644 --- a/XenAdmin/Diagnostics/Problems/HostProblem/HostDoesNotHaveHotfix.cs +++ b/XenAdmin/Diagnostics/Problems/HostProblem/HostDoesNotHaveHotfix.cs @@ -29,39 +29,23 @@ * SUCH DAMAGE. */ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading; -using XenAdmin.Core; using XenAdmin.Diagnostics.Checks; using XenAdmin.Diagnostics.Hotfixing; -using XenAdmin.Properties; using XenAPI; + namespace XenAdmin.Diagnostics.Problems.HostProblem { class HostDoesNotHaveHotfix : HostProblem { - private readonly HotfixFactory hotfixFactory = new HotfixFactory(); - public HostDoesNotHaveHotfix(HostHasHotfixCheck check, Host server) : base(check, server) { } - public override string Description - { - get { return string.Format(Messages.REQUIRED_HOTFIX_ISNOT_INSTALLED, ServerName); } - } + public override string Description => string.Format(Messages.REQUIRED_HOTFIX_NOT_INSTALLED, ServerName); - public override string HelpMessage - { - get { return Messages.APPLY_HOTFIX; } - } + public override string HelpMessage => Messages.APPLY_HOTFIX; protected override Actions.AsyncAction CreateAction(out bool cancelled) { @@ -69,10 +53,25 @@ namespace XenAdmin.Diagnostics.Problems.HostProblem return new Actions.DelegatedAsyncAction(Server.Connection, string.Format(Messages.APPLYING_HOTFIX_TO_HOST, Server), "", "", (ss) => { - Hotfix hotfix = hotfixFactory.Hotfix(Server); + Hotfix hotfix = HotfixFactory.Hotfix(Server); if (hotfix != null) hotfix.Apply(Server, ss); }, true); } } + + class HostDoesNotHaveHotfixWarning : Warning + { + private readonly Host host; + + public HostDoesNotHaveHotfixWarning(Check check, Host host) + : base(check) + { + this.host = host; + } + + public override string Title => Check.Description; + + public override string Description => string.Format(Messages.REQUIRED_HOTFIX_NOT_INSTALLED_WARNING, host); + } } diff --git a/XenAdmin/Wizards/RollingUpgradeWizard/RollingUpgradeWizardPrecheckPage.cs b/XenAdmin/Wizards/RollingUpgradeWizard/RollingUpgradeWizardPrecheckPage.cs index 7ecb01b82..aece209ec 100644 --- a/XenAdmin/Wizards/RollingUpgradeWizard/RollingUpgradeWizardPrecheckPage.cs +++ b/XenAdmin/Wizards/RollingUpgradeWizard/RollingUpgradeWizardPrecheckPage.cs @@ -179,7 +179,7 @@ namespace XenAdmin.Wizards.RollingUpgradeWizard var hotfixChecks = new List(); foreach (var host in hostsToUpgrade) { - if (new HotfixFactory().IsHotfixRequired(host) && !ManualUpgrade) + if (HotfixFactory.IsHotfixRequired(host) && !ManualUpgrade) hotfixChecks.Add(new HostHasHotfixCheck(host)); } if (hotfixChecks.Count > 0) @@ -201,7 +201,7 @@ namespace XenAdmin.Wizards.RollingUpgradeWizard //vSwitch controller check - for each pool var vswitchChecks = (from Host server in SelectedMasters.Where(m => !Helpers.StockholmOrGreater(m)) - select new VSwitchControllerCheck(server, InstallMethodConfig) as Check).ToList(); + select new VSwitchControllerCheck(server, InstallMethodConfig, ManualUpgrade) as Check).ToList(); if (vswitchChecks.Count > 0) groups.Add(new CheckGroup(Messages.CHECKING_VSWITCH_CONTROLLER_GROUP, vswitchChecks)); @@ -250,7 +250,7 @@ namespace XenAdmin.Wizards.RollingUpgradeWizard foreach (Pool pool in SelectedPools.Where(p => !Helpers.QuebecOrGreater(p.Connection))) { if (pool.Connection.Resolve(pool.master) != null) - pvChecks.Add(new PVGuestsCheck(pool, true, InstallMethodConfig, ManualUpgrade)); + pvChecks.Add(new PVGuestsCheck(pool, true, ManualUpgrade, InstallMethodConfig)); } if (pvChecks.Count > 0) groups.Add(new CheckGroup(Messages.CHECKING_PV_GUESTS, pvChecks)); diff --git a/XenModel/Messages.Designer.cs b/XenModel/Messages.Designer.cs index 1730c9e21..01a0db569 100755 --- a/XenModel/Messages.Designer.cs +++ b/XenModel/Messages.Designer.cs @@ -31861,9 +31861,18 @@ namespace XenAdmin { /// /// Looks up a localized string similar to {0}: The required hotfix is not installed. /// - public static string REQUIRED_HOTFIX_ISNOT_INSTALLED { + public static string REQUIRED_HOTFIX_NOT_INSTALLED { get { - return ResourceManager.GetString("REQUIRED_HOTFIX_ISNOT_INSTALLED", resourceCulture); + return ResourceManager.GetString("REQUIRED_HOTFIX_NOT_INSTALLED", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {0}: Check skipped because the required hotfix is not installed. + /// + public static string REQUIRED_HOTFIX_NOT_INSTALLED_WARNING { + get { + return ResourceManager.GetString("REQUIRED_HOTFIX_NOT_INSTALLED_WARNING", resourceCulture); } } diff --git a/XenModel/Messages.resx b/XenModel/Messages.resx index 7f421b88d..820a62ed8 100755 --- a/XenModel/Messages.resx +++ b/XenModel/Messages.resx @@ -11061,9 +11061,12 @@ Click Server Status Report to open the Compile Server Status Report Wizard or cl Repeated key - + {0}: The required hotfix is not installed + + {0}: Check skipped because the required hotfix is not installed + Required Updates From 8f79c7cf13fe0246d60bf876900b19cfc868bf06 Mon Sep 17 00:00:00 2001 From: Konstantina Chremmou Date: Tue, 31 Mar 2020 00:00:57 +0100 Subject: [PATCH 09/10] CA-336986: Handle server side update precheck for vSwitchController. Also, renamed a couple of parameters because the old name was specific to one error. Signed-off-by: Konstantina Chremmou --- .../Diagnostics/Checks/PatchPrecheckCheck.cs | 73 ++++++++++--------- 1 file changed, 40 insertions(+), 33 deletions(-) diff --git a/XenAdmin/Diagnostics/Checks/PatchPrecheckCheck.cs b/XenAdmin/Diagnostics/Checks/PatchPrecheckCheck.cs index 6c77e911e..a2454adfe 100644 --- a/XenAdmin/Diagnostics/Checks/PatchPrecheckCheck.cs +++ b/XenAdmin/Diagnostics/Checks/PatchPrecheckCheck.cs @@ -40,6 +40,7 @@ using System.Text.RegularExpressions; using System.Xml; using System.Collections.Generic; using XenAdmin.Actions; +using XenAdmin.Diagnostics.Problems.PoolProblem; namespace XenAdmin.Diagnostics.Checks { @@ -99,8 +100,6 @@ namespace XenAdmin.Diagnostics.Checks Session session = Host.Connection.DuplicateSession(); - - try { if (Patch != null) @@ -140,10 +139,7 @@ namespace XenAdmin.Diagnostics.Checks } } - public override string Description - { - get { return Messages.SERVER_SIDE_CHECK_DESCRIPTION; } - } + public override string Description => Messages.SERVER_SIDE_CHECK_DESCRIPTION; /// /// Find problem from xml result @@ -185,7 +181,7 @@ namespace XenAdmin.Diagnostics.Checks else if (node.Name == "required") required = node.InnerXml; } - var problem = FindProblem(errorcode, found, required); + var problem = FindProblem(errorcode, "", found, required); return problem ?? new PrecheckFailed(this, Host, new Failure(errorcode)); } @@ -193,14 +189,25 @@ namespace XenAdmin.Diagnostics.Checks /// Find problem from xapi Failure /// /// Xapi failure, thrown by Pool_patch.precheck() call. - /// E.g.: failure.ErrorDescription.Count = 4 + /// E.g.: failure.ErrorDescription.Count = 4 /// ErrorDescription[0] = "PATCH_PRECHECK_FAILED_WRONG_SERVER_VERSION" /// ErrorDescription[1] = "OpaqueRef:612b5eee-03dc-bbf5-3385-6905fdc9b079" /// ErrorDescription[2] = "6.5.0" /// ErrorDescription[3] = "^6\\.2\\.0$" - /// E.g.: failure.ErrorDescription.Count = 2 + /// + /// E.g.: failure.ErrorDescription.Count = 2 /// ErrorDescription[0] = "OUT_OF_SPACE" /// ErrorDescription[1] = "/var/patch" + /// + /// E.g.: failure.ErrorDescription.Count = 3 with the last parameter being an xml string + /// ErrorDescription[0] = "UPDATE_PRECHECK_FAILED_UNKNOWN_ERROR" + /// ErrorDescription[1] = "test-update" + /// ErrorDescription[2] = "" + /// + /// E.g.: failure.ErrorDescription.Count = 3 with the last parameter being a plain string + /// ErrorDescription[0] = "UPDATE_PRECHECK_FAILED_UNKNOWN_ERROR" + /// ErrorDescription[1] = "CH82" + /// ErrorDescription[2] = "VSWITCH_CONTROLLER_CONNECTED\nYou must [...] this update\n" /// /// Problem or null, if no problem found private Problem FindProblem(Failure failure) @@ -209,21 +216,17 @@ namespace XenAdmin.Diagnostics.Checks return null; var errorcode = failure.ErrorDescription[0]; - var found = ""; - var required = ""; + var param1 = failure.ErrorDescription.Count > 1 ? failure.ErrorDescription[1] : ""; + var param2 = failure.ErrorDescription.Count > 2 ? failure.ErrorDescription[2] : ""; + var param3 = failure.ErrorDescription.Count > 3 ? failure.ErrorDescription[3] : ""; - if (failure.ErrorDescription.Count > 2) - found = failure.ErrorDescription[2]; - if (failure.ErrorDescription.Count > 3) - required = failure.ErrorDescription[3]; - - return FindProblem(errorcode, found, required); + return FindProblem(errorcode, param1, param2, param3); } - private Problem FindProblem(string errorcode, string found, string required) + private Problem FindProblem(string errorcode, string param1, string param2, string param3) { - long requiredSpace = 0; - long foundSpace = 0; + long requiredSpace; + long foundSpace; long reclaimableDiskSpace = 0; DiskSpaceRequirements diskSpaceReq; @@ -234,19 +237,19 @@ namespace XenAdmin.Diagnostics.Checks return new WrongServerVersion(this, Host); case "UPDATE_PRECHECK_FAILED_CONFLICT_PRESENT": - return new ConflictingUpdatePresent(this, found, Host); + return new ConflictingUpdatePresent(this, param2, Host); case "UPDATE_PRECHECK_FAILED_PREREQUISITE_MISSING": - return new PrerequisiteUpdateMissing(this, found, Host); + return new PrerequisiteUpdateMissing(this, param2, Host); case "PATCH_PRECHECK_FAILED_WRONG_SERVER_VERSION": - return new WrongServerVersion(this, required, Host); + return new WrongServerVersion(this, param3, Host); case "PATCH_PRECHECK_FAILED_OUT_OF_SPACE": System.Diagnostics.Trace.Assert(!Helpers.ElyOrGreater(Host.Connection)); // If Ely or greater, we shouldn't get this error - long.TryParse(found, out foundSpace); - long.TryParse(required, out requiredSpace); + long.TryParse(param2, out foundSpace); + long.TryParse(param3, out requiredSpace); // get reclaimable disk space (excluding current patch) try { @@ -265,8 +268,9 @@ namespace XenAdmin.Diagnostics.Checks case "UPDATE_PRECHECK_FAILED_OUT_OF_SPACE": System.Diagnostics.Trace.Assert(Helpers.ElyOrGreater(Host.Connection)); // If not Ely or greater, we shouldn't get this error - long.TryParse(found, out foundSpace); - long.TryParse(required, out requiredSpace); + + long.TryParse(param2, out foundSpace); + long.TryParse(param3, out requiredSpace); diskSpaceReq = new DiskSpaceRequirements(DiskSpaceRequirements.OperationTypes.install, Host, Update.Name(), requiredSpace, foundSpace, 0); @@ -295,12 +299,15 @@ namespace XenAdmin.Diagnostics.Checks case "LICENCE_RESTRICTION": return new LicenseRestrictionProblem(this, Host); case "UPDATE_PRECHECK_FAILED_UNKNOWN_ERROR": - // try to find the problem from the error parameters as xml string - // e.g. - // ErrorDescription[0] = "UPDATE_PRECHECK_FAILED_UNKNOWN_ERROR" - // ErrorDescription[1] = "test-update" - // ErrorDescription[2] = "" - return FindProblem(found); + if (param1 == "CH82" && param2.StartsWith("VSWITCH_CONTROLLER_CONNECTED")) + { + var pool = Helpers.GetPoolOfOne(Host.Connection); + if (pool.vSwitchController()) + return new VSwitchControllerProblem(this, pool); + return null; + } + else + return FindProblem(param2); } return null; } From 00e015f2d0f1df0b6ddb858d606289f2e7acd00c Mon Sep 17 00:00:00 2001 From: Konstantina Chremmou Date: Wed, 1 Apr 2020 15:18:26 +0100 Subject: [PATCH 10/10] Run vSwitch Controller and PV Guest checks only if strictly necessary. Signed-off-by: Konstantina Chremmou --- XenAdmin/Diagnostics/Checks/Check.cs | 19 +++++++++++---- XenAdmin/Diagnostics/Checks/PVGuestsCheck.cs | 23 ++++++++++++++----- .../Checks/VSwitchControllerCheck.cs | 17 +++++++++++--- .../PatchingWizard_PrecheckPage.cs | 21 ++++++++--------- .../RollingUpgradeWizardPrecheckPage.cs | 21 +++++++++-------- 5 files changed, 67 insertions(+), 34 deletions(-) diff --git a/XenAdmin/Diagnostics/Checks/Check.cs b/XenAdmin/Diagnostics/Checks/Check.cs index a87283daf..5afa3aea9 100644 --- a/XenAdmin/Diagnostics/Checks/Check.cs +++ b/XenAdmin/Diagnostics/Checks/Check.cs @@ -43,10 +43,16 @@ namespace XenAdmin.Diagnostics.Checks // Check can override this to return multiple Problems public virtual List RunAllChecks() { - var list = new List(1); - var problem = RunCheck(); - if (problem != null) - list.Add(problem); + var list = new List(); + + //normally checks will have not been added to the list if they can't run, but check again + if (CanRun()) + { + var problem = RunCheck(); + if (problem != null) + list.Add(problem); + } + return list; } @@ -62,5 +68,10 @@ namespace XenAdmin.Diagnostics.Checks : string.Format(Messages.PATCHING_WIZARD_CHECK_OK, Description); } } + + public virtual bool CanRun() + { + return true; + } } } diff --git a/XenAdmin/Diagnostics/Checks/PVGuestsCheck.cs b/XenAdmin/Diagnostics/Checks/PVGuestsCheck.cs index 48f0e9914..3fb3cc98b 100644 --- a/XenAdmin/Diagnostics/Checks/PVGuestsCheck.cs +++ b/XenAdmin/Diagnostics/Checks/PVGuestsCheck.cs @@ -48,20 +48,31 @@ namespace XenAdmin.Diagnostics.Checks private readonly bool _manualUpgrade; private readonly Dictionary _installMethodConfig; - public PVGuestsCheck(Pool pool, bool upgrade, bool manualUpgrade = false, Dictionary installMethodConfig = null) - : base(Helpers.GetMaster(pool.Connection)) + public PVGuestsCheck(Host master, bool upgrade, bool manualUpgrade = false, Dictionary installMethodConfig = null) + : base(master) { - _pool = pool; + _pool = Helpers.GetPoolOfOne(Host?.Connection); _upgrade = upgrade; _manualUpgrade = manualUpgrade; _installMethodConfig = installMethodConfig; } + public override bool CanRun() + { + if (Helpers.QuebecOrGreater(Host)) + return false; + + if (_pool == null || !_pool.Connection.Cache.VMs.Any(vm => vm.IsPvVm())) + return false; + + if (!_upgrade && !Helpers.NaplesOrGreater(Host)) + return false; + + return true; + } + protected override Problem RunHostCheck() { - if (!_pool.Connection.Cache.VMs.Any(vm => vm.IsPvVm())) - return null; - //update case if (!_upgrade) return new PoolHasPVGuestWarningUrl(this, _pool); diff --git a/XenAdmin/Diagnostics/Checks/VSwitchControllerCheck.cs b/XenAdmin/Diagnostics/Checks/VSwitchControllerCheck.cs index 7ae522bff..a0b1e62e9 100644 --- a/XenAdmin/Diagnostics/Checks/VSwitchControllerCheck.cs +++ b/XenAdmin/Diagnostics/Checks/VSwitchControllerCheck.cs @@ -64,11 +64,22 @@ namespace XenAdmin.Diagnostics.Checks public override string Description => Messages.CHECKING_VSWITCH_CONTROLLER; + public override bool CanRun() + { + if (Helpers.StockholmOrGreater(Host)) + return false; + + if (_pool == null || !_pool.vSwitchController()) + return false; + + if (_newVersion != null && !Helpers.NaplesOrGreater(Host)) + return false; + + return true; + } + protected override Problem RunHostCheck() { - if (!_pool.vSwitchController() || Helpers.StockholmOrGreater(Host)) - return null; - //update case if (_newVersion != null) { diff --git a/XenAdmin/Wizards/PatchingWizard/PatchingWizard_PrecheckPage.cs b/XenAdmin/Wizards/PatchingWizard/PatchingWizard_PrecheckPage.cs index dd65478cf..e405c97bf 100644 --- a/XenAdmin/Wizards/PatchingWizard/PatchingWizard_PrecheckPage.cs +++ b/XenAdmin/Wizards/PatchingWizard/PatchingWizard_PrecheckPage.cs @@ -359,11 +359,10 @@ namespace XenAdmin.Wizards.PatchingWizard if (WizardMode == WizardMode.NewVersion) { //vSwitch controller check - for each pool - var vSwitchChecks = (from Pool pool in SelectedPools.Where( - p => Helpers.NaplesOrGreater(p.Connection) && !Helpers.StockholmOrGreater(p.Connection)) - let master = pool.Connection.Resolve(pool.master) - where master != null - select new VSwitchControllerCheck(master, UpdateAlert?.NewServerVersion) as Check).ToList(); + var vSwitchChecks = (from Pool pool in SelectedPools + let check = new VSwitchControllerCheck(pool.Connection.Resolve(pool.master), UpdateAlert?.NewServerVersion) + where check.CanRun() + select check as Check).ToList(); if (vSwitchChecks.Count > 0) groups.Add(new CheckGroup(Messages.CHECKING_VSWITCH_CONTROLLER_GROUP, vSwitchChecks)); @@ -506,12 +505,12 @@ namespace XenAdmin.Wizards.PatchingWizard if (highestNewVersion != null || UpdateAlert?.NewServerVersion != null) { //PVGuestsCheck checks - var pvChecks = new List(); - foreach (var pool in SelectedPools.Where(p => Helpers.NaplesOrGreater(p.Connection))) - { - if (pool.Connection.Resolve(pool.master) != null) - pvChecks.Add(new PVGuestsCheck(pool, false)); - } + var pvChecks = (from Pool pool in SelectedPools + let check = new PVGuestsCheck(pool.Connection.Resolve(pool.master), false) + where check.CanRun() + select check as Check).ToList(); + + if (pvChecks.Count > 0) groups.Add(new CheckGroup(Messages.CHECKING_PV_GUESTS, pvChecks)); } diff --git a/XenAdmin/Wizards/RollingUpgradeWizard/RollingUpgradeWizardPrecheckPage.cs b/XenAdmin/Wizards/RollingUpgradeWizard/RollingUpgradeWizardPrecheckPage.cs index aece209ec..411620fd6 100644 --- a/XenAdmin/Wizards/RollingUpgradeWizard/RollingUpgradeWizardPrecheckPage.cs +++ b/XenAdmin/Wizards/RollingUpgradeWizard/RollingUpgradeWizardPrecheckPage.cs @@ -200,11 +200,13 @@ namespace XenAdmin.Wizards.RollingUpgradeWizard } //vSwitch controller check - for each pool - var vswitchChecks = (from Host server in SelectedMasters.Where(m => !Helpers.StockholmOrGreater(m)) - select new VSwitchControllerCheck(server, InstallMethodConfig, ManualUpgrade) as Check).ToList(); + var vSwitchChecks = (from Host server in SelectedMasters + let check = new VSwitchControllerCheck(server, InstallMethodConfig, ManualUpgrade) + where check.CanRun() + select check as Check).ToList(); - if (vswitchChecks.Count > 0) - groups.Add(new CheckGroup(Messages.CHECKING_VSWITCH_CONTROLLER_GROUP, vswitchChecks)); + if (vSwitchChecks.Count > 0) + groups.Add(new CheckGroup(Messages.CHECKING_VSWITCH_CONTROLLER_GROUP, vSwitchChecks)); //HA checks - for each pool var haChecks = (from Host server in SelectedMasters @@ -246,12 +248,11 @@ namespace XenAdmin.Wizards.RollingUpgradeWizard } //Checking PV guests - for hosts that have any PV guests and warn the user before the upgrade. - var pvChecks = new List(); - foreach (Pool pool in SelectedPools.Where(p => !Helpers.QuebecOrGreater(p.Connection))) - { - if (pool.Connection.Resolve(pool.master) != null) - pvChecks.Add(new PVGuestsCheck(pool, true, ManualUpgrade, InstallMethodConfig)); - } + var pvChecks = (from Host server in SelectedMasters + let check = new PVGuestsCheck(server, true, ManualUpgrade, InstallMethodConfig) + where check.CanRun() + select check as Check).ToList(); + if (pvChecks.Count > 0) groups.Add(new CheckGroup(Messages.CHECKING_PV_GUESTS, pvChecks));