From 84e514fd0f2d8a0aaf825a49ab16b52fc4d74448 Mon Sep 17 00:00:00 2001 From: Bengang Yuan Date: Wed, 22 Nov 2023 16:23:16 +0800 Subject: [PATCH] IH-414: Resolve PR review comments from Tina --- .../ConversionWizard/VmSelectionPage.cs | 119 +++++++++++++----- .../ConversionWizard/VmSelectionPage.resx | 33 ++--- XenModel/InvisibleMessages.Designer.cs | 18 +++ XenModel/InvisibleMessages.resx | 6 + XenModel/Messages.Designer.cs | 36 ------ XenModel/Messages.resx | 12 -- XenModel/XCM/ConversionClient.cs | 3 +- 7 files changed, 123 insertions(+), 104 deletions(-) diff --git a/XenAdmin/Wizards/ConversionWizard/VmSelectionPage.cs b/XenAdmin/Wizards/ConversionWizard/VmSelectionPage.cs index 2ce73a3224..4319b4bbd2 100644 --- a/XenAdmin/Wizards/ConversionWizard/VmSelectionPage.cs +++ b/XenAdmin/Wizards/ConversionWizard/VmSelectionPage.cs @@ -33,6 +33,7 @@ using System.Linq; using System.Windows.Forms; using XenAdmin.Controls; +using XenAdmin.Core; using XenAdmin.XCM; @@ -44,13 +45,13 @@ public partial class VmSelectionPage : XenTabPage private bool _buttonNextEnabled; private bool _updating; - private string _currentConversionVersion; + private string _currentXSVersion; + private bool _supportVersionChecking; public VmSelectionPage() { InitializeComponent(); - tableLayoutPanelError.Visible = false; } #region XenTabPage implementation @@ -68,7 +69,21 @@ public override bool EnableNext() protected override void PageLoadedCore(PageLoadedDirection direction) { - _currentConversionVersion = ConversionClient.GetVpxVersion(); + tableLayoutPanelError.Visible = false; + _supportVersionChecking = IsSupportGuestVersionChecking(); + if (_supportVersionChecking) + { + tableLayoutPanelVersion.Visible = true; + columnRemarks.Visible = true; + showOnlySupportedGuestCheckBox.Checked = true; + } + else + { + tableLayoutPanelVersion.Visible = false; + columnRemarks.Visible = false; + showOnlySupportedGuestCheckBox.Checked = false; + } + _currentXSVersion = Helpers.HostProductVersion(Helpers.GetCoordinator(Connection)); if (direction == PageLoadedDirection.Forward) Build(); } @@ -89,7 +104,7 @@ public VmInstance[] SelectedVms get { return (from SourceVmRow row in dataGridViewVms.Rows - where row.IsChecked + where row.IsChecked && row.Visible select row.Vm).ToArray(); } } @@ -100,7 +115,7 @@ private bool SelectedVmsExist { foreach (SourceVmRow row in dataGridViewVms.Rows) { - if (row.IsChecked) + if (row.Visible && row.IsChecked) return true; } @@ -109,24 +124,17 @@ private bool SelectedVmsExist } // The feature of unsupported guest version warning is available on 8.3.1 - private Version LowestGuestCheckingConversionVersion => new Version("8.3.1"); + private bool IsSupportGuestVersionChecking() + { + string currentConversionVersion = ConversionClient.GetVpxVersion(); + return Version.TryParse(currentConversionVersion, out Version result) + && result.CompareTo(new Version("8.3.1")) >= 0; + } private void Build() { try { - if (Version.TryParse(_currentConversionVersion, out Version result) && - result.CompareTo(LowestGuestCheckingConversionVersion) >= 0) - { - tableLayoutPanelVersion.Visible = true; - columnRemarks.Visible = true; - } - else - { - tableLayoutPanelVersion.Visible = false; - columnRemarks.Visible = false; - } - dataGridViewVms.SuspendLayout(); dataGridViewVms.Rows.Clear(); @@ -140,12 +148,10 @@ private void Build() continue; } - bool supported = IsSupportedGuest(vm); - if (showOnlySupportedGuestCheckBox.Checked && !supported) - { - continue; - } - dataGridViewVms.Rows.Add(new SourceVmRow(vm, supported)); + bool supported = !_supportVersionChecking || IsSupportedGuest(vm); + SourceVmRow row = new SourceVmRow(vm, supported); + dataGridViewVms.Rows.Add(row); + row.Visible = !showOnlySupportedGuestCheckBox.Checked || supported; } } finally @@ -158,6 +164,7 @@ private void Build() private void UpdateButtons() { _buttonNextEnabled = SelectedVmsExist; + UpdateSelectAllAndClearAllButton(); OnPageUpdated(); } @@ -174,17 +181,40 @@ private void BulkCheck(bool check) finally { _updating = false; - SupportedVersionCheck(); + CheckIfExistUnsupportedVersion(); UpdateButtons(); } } - private void SupportedVersionCheck() + private void UpdateSelectAllAndClearAllButton() { - tableLayoutPanelError.Visible = false; + int total = 0; + int check = 0; foreach (SourceVmRow row in dataGridViewVms.Rows) { - if (row.IsChecked && !row.IsSupportedGuest()) + if (row.Visible) + { + total++; + if (row.IsChecked) + { + check++; + } + } + } + + buttonSelectAll.Enabled = total != check; + buttonClearAll.Enabled = check != 0; + } + + private void CheckIfExistUnsupportedVersion() + { + if (!_supportVersionChecking) + { + return; + } + foreach (SourceVmRow row in dataGridViewVms.Rows) + { + if (row.Visible && row.IsChecked && !row.IsSupportedGuest()) { pictureBoxError.Image = Images.StaticImages._000_Alert2_h32bit_16; labelError.Text = Messages.CONVERSION_UNSUPPORTED_VM_SELECTED_WARNING; @@ -192,6 +222,7 @@ private void SupportedVersionCheck() return; } } + tableLayoutPanelError.Visible = false; } private void UpdateComponentEnabledStatusWhenRefresh(bool enabled) @@ -210,7 +241,7 @@ private bool IsSupportedGuest(VmInstance vm) } foreach (string supportedVersion in vm.SupportedXSVersions) { - if (_currentConversionVersion.StartsWith(supportedVersion)) + if (_currentXSVersion.StartsWith(supportedVersion)) { return true; } @@ -291,24 +322,44 @@ private void dataGridViewVms_CellValueChanged(object sender, DataGridViewCellEve if (e.ColumnIndex != 0 || e.RowIndex < 0 || e.RowIndex >= dataGridViewVms.RowCount) return; - SupportedVersionCheck(); + CheckIfExistUnsupportedVersion(); UpdateButtons(); } private void showOnlySupportedGuestCheckBox_CheckedChanged(object sender, EventArgs e) { - RefreshData(); + bool existCheckedUnsupportedGuest = false; + foreach (SourceVmRow row in dataGridViewVms.Rows) + { + if (!row.IsSupportedGuest()) + { + row.Visible = !showOnlySupportedGuestCheckBox.Checked; + existCheckedUnsupportedGuest = row.IsChecked; + } + } + if (!showOnlySupportedGuestCheckBox.Checked && existCheckedUnsupportedGuest) + { + pictureBoxError.Image = Images.StaticImages._000_Alert2_h32bit_16; + labelError.Text = Messages.CONVERSION_UNSUPPORTED_VM_SELECTED_WARNING; + tableLayoutPanelError.Visible = true; + } + else + { + tableLayoutPanelError.Visible = false; + } + + UpdateButtons(); } private void supportedOSLinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { - if (_currentConversionVersion.StartsWith("8.2")) + if (_currentXSVersion.StartsWith("8.2")) { - System.Diagnostics.Process.Start(Messages.CONVERSION_DOC_PATH_82); + System.Diagnostics.Process.Start(InvisibleMessages.CONVERSION_DOC_PATH_82); } else { - System.Diagnostics.Process.Start(Messages.CONVERSION_DOC_PATH_LATEST); + System.Diagnostics.Process.Start(InvisibleMessages.CONVERSION_DOC_PATH_LATEST); } } diff --git a/XenAdmin/Wizards/ConversionWizard/VmSelectionPage.resx b/XenAdmin/Wizards/ConversionWizard/VmSelectionPage.resx index 3fc5aacade..82470370cc 100644 --- a/XenAdmin/Wizards/ConversionWizard/VmSelectionPage.resx +++ b/XenAdmin/Wizards/ConversionWizard/VmSelectionPage.resx @@ -212,7 +212,7 @@ Note that only VMs that are currently shut down are listed here. 518, 268 - 3 + 1 dataGridViewVms @@ -242,7 +242,7 @@ Note that only VMs that are currently shut down are listed here. 75, 23 - 0 + 2 &Select All @@ -266,7 +266,7 @@ Note that only VMs that are currently shut down are listed here. 75, 23 - 1 + 3 &Clear All @@ -290,7 +290,7 @@ Note that only VMs that are currently shut down are listed here. 75, 23 - 2 + 4 &Refresh @@ -350,29 +350,23 @@ Note that only VMs that are currently shut down are listed here. 2 - Top, Bottom, Left + Left True - 280, 0 - - - 0, 0, 3, 3 + 286, 5 - 103, 20 + 103, 13 - 1 + 6 Supported guest OS - - MiddleLeft - supportedOSLinkLabel @@ -386,7 +380,7 @@ Note that only VMs that are currently shut down are listed here. 0 - Top, Bottom, Left + Left True @@ -394,17 +388,14 @@ Note that only VMs that are currently shut down are listed here. 3, 3 - - 3, 3, 0, 3 - 277, 17 - 2 + 5 - Show only guest OS supported in the current version. + Show only guest &OS supported in the current version. showOnlySupportedGuestCheckBox @@ -575,7 +566,7 @@ Note that only VMs that are currently shut down are listed here. 0 - <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="label1" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="dataGridViewVms" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="tableLayoutPanel3" Row="2" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="versionTableLayoutPanel" Row="3" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="tableLayoutPanelError" Row="4" RowSpan="1" Column="0" ColumnSpan="1" /></Controls><Columns Styles="Percent,100" /><Rows Styles="AutoSize,0,Percent,100,AutoSize,0,AutoSize,0,Absolute,30" /></TableLayoutSettings> + <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="labelDesc" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="dataGridViewVms" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="tableLayoutPanelButtons" Row="2" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="tableLayoutPanelVersion" Row="3" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="tableLayoutPanelError" Row="4" RowSpan="1" Column="0" ColumnSpan="1" /></Controls><Columns Styles="Percent,100" /><Rows Styles="AutoSize,0,Percent,100,AutoSize,0,AutoSize,0,Absolute,30" /></TableLayoutSettings> 17, 17 diff --git a/XenModel/InvisibleMessages.Designer.cs b/XenModel/InvisibleMessages.Designer.cs index 89188031cb..c2fa5edeb6 100644 --- a/XenModel/InvisibleMessages.Designer.cs +++ b/XenModel/InvisibleMessages.Designer.cs @@ -78,6 +78,24 @@ public static string CLIENT_ID_URL { } } + /// + /// Looks up a localized string similar to https://docs.xenserver.com/en-us/xencenter/8-2/conversion-manager.html#citrix-hypervisor-environment-considerations. + /// + public static string CONVERSION_DOC_PATH_82 { + get { + return ResourceManager.GetString("CONVERSION_DOC_PATH_82", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to https://docs.xenserver.com/en-us/xencenter/current-release/conversion-manager.html#xenserver-environment-considerations. + /// + public static string CONVERSION_DOC_PATH_LATEST { + get { + return ResourceManager.GetString("CONVERSION_DOC_PATH_LATEST", resourceCulture); + } + } + /// /// Looks up a localized string similar to https://www.citrix.com/support/programs/. /// diff --git a/XenModel/InvisibleMessages.resx b/XenModel/InvisibleMessages.resx index 7c1bdf9f2a..c15a0264c0 100644 --- a/XenModel/InvisibleMessages.resx +++ b/XenModel/InvisibleMessages.resx @@ -123,6 +123,12 @@ https://support.citrix.com/xencenterclientiddownload + + https://docs.xenserver.com/en-us/xencenter/8-2/conversion-manager.html#citrix-hypervisor-environment-considerations + + + https://docs.xenserver.com/en-us/xencenter/current-release/conversion-manager.html#xenserver-environment-considerations + https://www.citrix.com/support/programs/ diff --git a/XenModel/Messages.Designer.cs b/XenModel/Messages.Designer.cs index 294646a30a..43a4a601c8 100755 --- a/XenModel/Messages.Designer.cs +++ b/XenModel/Messages.Designer.cs @@ -10178,24 +10178,6 @@ public static string CONVERSION_DETAIL_TARGET_SR { } } - /// - /// Looks up a localized string similar to https://docs.xenserver.com/en-us/xencenter/8-2/conversion-manager.html#prepare-your-environment. - /// - public static string CONVERSION_DOC_PATH_82 { - get { - return ResourceManager.GetString("CONVERSION_DOC_PATH_82", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to https://docs.xenserver.com/en-us/xencenter/current-release/conversion-manager.html. - /// - public static string CONVERSION_DOC_PATH_LATEST { - get { - return ResourceManager.GetString("CONVERSION_DOC_PATH_LATEST", resourceCulture); - } - } - /// /// Looks up a localized string similar to Export conversions to {0}. /// @@ -10378,15 +10360,6 @@ public static string CONVERSION_SELECT_VPX_TITLE { } } - /// - /// Looks up a localized string similar to Show only guest OS supported in the current version.. - /// - public static string CONVERSION_SHOW_ONLY_SUPPORTED_GUEST { - get { - return ResourceManager.GetString("CONVERSION_SHOW_ONLY_SUPPORTED_GUEST", resourceCulture); - } - } - /// /// Looks up a localized string similar to Canceled. /// @@ -10693,15 +10666,6 @@ public static string CONVERSION_VM_PAGE_TITLE { } } - /// - /// Looks up a localized string similar to The guest OS version may not be supported, please check the supported OS list and try again.. - /// - public static string CONVERSION_VM_SELECT_WARNING_UNSUPPORTED_VERSION { - get { - return ResourceManager.GetString("CONVERSION_VM_SELECT_WARNING_UNSUPPORTED_VERSION", resourceCulture); - } - } - /// /// Looks up a localized string similar to Obtaining an IP address for the Conversion Manager virtual appliance.... /// diff --git a/XenModel/Messages.resx b/XenModel/Messages.resx index 6558795f91..627ff8e1c5 100755 --- a/XenModel/Messages.resx +++ b/XenModel/Messages.resx @@ -3659,12 +3659,6 @@ This action cannot be undone. Are you sure you want to continue? Target SR - - https://docs.xenserver.com/en-us/xencenter/8-2/conversion-manager.html#prepare-your-environment - - - https://docs.xenserver.com/en-us/xencenter/current-release/conversion-manager.html - Export conversions to {0} @@ -3727,9 +3721,6 @@ This action cannot be undone. Are you sure you want to continue? Select Conversion Manager Virtual Appliance - {0} - - Show only guest OS supported in the current version. - Canceled @@ -3832,9 +3823,6 @@ This action cannot be undone. Are you sure you want to continue? Select the VMs to convert - - The guest OS version may not be supported, please check the supported OS list and try again. - Obtaining an IP address for the Conversion Manager virtual appliance... diff --git a/XenModel/XCM/ConversionClient.cs b/XenModel/XCM/ConversionClient.cs index d7bbf93c29..6f8b55e3e6 100644 --- a/XenModel/XCM/ConversionClient.cs +++ b/XenModel/XCM/ConversionClient.cs @@ -40,6 +40,7 @@ public class ConversionClient { private readonly IConversionProxy _conversionProxy; private readonly NetworkCredential _credential; + private string _vpxVersion; public ConversionClient(IXenConnection connection, string vpxIp, bool useSsl) { @@ -63,7 +64,7 @@ public ConversionClient(IXenConnection connection, string vpxIp, bool useSsl) public string GetVpxVersion() { - return _conversionProxy.GetVpxVersion(); + return _vpxVersion ?? (_vpxVersion = _conversionProxy.GetVpxVersion()); } public VmInstance[] GetSourceVMs(ServerInfo vmWareServer)