From 5093ef677c24ae906c17f5184806914a08e05510 Mon Sep 17 00:00:00 2001 From: Stephen Turner Date: Thu, 25 Feb 2016 17:18:48 +0000 Subject: [PATCH] CA-201421: tools ISO is missing in drop-down list --- XenAdmin/Controls/ComboBoxes/ISODropDownBox.cs | 3 +-- XenModel/Actions/VM/InstallPVToolsAction.cs | 10 +--------- XenModel/XenAPI-Extensions/VDI.cs | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/XenAdmin/Controls/ComboBoxes/ISODropDownBox.cs b/XenAdmin/Controls/ComboBoxes/ISODropDownBox.cs index 9c7188fe0..d6f72e007 100644 --- a/XenAdmin/Controls/ComboBoxes/ISODropDownBox.cs +++ b/XenAdmin/Controls/ComboBoxes/ISODropDownBox.cs @@ -257,8 +257,7 @@ namespace XenAdmin.Controls { foreach (VDI vdi in connection.ResolveAll(srWrapper.item.VDIs)) { - if(Actions.InstallPVToolsAction.ISONameOld.Equals(vdi.name_label) || - Actions.InstallPVToolsAction.ISONameNew.Equals(vdi.name_label)) + if (vdi.IsToolsIso) items.Add(new ToStringWrapper(vdi, " " + vdi.Name)); } } diff --git a/XenModel/Actions/VM/InstallPVToolsAction.cs b/XenModel/Actions/VM/InstallPVToolsAction.cs index 18ccefdd7..96f489fca 100644 --- a/XenModel/Actions/VM/InstallPVToolsAction.cs +++ b/XenModel/Actions/VM/InstallPVToolsAction.cs @@ -44,10 +44,6 @@ namespace XenAdmin.Actions private readonly Action _xsToolsNotFound; private readonly bool _searchHiddenIsOs; - // The 'well known' name of the ISO containing our PV tools. - public const string ISONameOld = "xswindrivers.iso"; - public const string ISONameNew = "xs-tools.iso"; - public InstallPVToolsAction(VM vm, Action xsToolsNotfound, bool searchHiddenISOs) : base(vm.Connection, string.Format(Messages.INSTALLTOOLS_TITLE, vm.Name)) { @@ -140,12 +136,8 @@ namespace XenAdmin.Actions { foreach (VDI vdi in Connection.ResolveAllShownXenModelObjects(sr.VDIs, searchHiddenISOs)) { - if (ISONameOld.Equals(vdi.name_label) || - ISONameNew.Equals(vdi.name_label) || - vdi.is_tools_iso) - { + if (vdi.IsToolsIso) return vdi; - } } } } diff --git a/XenModel/XenAPI-Extensions/VDI.cs b/XenModel/XenAPI-Extensions/VDI.cs index 8ed723b49..b3e63559b 100644 --- a/XenModel/XenAPI-Extensions/VDI.cs +++ b/XenModel/XenAPI-Extensions/VDI.cs @@ -300,6 +300,24 @@ namespace XenAPI get { return other_config.ContainsKey("config-drive") && other_config["config-drive"].ToLower() == "true"; } } + + /// + /// Whether this is a Tools ISO. Finds the old method (by name) as well as + /// the new method (field on the VDI). + /// + public bool IsToolsIso + { + get + { + const string ISONameOld = "xswindrivers.iso"; + const string ISONameNew = "xs-tools.iso"; + + return + is_tools_iso || + ISONameOld.Equals(name_label) || + ISONameNew.Equals(name_label); + } + } /// /// Whether read caching is enabled on this disk on a specific host