diff --git a/CFUValidator/CFUValidator.cs b/CFUValidator/CFUValidator.cs deleted file mode 100644 index 94bc434a4f..0000000000 --- a/CFUValidator/CFUValidator.cs +++ /dev/null @@ -1,207 +0,0 @@ -/* Copyright (c) Cloud Software Group, Inc. - * - * 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.Linq; -using System.Collections.Generic; -using System.Text; -using CFUValidator.CommandLineOptions; -using CFUValidator.OutputDecorators; -using CFUValidator.Updates; -using CFUValidator.Validators; -using Moq; -using XenAdmin; -using XenAdmin.Core; -using XenAdminTests; -using XenAPI; - - -namespace CFUValidator -{ - public class CFUValidationException : Exception - { - public CFUValidationException(string message) : base(message){} - } - - public class CFUValidator - { - private readonly MockObjectManager mom = new MockObjectManager(); - private readonly XmlRetrieverFactory xmlFactory = new XmlRetrieverFactory(); - private const string id = "id"; - private readonly string _xmlLocation; - private readonly string _serverVersion; - private readonly OptionUsage UrlOrFile; - private readonly List _installedHotfixes; - private readonly bool _checkHotfixContents; - private readonly IConfigProvider _configProvider; - - public CFUValidator(OptionUsage urlOrFile, string xmlLocation, string serverVersion, - List installedHotfixes, bool checkHotfixContents, IConfigProvider configProvider) - { - if (urlOrFile != OptionUsage.File && urlOrFile != OptionUsage.Url) - throw new ArgumentException("urlOrFile option should be either File or Url"); - - mom.CreateNewConnection(id); - ConnectionsManager.XenConnections.AddRange(mom.AllConnections); - _xmlLocation = xmlLocation; - _serverVersion = serverVersion; - _installedHotfixes = installedHotfixes; - UrlOrFile = urlOrFile; - _checkHotfixContents = checkHotfixContents; - _configProvider = configProvider; - } - - public void Validate(Action statusReporter) - { - statusReporter($"Getting check for updates XML from {_xmlLocation}..."); - ReadCheckForUpdatesXML(out var xenServerPatches, out var xenServerVersions); - - List versionsToCheck; - if (_serverVersion == CFUCommandLineOptionManager.AllVersions) - { - versionsToCheck = xenServerVersions.ConvertAll(i => i.Version.ToString()).Distinct().ToList(); - } - else - { - CheckVersionExistsInCfu(_serverVersion, xenServerVersions); - versionsToCheck = new List {_serverVersion}; - } - - var summaryGenerators = new List(); - foreach (string ver in versionsToCheck) - summaryGenerators.AddRange(RunTestsForGivenServerVersion(ver, xenServerVersions, xenServerPatches, statusReporter)); - - summaryGenerators.ForEach(s => statusReporter(s.GenerateSummary())); - } - - private List RunTestsForGivenServerVersion(string serverVersion, List xenServerVersions, - List xenServerPatches, Action statusReporter) - { - statusReporter($"Generating server {serverVersion} mock-ups..."); - SetupMocks(serverVersion, xenServerPatches, xenServerVersions); - - statusReporter("Determining required XenServer update..."); - var updateAlerts = XenAdmin.Core.Updates.NewXenServerVersionAlerts(xenServerVersions).Where(alert => !alert.CanIgnore).ToList(); - - statusReporter("Determining required patches..."); - var patchAlerts = XenAdmin.Core.Updates.NewXenServerPatchAlerts(xenServerVersions, xenServerPatches).Where(alert => !alert.CanIgnore).ToList(); - - statusReporter("Running patch check(s), this may take some time..."); - - var validators = new List - { - new HfxEligibilityValidator(xenServerVersions), - new CorePatchDetailsValidator(patchAlerts), - new PatchURLValidator(patchAlerts) - }; - - if (_checkHotfixContents) - validators.Add(new ZipContentsValidator(patchAlerts, _configProvider)); - - validators.ForEach(v => v.Validate(statusReporter)); - - var summaryGenerators = new List {new HeaderDecorator(serverVersion, _xmlLocation)}; - summaryGenerators.AddRange(validators); - summaryGenerators.Add(new XenServerUpdateDecorator(updateAlerts)); - summaryGenerators.Add(new PatchAlertDecorator(patchAlerts)); - return summaryGenerators; - } - - private void CheckVersionExistsInCfu(string serverVersion, List xenServerVersions) - { - if (xenServerVersions.All(v => v.Version.ToString() != serverVersion)) - { - var sb = new StringBuilder(); - sb.AppendLine($"Could not find version {serverVersion} in the CFU file."); - sb.AppendLine("Available versions are:"); - xenServerVersions.Select(i => i.Version.ToString()).Distinct().ToList().ForEach(v => sb.AppendLine(v)); - throw new CFUValidationException(sb.ToString()); - } - } - - private void ReadCheckForUpdatesXML(out List patches, out List versions) - { - ICheckForUpdatesXMLSource checkForUpdates = xmlFactory.GetAction(UrlOrFile, _xmlLocation); - checkForUpdates.RunAsync(); - - ConsoleSpinner spinner = new ConsoleSpinner(); - while(!checkForUpdates.IsCompleted) - { - spinner.Turn(checkForUpdates.PercentComplete); - } - - if (checkForUpdates.ErrorRaised != null) - throw checkForUpdates.ErrorRaised; - - patches = checkForUpdates.XenServerPatches; - versions = checkForUpdates.XenServerVersions; - } - - private void SetupMocks(string versionToCheck, List xenServerPatches, List xenServerVersions) - { - Mock coordinator = mom.NewXenObject(id); - Mock pool = mom.NewXenObject(id); - XenRef coordinatorRef = new XenRef("ref"); - pool.Setup(p => p.master).Returns(coordinatorRef); - pool.Setup(p => p.other_config).Returns(new Dictionary()); - mom.MockCacheFor(id).Setup(c => c.Resolve(It.IsAny>())).Returns(pool.Object); - mom.MockConnectionFor(id).Setup(c => c.Resolve(coordinatorRef)).Returns(coordinator.Object); - mom.MockConnectionFor(id).Setup(c => c.IsConnected).Returns(true); - coordinator.Setup(h => h.software_version).Returns(new Dictionary()); - coordinator.Setup(h => h.ProductVersion()).Returns(versionToCheck); - coordinator.Setup(h => h.AppliedPatches()).Returns(GenerateMockPoolPatches(xenServerPatches)); - - //Currently build number will be referenced first so if it's present hook it up - string buildNumber = xenServerVersions.First(v => v.Version.ToString() == versionToCheck).BuildNumber; - coordinator.Setup(h=>h.BuildNumberRaw()).Returns(buildNumber); - } - - private List GenerateMockPoolPatches(List xenServerPatches) - { - List patches = new List(); - - foreach (string installedHotfix in _installedHotfixes) - { - string hotfix = installedHotfix; - XenServerPatch match = xenServerPatches.Find(m => m.Name.Contains(hotfix)); - - if(match == null) - throw new CFUValidationException("No patch could be found in the XML matching " + hotfix); - - Mock pp = mom.NewXenObject(id); - pp.Setup(p => p.uuid).Returns(match.Uuid); - patches.Add(pp.Object); - } - - return patches; - } - - } -} diff --git a/CFUValidator/CFUValidator.csproj b/CFUValidator/CFUValidator.csproj deleted file mode 100644 index 086c07a006..0000000000 --- a/CFUValidator/CFUValidator.csproj +++ /dev/null @@ -1,145 +0,0 @@ - - - - Debug - AnyCPU - 9.0.30729 - 2.0 - {39308480-78C3-40B4-924D-06914F343ACD} - Exe - Properties - CFUValidator - CFUValidator - v4.8 - 512 - publish\ - true - Disk - false - Foreground - 7 - Days - false - false - true - 0 - 1.0.0.%2a - false - false - true - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - false - true - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - false - - - - ..\packages\Moq.dll - - - - 3.5 - - - - - - Properties\CommonAssemblyInfo.cs - - - - - - - - - - - - - - - - - - - - - - False - .NET Framework Client Profile - false - - - False - .NET Framework 2.0 %28x86%29 - false - - - False - .NET Framework 3.0 %28x86%29 - false - - - False - .NET Framework 3.5 - false - - - False - .NET Framework 3.5 SP1 - true - - - False - Windows Installer 3.1 - true - - - - - {21B9482C-D255-40D5-ABA7-C8F00F99547C} - XenAdminTests - - - {70BDA4BC-F062-4302-8ACD-A15D8BF31D65} - XenAdmin - - - {9861DFA1-B41F-432D-A43F-226257DEBBB9} - XenCenterLib - - - {B306FC59-4441-4A5F-9F54-D3F68D4EE38D} - XenModel - - - - - - - - \ No newline at end of file diff --git a/CFUValidator/CommandLineOptions/CFUCommandLineOptionManager.cs b/CFUValidator/CommandLineOptions/CFUCommandLineOptionManager.cs deleted file mode 100644 index 6f8c5f3a34..0000000000 --- a/CFUValidator/CommandLineOptions/CFUCommandLineOptionManager.cs +++ /dev/null @@ -1,112 +0,0 @@ -/* Copyright (c) Cloud Software Group, Inc. - * - * 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.Collections.Generic; -using System.Linq; -using System.Text; - -namespace CFUValidator.CommandLineOptions -{ - internal class CFUCommandLineOptionManager - { - public CFUCommandLineOptionManager(CommandLineArgument[] args) - { - if (args.First(c => c.Usage == OptionUsage.Help).IsActiveOption || - args.All(c => !c.IsActiveOption)) - throw new CFUValidationException(GetHelp(args)); - - CommandLineArgument urlArg = args.First(c => c.Usage == OptionUsage.Url); - CommandLineArgument fileArg = args.First(c => c.Usage == OptionUsage.File); - - if (urlArg.IsActiveOption && fileArg.IsActiveOption) - throw new CFUValidationException($"Switches '-{fileArg.Switch}' and '-{urlArg.Switch}' cannot be used at the same time"); - - if (!urlArg.IsActiveOption && !fileArg.IsActiveOption) - throw new CFUValidationException($"You must provide either option '-{fileArg.Switch}' or '-{urlArg.Switch}'"); - - if (fileArg.IsActiveOption) - { - XmlLocation = fileArg.Options.First(); - XmlLocationType = fileArg.Usage; - } - else - { - XmlLocation = urlArg.Options.First(); - XmlLocationType = urlArg.Usage; - } - - CheckHotfixContents = args.First(c => c.Usage == OptionUsage.CheckZipContents).IsActiveOption; - - CommandLineArgument usernameArg = args.First(c => c.Usage == OptionUsage.Username); - CommandLineArgument clientIdArg = args.First(c => c.Usage == OptionUsage.ClientId); - - if (CheckHotfixContents) - { - Username = usernameArg.Options.First(); - ClientId = clientIdArg.Options.First(); - } - - var serverArg = args.First(c => c.Usage == OptionUsage.ServerVersion); - ServerVersion = serverArg.IsActiveOption ? serverArg.Options.First() : AllVersions; - - var hotfixArg = args.First(c => c.Usage == OptionUsage.Hotfix); - InstalledHotfixes = hotfixArg.IsActiveOption ? hotfixArg.Options : new List(); - } - - public static string AllVersions = "999.999.999"; - - public string XmlLocation { get; } - - public bool CheckHotfixContents { get; } - - public string Username { get; } - - public string ClientId { get; } - - public OptionUsage XmlLocationType { get; } - - public string ServerVersion { get; } - - public List InstalledHotfixes { get; } - - private static string GetHelp(CommandLineArgument[] args) - { - StringBuilder sb = new StringBuilder(); - sb.AppendLine("\nUsage:"); - sb.AppendLine("\n CFUValidator.exe [options]"); - sb.AppendLine("\nOptions:"); - - var orderedArgs = args.OrderBy(c => c.Switch); - foreach (CommandLineArgument cla in orderedArgs) - sb.AppendLine($" -{cla.Switch} {cla.Description}"); - return sb.ToString(); - } - } -} diff --git a/CFUValidator/CommandLineOptions/CommandLineArgument.cs b/CFUValidator/CommandLineOptions/CommandLineArgument.cs deleted file mode 100644 index 9de2ebef66..0000000000 --- a/CFUValidator/CommandLineOptions/CommandLineArgument.cs +++ /dev/null @@ -1,64 +0,0 @@ -/* Copyright (c) Cloud Software Group, Inc. - * - * 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.Collections.Generic; - -namespace CFUValidator.CommandLineOptions -{ - public enum OptionUsage - { - Help, - Url, - File, - Hotfix, - ServerVersion, - CheckZipContents, - Username, - ClientId - } - - public class CommandLineArgument - { - public CommandLineArgument(OptionUsage usage, char commandSwitch, string description) - { - Switch = commandSwitch; - Description = description; - Usage = usage; - Options = null; - IsActiveOption = false; - } - - public OptionUsage Usage { get; private set; } - public char Switch { get; private set; } - public List Options { get; set; } - public string Description { get; private set; } - public bool IsActiveOption { get; set; } - } -} diff --git a/CFUValidator/CommandLineOptions/CommandLineParser.cs b/CFUValidator/CommandLineOptions/CommandLineParser.cs deleted file mode 100644 index d7b534aacf..0000000000 --- a/CFUValidator/CommandLineOptions/CommandLineParser.cs +++ /dev/null @@ -1,79 +0,0 @@ -/* Copyright (c) Cloud Software Group, Inc. - * - * 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.Linq; -using System.Text.RegularExpressions; - -namespace CFUValidator.CommandLineOptions -{ - public class CommandLineParser - { - private readonly string[] args; - - public CommandLineArgument[] ParsedArguments { get; } = - { - new CommandLineArgument(OptionUsage.Help, 'h', "Display this help."), - new CommandLineArgument(OptionUsage.CheckZipContents, 'c', "Optionally check the zip contents of the hotfixes."), - new CommandLineArgument(OptionUsage.Url, 'u', "URL of CFU XML. Cannot be used with -f flag."), - new CommandLineArgument(OptionUsage.File, 'f', "Path to CFU XML file. Cannot be used with -u flag."), - new CommandLineArgument(OptionUsage.ServerVersion, 's', "Server version to test, eg. 6.0.2."), - new CommandLineArgument(OptionUsage.Hotfix, 'p', "Space delimited list of patches/hotfixes to test, e.g. XS602E001."), - new CommandLineArgument(OptionUsage.Username, 'n', "Username for downloading hotfixes, e.g. john123."), - new CommandLineArgument(OptionUsage.ClientId, 'k', "ClientId to use for downloading hotfixes (alphanumeric string).") - }; - - public CommandLineParser(string[] args) - { - this.args = args; - } - - public void Parse() - { - string[] recastArgs = Regex.Split(string.Join(" ", args).Trim(), @"(?=[-])(?<=[ ])"); - foreach (string arg in recastArgs) - { - if (String.IsNullOrEmpty(arg)) - continue; - - string optionSwitch = Regex.Match(arg, "[-]{1}[a-z]{1}").Value.Trim(); - char switchChar = Convert.ToChar(optionSwitch.Substring(1, 1)); - string[] splitArgs = arg.Replace(optionSwitch, "").Trim().Split(' '); - - CommandLineArgument cla = ParsedArguments.FirstOrDefault(c => c.Switch == switchChar); - if (cla != null) - { - cla.Options = splitArgs.Where(s => !String.IsNullOrEmpty(s)).ToList(); - cla.IsActiveOption = true; - } - } - } - } -} diff --git a/CFUValidator/ConsoleSpinner.cs b/CFUValidator/ConsoleSpinner.cs deleted file mode 100644 index 7c54f7a492..0000000000 --- a/CFUValidator/ConsoleSpinner.cs +++ /dev/null @@ -1,84 +0,0 @@ -/* Copyright (c) Cloud Software Group, Inc. - * - * 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.Threading; - -namespace CFUValidator -{ - public class ConsoleSpinner - { - int counter; - private const string working = "Working "; - - public ConsoleSpinner() - { - counter = 0; - } - - public void Turn() - { - counter++; - switch (counter % 4) - { - case 0: WriteAtOrigin(working + "/"); break; - case 1: WriteAtOrigin(working + "-"); break; - case 2: WriteAtOrigin(working + "\\"); break; - case 3: WriteAtOrigin(working + "|"); break; - } - Thread.Sleep(500); - } - - public void Turn(double percentageComplete) - { - counter++; - switch (counter % 4) - { - case 0: WriteAtOrigin(working + "/ (" + percentageComplete + "%)"); break; - case 1: WriteAtOrigin(working + "- (" + percentageComplete + "%)"); break; - case 2: WriteAtOrigin(working + "\\ (" + percentageComplete + "%)"); break; - case 3: WriteAtOrigin(working + "| (" + percentageComplete + "%)"); break; - } - Thread.Sleep(500); - } - - private void WriteAtOrigin(string toWrite) - { - try - { - Console.SetCursorPosition(0, Console.CursorTop); - Console.Write(toWrite); - Console.SetCursorPosition(0, Console.CursorTop); - } - catch (SystemException){} - } - } -} - diff --git a/CFUValidator/OutputDecorators/AlertDecorator.cs b/CFUValidator/OutputDecorators/AlertDecorator.cs deleted file mode 100644 index 888cc59787..0000000000 --- a/CFUValidator/OutputDecorators/AlertDecorator.cs +++ /dev/null @@ -1,137 +0,0 @@ -/* Copyright (c) Cloud Software Group, Inc. - * - * 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 System.Linq; -using System.Text; -using System.Text.RegularExpressions; -using XenAdmin.Alerts; - - -namespace CFUValidator.OutputDecorators -{ - public interface ISummaryGenerator - { - string GenerateSummary(); - } - - public class HeaderDecorator : ISummaryGenerator - { - private readonly string _serverVersion; - private readonly string _xmlLocation; - - public HeaderDecorator(string serverVersion, string xmlLocation) - { - _serverVersion = serverVersion; - _xmlLocation = xmlLocation; - } - - public string GenerateSummary() - { - return $"Summary for server version {_serverVersion}, XML from {_xmlLocation}, generated at {DateTime.Now.ToLocalTime()}\n"; - } - } - - public abstract class AlertDecorator : ISummaryGenerator - { - public string GenerateSummary() - { - var sb = new StringBuilder(); - sb.AppendLine(SummaryTitle); - sb.AppendLine(GenerateSummaryCore()); - return sb.ToString(); - } - - protected abstract string GenerateSummaryCore(); - - protected abstract string SummaryTitle { get; } - } - - class XenServerUpdateDecorator : AlertDecorator - { - private readonly List _alerts; - - public XenServerUpdateDecorator(List alerts) - { - _alerts = alerts; - } - - protected override string GenerateSummaryCore() - { - if (_alerts.Count == 0) - return "None"; - - var sb = new StringBuilder(); - foreach (XenServerVersionAlert alert in _alerts) - sb.AppendLine(alert == null ? "XenServer update could not be found" : alert.Version.Name); - return sb.ToString(); - } - - protected override string SummaryTitle => "XenServer updates required:"; - } - - - class PatchAlertDecorator : AlertDecorator - { - private readonly List _alerts; - private const string HOTFIX_REGEX = "XS[0-9]+E[A-Z]*[0-9]+"; - - public PatchAlertDecorator(List alerts) - { - _alerts = alerts; - } - - protected override string GenerateSummaryCore() - { - if (_alerts.Count == 0) - return "None"; - - var sb = new StringBuilder(); - - foreach (XenServerPatchAlert alert in _alerts.OrderBy(a => a.Patch.Name)) - { - string patchName = Regex.Match(alert.Patch.Name, HOTFIX_REGEX).Value; - - if (string.IsNullOrEmpty(patchName)) - patchName = alert.Patch.Name.Trim(); - - if (string.IsNullOrEmpty(patchName)) - patchName = $"Name unknown (uuid={alert.Patch.Uuid})"; - - sb.AppendLine(patchName); - } - - return sb.ToString(); - } - - protected override string SummaryTitle => "Patches required:"; - } -} diff --git a/CFUValidator/Program.cs b/CFUValidator/Program.cs deleted file mode 100644 index 5a244b8390..0000000000 --- a/CFUValidator/Program.cs +++ /dev/null @@ -1,97 +0,0 @@ -/* Copyright (c) Cloud Software Group, Inc. - * - * 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.Net; -using CFUValidator.CommandLineOptions; -using XenAdmin; -using XenAdmin.Core; -using XenAdmin.Network; - -namespace CFUValidator -{ - static class Program - { - static void Main(string[] args) - { - try - { - CommandLineParser parser = new CommandLineParser(args); - parser.Parse(); - - CFUCommandLineOptionManager manager = new CFUCommandLineOptionManager(parser.ParsedArguments); - - var cfuValidator = new CFUValidator(manager.XmlLocationType, manager.XmlLocation, - manager.ServerVersion, manager.InstalledHotfixes, - manager.CheckHotfixContents, new ConfigProvider(manager.Username, manager.ClientId)); - - cfuValidator.Validate(Console.WriteLine); - } - catch (Exception ex) - { - Console.WriteLine(ex.Message); - - if (!(ex is CFUValidationException)) - Console.WriteLine(ex.StackTrace); - - Environment.Exit(1); - } - - Environment.Exit(0); - } - } - - public class ConfigProvider : IConfigProvider - { - public ConfigProvider(string username, string clientId) - { - FileServiceUsername = username; - FileServiceClientId = clientId; - } - - public string FileServiceUsername { get; } - public string FileServiceClientId { get; } - - public string GetCustomTokenUrl() - { - return Registry.GetCustomTokenUrl() ?? InvisibleMessages.TOKEN_API_URL; - } - - public IWebProxy GetProxyFromSettings(IXenConnection connection) - { - return null; - } - - public IWebProxy GetProxyFromSettings(IXenConnection connection, bool isForXenServer) - { - return null; - } - } -} diff --git a/CFUValidator/Properties/AssemblyInfo.cs b/CFUValidator/Properties/AssemblyInfo.cs deleted file mode 100644 index e6cfaecbb1..0000000000 --- a/CFUValidator/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,48 +0,0 @@ -/* Copyright (c) Cloud Software Group, Inc. - * - * 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.Reflection; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("CFUValidator")] -[assembly: AssemblyDescription("Utility for testing [XenServerProduct] update packages")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyProduct("[XenCenter]")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("1fc53fff-32d6-4775-a913-203c3410d388")] diff --git a/CFUValidator/Updates/AlternativeUrlDownloadUpdatesXmlSourceAction.cs b/CFUValidator/Updates/AlternativeUrlDownloadUpdatesXmlSourceAction.cs deleted file mode 100644 index 9b0b0f50c1..0000000000 --- a/CFUValidator/Updates/AlternativeUrlDownloadUpdatesXmlSourceAction.cs +++ /dev/null @@ -1,81 +0,0 @@ -/* Copyright (c) Cloud Software Group, Inc. - * - * 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.IO; -using System.Net; -using System.Xml; -using XenAdmin.Actions; - - -namespace CFUValidator.Updates -{ - class AlternativeUrlDownloadUpdatesXmlSourceAction : DownloadCfuAction, ICheckForUpdatesXMLSource - { - private readonly string _url; - - public AlternativeUrlDownloadUpdatesXmlSourceAction(string url) - : base(true, true, "CFU", url, true) - { - _url = url ?? throw new ArgumentNullException(nameof(url)); - } - - protected override XmlDocument FetchCheckForUpdatesXml() - { - try - { - XmlDocument doc = new XmlDocument(); - XmlReaderSettings settings = new XmlReaderSettings - { - IgnoreComments = true, - IgnoreWhitespace = true, - IgnoreProcessingInstructions = true - }; - - WebRequest wr = WebRequest.Create(_url); - using (Stream xmlStream = wr.GetResponse().GetResponseStream()) - { - if (xmlStream != null) - using (var reader = XmlReader.Create(xmlStream, settings)) - doc.Load(reader); - } - - return doc; - } - catch (Exception) - { - ErrorRaised = new CFUValidationException("Failed to wget the URL: " + _url); - throw ErrorRaised; - } - } - - public Exception ErrorRaised { get; private set; } - } -} diff --git a/CFUValidator/Updates/ICheckForUpdatesXMLSource.cs b/CFUValidator/Updates/ICheckForUpdatesXMLSource.cs deleted file mode 100644 index e1fab94207..0000000000 --- a/CFUValidator/Updates/ICheckForUpdatesXMLSource.cs +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright (c) Cloud Software Group, Inc. - * - * 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; - -namespace CFUValidator.Updates -{ - interface ICheckForUpdatesXMLSource - { - List XenServerPatches { get; } - List XenServerVersions{ get; } - bool IsCompleted { get; } - void RunAsync(); - int PercentComplete { get; } - Exception ErrorRaised { get; } - } -} diff --git a/CFUValidator/Updates/ReadFromFileUpdatesXmlSource.cs b/CFUValidator/Updates/ReadFromFileUpdatesXmlSource.cs deleted file mode 100644 index 2b62fe26b3..0000000000 --- a/CFUValidator/Updates/ReadFromFileUpdatesXmlSource.cs +++ /dev/null @@ -1,73 +0,0 @@ -/* Copyright (c) Cloud Software Group, Inc. - * - * 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.IO; -using System.Xml; -using XenAdmin.Actions; - -namespace CFUValidator.Updates -{ - class ReadFromFileUpdatesXmlSource : DownloadCfuAction, ICheckForUpdatesXMLSource - { - private readonly string _location; - - public ReadFromFileUpdatesXmlSource(string location) - : base(true, true, "CFU", location, true) - { - _location = location ?? throw new ArgumentNullException(nameof(location)); - } - - protected override XmlDocument FetchCheckForUpdatesXml() - { - if (!File.Exists(_location)) - { - ErrorRaised = new CFUValidationException("File not found at: " + _location); - throw ErrorRaised; - } - - try - { - XmlDocument xdoc = new XmlDocument(); - using (StreamReader sr = new StreamReader(_location)) - xdoc.Load(sr); - return xdoc; - } - catch(Exception) - { - ErrorRaised = new CFUValidationException("Could not read/parse file: " + _location); - throw ErrorRaised; - } - - } - - public Exception ErrorRaised { get; private set; } - } -} diff --git a/CFUValidator/Updates/XmlRetrieverFactory.cs b/CFUValidator/Updates/XmlRetrieverFactory.cs deleted file mode 100644 index 48c9264abb..0000000000 --- a/CFUValidator/Updates/XmlRetrieverFactory.cs +++ /dev/null @@ -1,48 +0,0 @@ -/* Copyright (c) Cloud Software Group, Inc. - * - * 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 CFUValidator.CommandLineOptions; - -namespace CFUValidator.Updates -{ - class XmlRetrieverFactory - { - public ICheckForUpdatesXMLSource GetAction(OptionUsage usage, string location) - { - if (usage == OptionUsage.Url) - return new AlternativeUrlDownloadUpdatesXmlSourceAction(location); - if (usage == OptionUsage.File) - return new ReadFromFileUpdatesXmlSource(location); - - throw new ArgumentException("No action was found for the provided usage"); - } - } -} diff --git a/CFUValidator/Validators/CorePatchDetailsValidator.cs b/CFUValidator/Validators/CorePatchDetailsValidator.cs deleted file mode 100644 index 22dd2bed30..0000000000 --- a/CFUValidator/Validators/CorePatchDetailsValidator.cs +++ /dev/null @@ -1,73 +0,0 @@ -/* Copyright (c) Cloud Software Group, Inc. - * - * 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.Alerts; - -namespace CFUValidator.Validators -{ - class CorePatchDetailsValidator : Validator - { - private readonly List alerts; - - public CorePatchDetailsValidator(List alerts) - { - this.alerts = alerts; - } - - protected override string SummaryTitle => "Core details in patch checks:"; - - protected override string Header => "Verifying core patch details..."; - - protected override string Footer => "Verification of core patch details completed."; - - protected override void ValidateCore(Action statusReporter) - { - foreach (XenServerPatchAlert alert in alerts) - { - if(string.IsNullOrEmpty(alert.Patch.Uuid)) - Errors.Add("Missing patch uuid for patch: " + alert.Patch.Name); - if(string.IsNullOrEmpty(alert.Patch.Name)) - Errors.Add("Missing patch name for patch with UUID: " + alert.Patch.Uuid); - if(string.IsNullOrEmpty(alert.Patch.PatchUrl)) - Errors.Add("Missing patch patch-url for patch with UUID: " + alert.Patch.Uuid); - if (string.IsNullOrEmpty(alert.Patch.Description)) - Errors.Add("Missing patch description for patch with UUID: " + alert.Patch.Uuid); - if (string.IsNullOrEmpty(alert.Patch.Url)) - Errors.Add("Missing patch webpage url for patch with UUID: " + alert.Patch.Uuid); - if (string.IsNullOrEmpty(alert.Patch.Guidance)) - Errors.Add("Missing patch guidance for patch with UUID: " + alert.Patch.Uuid); - if (string.IsNullOrEmpty(alert.Patch.TimeStamp.ToString())) - Errors.Add("Missing patch timestamp for patch with UUID: " + alert.Patch.Uuid); - } - } - } -} diff --git a/CFUValidator/Validators/HfxEligibilityValidator.cs b/CFUValidator/Validators/HfxEligibilityValidator.cs deleted file mode 100644 index d489891f04..0000000000 --- a/CFUValidator/Validators/HfxEligibilityValidator.cs +++ /dev/null @@ -1,70 +0,0 @@ -/* Copyright (c) Cloud Software Group, Inc. - * - * 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; - -namespace CFUValidator.Validators -{ - class HfxEligibilityValidator : Validator - { - private List xsversions; - - public HfxEligibilityValidator(List xsversions) - { - this.xsversions = xsversions; - } - - protected override string Header => "Running hotfix eligibility check..."; - - protected override string Footer => "Hotfix Eligibility check completed."; - - protected override string SummaryTitle => "Hotfix eligibility check:"; - - protected override void ValidateCore(Action statusReporter) - { - foreach (XenServerVersion version in xsversions) - DateSanityCheck(version); - } - - private void DateSanityCheck(XenServerVersion version) - { - if (version.HotfixEligibility == hotfix_eligibility.none && version.EolDate == DateTime.MinValue) - Errors.Add("Missing or wrong eol-date field on: " + version.Name); - if (version.HotfixEligibility == hotfix_eligibility.premium && version.HotfixEligibilityPremiumDate == DateTime.MinValue) - Errors.Add("Missing or wrong hotfix-eligibility-premium-date field on: " + version.Name); - if (version.HotfixEligibility == hotfix_eligibility.cu && version.HotfixEligibilityNoneDate == DateTime.MinValue) - Errors.Add("Missing or wrong hotfix-eligibility-none-date field on: " + version.Name); - if (version.HotfixEligibility == hotfix_eligibility.cu && version.HotfixEligibilityPremiumDate == DateTime.MinValue) - Errors.Add("Missing or wrong hotfix-eligibility-premium-date field on: " + version.Name); - } - } -} diff --git a/CFUValidator/Validators/PatchURLValidator.cs b/CFUValidator/Validators/PatchURLValidator.cs deleted file mode 100644 index 0caf2e3a7c..0000000000 --- a/CFUValidator/Validators/PatchURLValidator.cs +++ /dev/null @@ -1,98 +0,0 @@ -/* Copyright (c) Cloud Software Group, Inc. - * - * 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 System.ComponentModel; -using System.Net; -using XenAdmin.Alerts; - -namespace CFUValidator.Validators -{ - class PatchURLValidator : Validator - { - private readonly List alerts; - - public PatchURLValidator(List alerts) - { - this.alerts = alerts; - } - - protected override string Header => "Checking the patch URLs return a suitable http response..."; - - protected override string Footer => "Patch URL check completed."; - - protected override string SummaryTitle => "Required patch URL checks:"; - - protected override void ValidateCore(Action statusReporter) - { - ConsoleSpinner spinner = new ConsoleSpinner(); - - using (var workerThread = new BackgroundWorker()) - { - workerThread.DoWork += CheckAllPatchURLs; - workerThread.RunWorkerAsync(); - - while (workerThread.IsBusy) - spinner.Turn(); - } - } - - private void CheckAllPatchURLs(object sender, DoWorkEventArgs e) - { - foreach (XenServerPatchAlert alert in alerts) - { - if (String.IsNullOrEmpty(alert.Patch.PatchUrl)) - { - Errors.Add($"Patch '{alert.Patch.Name}' URL is missing"); - continue; - } - - HttpWebResponse response = null; - try - { - WebRequest request = WebRequest.Create(alert.Patch.PatchUrl); - request.Method = "HEAD"; - response = request.GetResponse() as HttpWebResponse; - if (response == null || response.StatusCode != HttpStatusCode.OK) - Errors.Add($"Patch '{alert.Patch.Name}' URL '{alert.Patch.PatchUrl}' is invalid"); - } - catch (WebException ex) - { - Errors.Add($"Patch '{alert.Patch.Name}' URL '{alert.Patch.PatchUrl}' failed: {ex.Message}"); - } - finally - { - response?.Close(); - } - } - } - } -} diff --git a/CFUValidator/Validators/Validator.cs b/CFUValidator/Validators/Validator.cs deleted file mode 100644 index 3cbabb6837..0000000000 --- a/CFUValidator/Validators/Validator.cs +++ /dev/null @@ -1,72 +0,0 @@ -/* Copyright (c) Cloud Software Group, Inc. - * - * 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 System.Text; -using CFUValidator.OutputDecorators; - - -namespace CFUValidator.Validators -{ - public abstract class Validator : ISummaryGenerator - { - protected List Errors { get; } = new List(); - - public void Validate(Action statusReporter) - { - statusReporter(Header); - ValidateCore(statusReporter); - statusReporter(Footer); - statusReporter(string.Empty); - } - - public string GenerateSummary() - { - var sb = new StringBuilder(); - sb.AppendLine(SummaryTitle); - - if (Errors.Count > 0) - Errors.ForEach(v => sb.AppendLine(v)); - else - sb.AppendLine("All OK"); - - return sb.ToString(); - } - - protected abstract void ValidateCore(Action statusReporter); - - protected abstract string Header { get; } - - protected abstract string Footer { get; } - - protected abstract string SummaryTitle { get; } - } -} diff --git a/CFUValidator/Validators/ZipContentsValidator.cs b/CFUValidator/Validators/ZipContentsValidator.cs deleted file mode 100644 index 85f20537a3..0000000000 --- a/CFUValidator/Validators/ZipContentsValidator.cs +++ /dev/null @@ -1,105 +0,0 @@ -/* Copyright (c) Cloud Software Group, Inc. - * - * 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.Linq; -using System.Collections.Generic; -using XenAdmin; -using XenAdmin.Core; -using XenAdmin.Actions; -using XenAdmin.Actions.Updates; -using XenAdmin.Alerts; - -namespace CFUValidator.Validators -{ - class ZipContentsValidator : Validator - { - private readonly List alerts; - private IConfigProvider _configProvider; - - public ZipContentsValidator(List alerts, IConfigProvider configProvider) - { - this.alerts = alerts; - _configProvider = configProvider; - } - - protected override string Header => "Downloading and checking the contents of the zip files in the patch..."; - - protected override string Footer => "Download and content check of patch zip files completed."; - - protected override string SummaryTitle => "Required patch zip content checks:"; - - protected override void ValidateCore(Action statusReporter) - { - try - { - TokenManager.GetToken(_configProvider); - - foreach (XenServerPatchAlert alert in alerts.OrderBy(a => a.Patch.Name)) - DownloadPatchFile(alert, statusReporter); - } - finally - { - TokenManager.InvalidateToken(_configProvider); - } - } - - private void DownloadPatchFile(XenServerPatchAlert patch, Action statusReporter) - { - if (string.IsNullOrEmpty(patch.Patch.PatchUrl)) - { - Errors.Add("Patch contained no URL: " + patch.Patch.Name); - return; - } - - var action = new DownloadAndUnzipUpdateAction(patch.Patch.Name, new Uri(patch.Patch.PatchUrl), - BrandManager.ExtensionUpdate, "iso"); - - try - { - statusReporter("Download and unzip patch " + patch.Patch.Name); - - ConsoleSpinner spinner = new ConsoleSpinner(); - action.RunAsync(); - while (!action.IsCompleted) - { - spinner.Turn(action.PercentComplete); - } - - if (!action.Succeeded) - Errors.Add("Patch download and unzip unsuccessful: " + action.Exception.Message); - } - catch (Exception ex) - { - Errors.Add("Patch download error: " + ex.Message); - } - } - } -} diff --git a/CFUValidator/app.config b/CFUValidator/app.config deleted file mode 100644 index 99dca7597b..0000000000 --- a/CFUValidator/app.config +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/XenAdmin.sln b/XenAdmin.sln index b297f76782..5e22eed501 100644 --- a/XenAdmin.sln +++ b/XenAdmin.sln @@ -18,8 +18,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XenModel", "XenModel\XenMod EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XenOvfApi", "XenOvfApi\XenOvfApi.csproj", "{2D78AC6C-B867-484A-A447-3C6FC8B8EAF7}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CFUValidator", "CFUValidator\CFUValidator.csproj", "{39308480-78C3-40B4-924D-06914F343ACD}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xe", "xe\Xe.csproj", "{727E885D-14BE-40F0-9D0B-3853D44D3984}" EndProject Global @@ -96,16 +94,6 @@ Global {2D78AC6C-B867-484A-A447-3C6FC8B8EAF7}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {2D78AC6C-B867-484A-A447-3C6FC8B8EAF7}.Release|Mixed Platforms.Build.0 = Release|Any CPU {2D78AC6C-B867-484A-A447-3C6FC8B8EAF7}.Release|Win32.ActiveCfg = Release|Any CPU - {39308480-78C3-40B4-924D-06914F343ACD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {39308480-78C3-40B4-924D-06914F343ACD}.Debug|Any CPU.Build.0 = Debug|Any CPU - {39308480-78C3-40B4-924D-06914F343ACD}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {39308480-78C3-40B4-924D-06914F343ACD}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {39308480-78C3-40B4-924D-06914F343ACD}.Debug|Win32.ActiveCfg = Debug|Any CPU - {39308480-78C3-40B4-924D-06914F343ACD}.Release|Any CPU.ActiveCfg = Release|Any CPU - {39308480-78C3-40B4-924D-06914F343ACD}.Release|Any CPU.Build.0 = Release|Any CPU - {39308480-78C3-40B4-924D-06914F343ACD}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {39308480-78C3-40B4-924D-06914F343ACD}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {39308480-78C3-40B4-924D-06914F343ACD}.Release|Win32.ActiveCfg = Release|Any CPU {727E885D-14BE-40F0-9D0B-3853D44D3984}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {727E885D-14BE-40F0-9D0B-3853D44D3984}.Debug|Any CPU.Build.0 = Debug|Any CPU {727E885D-14BE-40F0-9D0B-3853D44D3984}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU diff --git a/XenModel/Actions/Updates/DownloadUpdatesXmlAction.cs b/XenModel/Actions/Updates/DownloadUpdatesXmlAction.cs index 86a6884382..39c4fd3cca 100644 --- a/XenModel/Actions/Updates/DownloadUpdatesXmlAction.cs +++ b/XenModel/Actions/Updates/DownloadUpdatesXmlAction.cs @@ -393,7 +393,7 @@ protected DownloadUpdatesXmlAction(string userAgent, string xmlLocationUrl, bool _checkForUpdatesUrl = xmlLocationUrl; } - protected virtual XmlDocument FetchCheckForUpdatesXml() + protected XmlDocument FetchCheckForUpdatesXml() { var checkForUpdatesXml = new XmlDocument(); var uriBuilder = new UriBuilder(_checkForUpdatesUrl); diff --git a/scripts/rebranding.ps1 b/scripts/rebranding.ps1 index 8531a4f534..36db53b37a 100644 --- a/scripts/rebranding.ps1 +++ b/scripts/rebranding.ps1 @@ -86,7 +86,7 @@ $REPO = Get-Item "$PSScriptRoot\.." | Select-Object -ExpandProperty FullName version_csharp $REPO\CommonAssemblyInfo.cs rebranding_global $REPO\CommonAssemblyInfo.cs -$projects = @("CFUValidator", "CommandLib", "xe", "XenAdmin", "XenAdminTests", "XenCenterLib", "XenModel", "XenOvfApi") +$projects = @("CommandLib", "xe", "XenAdmin", "XenAdminTests", "XenCenterLib", "XenModel", "XenOvfApi") foreach ($project in $projects) { $assemblyInfo = "$REPO\$project\Properties\AssemblyInfo.cs" diff --git a/scripts/xenadmin-build.ps1 b/scripts/xenadmin-build.ps1 index 0f00b72c4a..4176e82707 100644 --- a/scripts/xenadmin-build.ps1 +++ b/scripts/xenadmin-build.ps1 @@ -273,14 +273,6 @@ Copy-Item $REPO\XenAdmin\ReportViewer\* $REPO\XenAdminTests\bin\Release\ -Verbos Compress-Archive -Path $REPO\XenAdminTests\bin\Release -DestinationPath $OUTPUT_DIR\XenAdminTests.zip -Verbose:$verbose Compress-Archive -Path $REPO\XenAdmin\TestResources\* -DestinationPath "$OUTPUT_DIR\$($appName)TestResources.zip" -Verbose:$verbose -#################################################### -# include cfu validator binary in output directory # -#################################################### - -Compress-Archive -Path $REPO\CFUValidator\bin\Release\*.dll -DestinationPath $OUTPUT_DIR\CFUValidator.zip -Verbose:$verbose -Compress-Archive -Path $REPO\CFUValidator\bin\Release\CFUValidator.exe -Update -DestinationPath $OUTPUT_DIR\CFUValidator.zip -Verbose:$verbose -Compress-Archive -Path $REPO\CFUValidator\bin\Release\$appName.exe -Update -DestinationPath $OUTPUT_DIR\CFUValidator.zip -Verbose:$verbose - #################### # package the pdbs # ####################