コード例 #1
0
        public void TestAlertWithHostsAndNoConnection()
        {
            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.IncludeHosts(new List <Host> {
                hostA.Object, hostB.Object
            });

            IUnitTestVerifier validator = new VerifyGetters(alert);

            validator.Verify(new AlertClassUnitTestData
            {
                AppliesTo    = "HostAName, HostBName",
                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.Never);
            VerifyHostsExpectations(Times.Once);
        }
コード例 #2
0
        private void GeneratePatchSummary(List <XenServerPatchAlert> alerts, List <AlertFeatureValidator> validators,
                                          XenServerVersionAlert updateAlert, XenCenterUpdateAlert xcupdateAlert)
        {
            OuputComponent                 oc            = new OutputTextOuputComponent(XmlLocation, ServerVersion);
            XenCenterUpdateDecorator       xcud          = new XenCenterUpdateDecorator(oc, xcupdateAlert);
            XenServerUpdateDecorator       xsud          = new XenServerUpdateDecorator(xcud, updateAlert);
            PatchAlertDecorator            pad           = new PatchAlertDecorator(xsud, alerts);
            AlertFeatureValidatorDecorator afdCoreFields = new AlertFeatureValidatorDecorator(pad,
                                                                                              validators.First(v => v is CorePatchDetailsValidator),
                                                                                              "Core fields in patch checks:");
            AlertFeatureValidatorDecorator afdPatchUrl = new AlertFeatureValidatorDecorator(afdCoreFields,
                                                                                            validators.First(v => v is PatchURLValidator),
                                                                                            "Required patch URL checks:");
            AlertFeatureValidatorDecorator afdZipContents = new AlertFeatureValidatorDecorator(afdPatchUrl,
                                                                                               validators.First(v => v is ZipContentsValidator),
                                                                                               "Required patch zip content checks:");

            if (CheckHotfixContents)
            {
                Output = afdZipContents.Generate().Insert(0, Output).ToString();
            }
            else
            {
                Output = afdPatchUrl.Generate().Insert(0, Output).ToString();
            }
        }
コード例 #3
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);
        }
コード例 #4
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);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
 public void TestAlertWithNullVersion()
 {
     var alert = new XenServerVersionAlert(null);
 }
コード例 #7
0
 public XenServerUpdateDecorator(OuputComponent ouputComponent, XenServerVersionAlert alert)
 {
     SetComponent(ouputComponent);
     this.alert = alert;
 }