コード例 #1
0
        public void TestAlertWithConnectionAndHosts()
        {
            XenServerVersion ver = new XenServerVersion("1.2.3", "name", true, "http://url", new List<XenServerPatch>(), new DateTime(2011,4,1).ToString(), "123");
            XenServerUpdateAlert alert = new XenServerUpdateAlert(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 Citrix website (April 1, 2011)",
                HelpLinkText = "&Help on this alert...",
                Title = "name is now available",
                Priority = "Priority5"
            });

            Assert.IsFalse(alert.CanIgnore);

            VerifyConnExpectations(Times.Once);
            VerifyHostsExpectations(Times.Once);
        }
コード例 #2
0
ファイル: Updates.cs プロジェクト: BATYD-Turksat/xenadmin
        public static XenServerUpdateAlert NewXenServerUpdateAlert(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;

            XenServerUpdateAlert alert = new XenServerUpdateAlert(latestVersion);

            foreach (IXenConnection xc in ConnectionsManager.XenConnectionsCopy)
            {
                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);
            }

            if (alert.CanIgnore)
                return null;

            return alert;
        }
コード例 #3
0
ファイル: Updates.cs プロジェクト: ChrisH4rding/xenadmin
        public static XenServerUpdateAlert NewServerVersionAlert(List<XenServerVersion> xenServerVersions,
            bool checkAlertIsAlreadyDismissed)
        {
            if (Helpers.CommonCriteriaCertificationRelease)
                return null;

            List<XenServerVersion> latestVersions = xenServerVersions.FindAll(item => item.Latest);

            if (latestVersions.Count == 0)
                return null;

            XenServerVersion latestVersion = latestVersions[0];
            for (int i = 1; i < latestVersions.Count; i++)
            {
                XenServerVersion version = latestVersions[i];
                if (version.Version > latestVersion.Version)
                    latestVersion = version;
            }

            XenServerUpdateAlert alert = new XenServerUpdateAlert(latestVersion);

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

                //check if the latest version has been already dismissed
                if (checkAlertIsAlreadyDismissed && GetLatestSeenVersion(pool).Contains(latestVersion.VersionAndOEM))
                    return null;

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

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

            if (alert.CanIgnore)
                return null;

            return alert;
        }