public void TestAlertWithConnectionAndNoHosts()
        {
            XenServerVersion ver = new XenServerVersion("1.2.3", "name", true, false, "http://url", new List <XenServerPatch>(), new List <XenServerPatch>(), new DateTime(2011, 4, 1).ToString(), "123", "", false, "");
            var alert            = new XenServerVersionAlert(ver);

            alert.IncludeConnection(connA.Object);
            alert.IncludeConnection(connB.Object);

            IUnitTestVerifier validator = new VerifyGetters(alert);

            validator.Verify(new AlertClassUnitTestData
            {
                AppliesTo    = "ConnAName, ConnBName",
                FixLinkText  = "Go to Web Page",
                HelpID       = "XenServerUpdateAlert",
                Description  = "name is now available. Download the latest at the " + XenAdmin.Branding.COMPANY_NAME_SHORT + " website.",
                HelpLinkText = "Help",
                Title        = "name is now available",
                Priority     = "Priority5"
            });

            Assert.IsFalse(alert.CanIgnore);

            VerifyConnExpectations(Times.Once);
            VerifyHostsExpectations(Times.Never);
        }
Exemplo n.º 2
0
 public HotfixEligibilityAlert(IXenConnection connection, XenServerVersion version)
 {
     Connection   = connection;
     this.Version = version;
     pool         = Helpers.GetPoolOfOne(connection);
     _timestamp   = DateTime.Now;
 }
