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

            alert.IncludeConnection(connA.Object);
            alert.IncludeConnection(connB.Object);
            alert.IncludeHosts(new List <Host>()
            {
                hostA.Object, hostB.Object
            });

            IUnitTestVerifier validator = new VerifyGetters(alert);

            validator.Verify(new AlertClassUnitTestData
            {
                AppliesTo    = "HostAName, HostBName, 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.Once);
        }
Ejemplo n.º 2
0
        public static XenServerVersionAlert NewXenServerVersionAlert(List <XenServerVersion> xenServerVersions)
        {
            if (Helpers.CommonCriteriaCertificationRelease)
            {
                return(null);
            }

            var latestVersion = xenServerVersions.FindAll(item => item.Latest).OrderByDescending(v => v.Version).FirstOrDefault();

            if (latestVersion == null)
            {
                return(null);
            }

            var alert = new XenServerVersionAlert(latestVersion);

            foreach (IXenConnection xc in ConnectionsManager.XenConnectionsCopy)
            {
                if (!xc.IsConnected)
                {
                    continue;
                }

                Host        master = Helpers.GetMaster(xc);
                Pool        pool   = Helpers.GetPoolOfOne(xc);
                List <Host> hosts  = xc.Cache.Hosts.ToList();
                if (master == null || pool == null)
                {
                    continue;
                }

                var outOfDateHosts = hosts.Where(host => new Version(Helpers.HostProductVersion(host)) < latestVersion.Version);

                if (outOfDateHosts.Count() == hosts.Count)
                {
                    alert.IncludeConnection(xc);
                }
                else
                {
                    alert.IncludeHosts(outOfDateHosts);
                }
            }

            return(alert);
        }
Ejemplo n.º 3
0
        private static XenServerVersionAlert CreateAlertForXenServerVersion(XenServerVersion version)
        {
            var alert = new XenServerVersionAlert(version);

            // the patch that installs this version, if any
            var patch = XenServerPatches.FirstOrDefault(p => p.Uuid.Equals(version.PatchUuid, StringComparison.OrdinalIgnoreCase));

            foreach (IXenConnection xc in ConnectionsManager.XenConnectionsCopy)
            {
                if (!xc.IsConnected)
                {
                    continue;
                }

                Host        master = Helpers.GetMaster(xc);
                Pool        pool   = Helpers.GetPoolOfOne(xc);
                List <Host> hosts  = xc.Cache.Hosts.ToList();
                if (master == null || pool == null)
                {
                    continue;
                }

                // Show the Upgrade alert for a host if:
                // - the host version is older than this version AND
                // - there is no patch (amongst the current version patches) that can update to this version OR, if there is a patch, the patch cannot be installed
                var patchApplicable = patch != null && GetServerVersions(master, XenServerVersions).Any(v => v.Patches.Contains(patch));
                var outOfDateHosts  = hosts.Where(host => new Version(Helpers.HostProductVersion(host)) < version.Version &&
                                                  (!patchApplicable || !PatchCanBeInstalledOnHost(patch, host, version)));

                if (outOfDateHosts.Count() == hosts.Count)
                {
                    alert.IncludeConnection(xc);
                }
                else
                {
                    alert.IncludeHosts(outOfDateHosts);
                }
            }

            return(alert);
        }