Exemplo n.º 3
0
        public static bool IsAlertNeeded(hotfix_eligibility hotfixEligibility, XenServerVersion version, bool licensed)
        {
            if (version == null)
            {
                return(false);
            }

            switch (hotfixEligibility)
            {
            // all + the EOL date is known -> "Approaching EOL" alert
            case hotfix_eligibility.all when version.EolDate != DateTime.MinValue:
                return(true);

            // premium + unlicensed host -> "EOL for express customers" alert
            case hotfix_eligibility.premium when !licensed:
                return(true);

            // premium + licensed host and the EOL date is known -> "Approaching EOL" alert
            case hotfix_eligibility.premium when version.EolDate != DateTime.MinValue:
                return(true);

            // cu -> "EOL for express customers" / "CU for licensed customers" alert
            case hotfix_eligibility.cu:
                return(true);

            // none -> EOL alert
            case hotfix_eligibility.none:
                return(true);

            // everything else -> no alert
            default:
                return(false);
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// Creates a patch alert
 ///  </summary>
 /// <param name="patch">The patch</param>
 /// <param name="newServerVersion">The version that the patch installs, or null if the patch doesn't update the server version</param>
 public XenServerPatchAlert(XenServerPatch patch, XenServerVersion newServerVersion = null)
 {
     Patch            = patch;
     NewServerVersion = newServerVersion;
     if (NewServerVersion != null)
     {
         RequiredXenCenterVersion = Updates.GetRequiredXenCenterVersion(NewServerVersion);
     }
     _priority  = patch.Priority;
     _timestamp = Patch.TimeStamp;
 }
Exemplo n.º 5
0
        private static List <XenServerVersion> GetAVersionWithGivenNumberOfPatches(int numberOfPatches)
        {
            var serverVersions = new List <XenServerVersion>();

            var version = new XenServerVersion("7.0.0", "XenServer Test 7", true, false, "", new List <XenServerPatch>(), new List <XenServerPatch>(), DateTime.MinValue.ToString(), "buildNo", "", false, "");

            for (int ii = 0; ii < numberOfPatches; ii++)
            {
                var patch = new XenServerPatch("patch_uuid_" + ii, "patch name " + ii, "patch description" + ii, "", "", "1.0", "", "", "1970-01-01T00:00:00Z", "", "1000", "1000");
                version.Patches.Add(patch);
                version.MinimalPatches.Add(patch);
            }
            serverVersions.Add(version);

            return(serverVersions);
        }
Exemplo n.º 6
0
 private void DateSanityCheck(XenServerVersion version)
 {
     if (version.HotfixEligibility == hotfix_eligibility.none && version.EolDate == DateTime.MinValue)
     {
         Results.Add("Missing or wrong eol-date field on: " + version.Name);
     }
     if (version.HotfixEligibility == hotfix_eligibility.premium && version.HotfixEligibilityPremiumDate == DateTime.MinValue)
     {
         Results.Add("Missing or wrong hotfix-eligibility-premium-date field on: " + version.Name);
     }
     if (version.HotfixEligibility == hotfix_eligibility.cu && version.HotfixEligibilityNoneDate == DateTime.MinValue)
     {
         Results.Add("Missing or wrong hotfix-eligibility-none-date field on: " + version.Name);
     }
     if (version.HotfixEligibility == hotfix_eligibility.cu && version.HotfixEligibilityPremiumDate == DateTime.MinValue)
     {
         Results.Add("Missing or wrong hotfix-eligibility-premium-date field on: " + version.Name);
     }
 }
        public void TestAlertWithNoConnectionAndNoHosts()
        {
            XenServerVersion ver = new XenServerVersion("1.2.3", "name", true, false, "http://url", new List <XenServerPatch>(), new List <XenServerPatch>(), new DateTime(2011, 4, 1).ToString(), "123", "", false, "", "", "", "", "");
            var alert            = new XenServerVersionAlert(ver);

            ClassVerifiers.VerifyGetters(alert, new AlertClassUnitTestData
            {
                AppliesTo    = string.Empty,
                FixLinkText  = "Go to Web Page",
                HelpID       = "XenServerUpdateAlert",
                Description  = "name is now available. Download the latest at the " + BrandManager.COMPANY_NAME_SHORT + " website.",
                HelpLinkText = "Help",
                Title        = "name is now available",
                Priority     = "Priority5"
            });

            Assert.IsTrue(alert.CanIgnore);

            VerifyConnExpectations(Times.Never);
            VerifyHostsExpectations(Times.Never);
        }
Exemplo n.º 8
0
 public IgnoreServerAction(IXenConnection connection, XenServerVersion version)
     : base(connection, "ignore_patch", "ignore_patch", true)
 {
     Version = version;
 }
Exemplo n.º 9
0
 public XenServerVersionAlert(XenServerVersion version)
 {
     Version    = version;
     _timestamp = version.TimeStamp;
 }
Exemplo n.º 10
0
 public VSwitchControllerCheck(Host host, XenServerVersion newVersion)
     : base(host)
 {
     _newVersion = newVersion;
     _pool       = Helpers.GetPoolOfOne(Host?.Connection);
 }
Exemplo n.º 11
0
 public XenCenterVersionCheck(XenServerVersion newServerVersion)
 {
     _newServerVersion = newServerVersion;
 }
Exemplo n.º 12
0
 public PoolLegacySslCheck(Host host, XenServerVersion newVersion)
     : base(host)
 {
     _newVersion = newVersion;
     _pool       = Helpers.GetPoolOfOne(Host?.Connection);
 }
Exemplo n.º 13
0
 public PowerOniLoCheck(Host host, XenServerVersion newVersion)
     : base(host)
 {
     _newVersion = newVersion;
 }
Exemplo n.º 14
0
 public XenServerUpdateAlert(XenServerVersion version)
 {
     Version    = version;
     _timestamp = version.TimeStamp;
     canIgnore  = true;
 }
        protected virtual List <CheckGroup> GenerateCommonChecks(List <Host> applicableServers)
        {
            var groups = new List <CheckGroup>();

            //HostLivenessCheck checks
            var livenessChecks = new List <Check>();

            foreach (Host host in applicableServers)
            {
                livenessChecks.Add(new HostLivenessCheck(host));
            }

            groups.Add(new CheckGroup(Messages.CHECKING_HOST_LIVENESS_STATUS, livenessChecks));

            //HA checks

            var haChecks = new List <Check>();

            foreach (Host host in SelectedServers)
            {
                if (Helpers.HostIsMaster(host))
                {
                    haChecks.Add(new HAOffCheck(host));
                }
            }
            groups.Add(new CheckGroup(Messages.CHECKING_HA_STATUS, haChecks));

            //PBDsPluggedCheck
            var pbdChecks = new List <Check>();

            foreach (Host host in applicableServers)
            {
                SR uploadSr = null;
                if (PoolUpdate != null && SrUploadedUpdates != null)
                {
                    foreach (var dict in SrUploadedUpdates)
                    {
                        if (dict.Key.uuid == PoolUpdate.uuid && dict.Value.ContainsKey(host))
                        {
                            uploadSr = dict.Value[host];
                            break;
                        }
                    }
                }
                pbdChecks.Add(new PBDsPluggedCheck(host, uploadSr));
            }

            groups.Add(new CheckGroup(Messages.CHECKING_STORAGE_CONNECTIONS_STATUS, pbdChecks));

            XenServerVersion highestNewVersion = null;

            //Disk space, reboot required and can evacuate host checks for automated and version updates
            if (WizardMode != WizardMode.SingleUpdate)
            {
                var diskChecks     = new List <Check>();
                var rebootChecks   = new List <Check>();
                var evacuateChecks = new List <Check>();

                foreach (Pool pool in SelectedPools)
                {
                    //if any host is not licensed for automated updates
                    bool automatedUpdatesRestricted = pool.Connection.Cache.Hosts.Any(Host.RestrictBatchHotfixApply);

                    var minimalPatches = WizardMode == WizardMode.NewVersion
                        ? Updates.GetMinimalPatches(UpdateAlert, ApplyUpdatesToNewVersion && !automatedUpdatesRestricted)
                        : Updates.GetMinimalPatches(pool.Connection);

                    if (minimalPatches == null)
                    {
                        continue;
                    }

                    var us    = new Dictionary <Host, List <XenServerPatch> >();
                    var hosts = pool.Connection.Cache.Hosts;
                    Array.Sort(hosts);

                    foreach (var h in hosts)
                    {
                        var ps = Updates.GetPatchSequenceForHost(h, minimalPatches);
                        if (ps != null)
                        {
                            us[h] = ps;
                        }
                    }

                    log.InfoFormat("Minimal patches for {0}: {1}", pool.Name(), string.Join(",", minimalPatches.Select(p => p.Name)));

                    // we check the contains-livepatch property of all the applicable patches to determine if a host will need to be rebooted after patch installation,
                    // because the minimal patches might roll-up patches that are not live-patchable
                    var allPatches = WizardMode == WizardMode.NewVersion
                        ? Updates.GetAllPatches(UpdateAlert, ApplyUpdatesToNewVersion && !automatedUpdatesRestricted)
                        : Updates.GetAllPatches(pool.Connection);

                    foreach (Host host in us.Keys)
                    {
                        diskChecks.Add(new DiskSpaceForAutomatedUpdatesCheck(host, us));

                        if (us[host] != null && us[host].Count > 0)
                        {
                            var allApplicablePatches = Updates.GetPatchSequenceForHost(host, allPatches);
                            var restartHostPatches   = allApplicablePatches != null
                                ? allApplicablePatches.Where(p => p.after_apply_guidance == after_apply_guidance.restartHost).ToList()
                                : new List <XenServerPatch>();

                            rebootChecks.Add(new HostNeedsRebootCheck(host, restartHostPatches));
                            if (restartHostPatches.Any(p => !p.ContainsLivepatch))
                            {
                                evacuateChecks.Add(new AssertCanEvacuateCheck(host));
                            }

                            foreach (var p in us[host])
                            {
                                var newVersion = Updates.XenServerVersions.FirstOrDefault(v => v.PatchUuid != null && v.PatchUuid.Equals(p.Uuid, StringComparison.OrdinalIgnoreCase));
                                if (newVersion != null && (highestNewVersion == null || newVersion.Version > highestNewVersion.Version))
                                {
                                    highestNewVersion = newVersion;
                                }
                            }
                        }
                    }
                }

                groups.Add(new CheckGroup(Messages.PATCHINGWIZARD_PRECHECKPAGE_CHECKING_DISK_SPACE, diskChecks));
                if (rebootChecks.Count > 0)
                {
                    groups.Add(new CheckGroup(Messages.CHECKING_SERVER_NEEDS_REBOOT, rebootChecks));
                }
                if (evacuateChecks.Count > 0)
                {
                    groups.Add(new CheckGroup(Messages.CHECKING_CANEVACUATE_STATUS, evacuateChecks));
                }
            }

            //XenCenter version check
            if (highestNewVersion != null || UpdateAlert?.NewServerVersion != null)
            {
                // add XenCenter version check as the first group
                groups.Insert(0, new CheckGroup(Messages.CHECKING_XENCENTER_VERSION,
                                                new List <Check> {
                    new XenCenterVersionCheck(highestNewVersion ?? UpdateAlert.NewServerVersion)
                }));
            }

            //GFS2 check for version updates
            if (WizardMode == WizardMode.NewVersion)
            {
                var gfs2Checks = new List <Check>();

                foreach (Pool pool in SelectedPools.Where(p =>
                                                          Helpers.KolkataOrGreater(p.Connection) && !Helpers.LimaOrGreater(p.Connection)))
                {
                    Host host = pool.Connection.Resolve(pool.master);
                    gfs2Checks.Add(new PoolHasGFS2SR(host));
                }

                if (gfs2Checks.Count > 0)
                {
                    groups.Add(new CheckGroup(Messages.CHECKING_CLUSTERING_STATUS, gfs2Checks));
                }
            }

            return(groups);
        }
Exemplo n.º 16
0
 public XenServerVersionAlert(XenServerVersion version)
 {
     Version = version;
     RequiredXenCenterVersion = Updates.GetRequiredXenCenterVersion(Version);
     _timestamp = version.TimeStamp;
 }
Exemplo n.º 17
0
 public XenCenterVersionCheck(XenServerVersion newServerVersion)
     : base(null)
 {
     _newServerVersion = newServerVersion;
 }