Example #1
0
        protected override Problem RunHostCheck()
        {
            var hotfix = HotfixFactory.Hotfix(Host);

            if (hotfix != null && hotfix.ShouldBeAppliedTo(Host))
            {
                return(new HostDoesNotHaveHotfix(this, Host));
            }

            return(null);
        }
Example #2
0
 protected override Actions.AsyncAction CreateAction(out bool cancelled)
 {
     cancelled = false;
     return(new Actions.DelegatedAsyncAction(Server.Connection, string.Format(Messages.APPLYING_HOTFIX_TO_HOST, Server), "", "",
                                             (ss) =>
     {
         Hotfix hotfix = HotfixFactory.Hotfix(Server);
         if (hotfix != null)
         {
             hotfix.Apply(Server, ss);
         }
     }, true));
 }
Example #3
0
        protected override Problem RunHostCheck()
        {
            if (!_pool.ssl_legacy() || Helpers.StockholmOrGreater(Host))
            {
                return(null);
            }

            //update case
            if (_newVersion != null)
            {
                if (_newVersion.Version.CompareTo(new Version(BrandManager.ProductVersion82)) >= 0)
                {
                    return(new LegacySslProblem(this, _pool));
                }
                return(null);
            }

            //upgrade case

            if (!_manualUpgrade)
            {
                var hotfix = HotfixFactory.Hotfix(Host);
                if (hotfix != null && hotfix.ShouldBeAppliedTo(Host))
                {
                    return(new HostDoesNotHaveHotfixWarning(this, Host));
                }
            }

            string upgradePlatformVersion = null;

            if (_installMethodConfig != null)
            {
                Host.TryGetUpgradeVersion(Host, _installMethodConfig, out upgradePlatformVersion, out _);
            }

            // we don't know the upgrade version, so add generic warning
            // (this is the case of the manual upgrade or when the rpu plugin doesn't have the function)
            if (string.IsNullOrEmpty(upgradePlatformVersion))
            {
                return(new LegacySslWarning(this, _pool));
            }

            // we know they are upgrading to Stockholm or greater, so block them
            if (Helpers.StockholmOrGreater(upgradePlatformVersion))
            {
                return(new LegacySslProblem(this, _pool));
            }

            return(null);
        }
Example #4
0
        protected override Problem RunHostCheck()
        {
            //update case
            if (!_upgrade)
            {
                return(new PoolHasPVGuestWarningUrl(this, _pool));
            }

            //upgrade case

            if (!_manualUpgrade)
            {
                var hotfix = HotfixFactory.Hotfix(Host);
                if (hotfix != null && hotfix.ShouldBeAppliedTo(Host))
                {
                    return(new HostDoesNotHaveHotfixWarning(this, Host));
                }
            }

            string upgradePlatformVersion = null;

            if (_installMethodConfig != null)
            {
                Host.TryGetUpgradeVersion(Host, _installMethodConfig, out upgradePlatformVersion, out _);
            }

            // we don't know the upgrade version, so add warning
            // (this is the case of the manual upgrade or when the rpu plugin doesn't have the function)
            if (string.IsNullOrEmpty(upgradePlatformVersion))
            {
                return(new PoolHasPVGuestWarningUrl(this, _pool));
            }

            if (Helpers.QuebecOrGreater(upgradePlatformVersion))
            {
                return(new PoolHasPVGuestWarningUrl(this, _pool));
            }

            return(null);
        }
Example #5
0
        protected override Problem RunHostCheck()
        {
            var hotfix = HotfixFactory.Hotfix(Host);

            if (hotfix != null && hotfix.ShouldBeAppliedTo(Host))
            {
                return(new HostDoesNotHaveHotfixWarning(this, Host));
            }

            try
            {
                var result = Host.call_plugin(Host.Connection.Session, Host.opaque_ref, "prepare_host_upgrade.py", "testSafe2Upgrade", _installMethodConfig);

                if (result.ToLowerInvariant() == "true")
                {
                    return(null);
                }

                Host.TryGetUpgradeVersion(Host, _installMethodConfig, out var upgradePlatformVersion, out _);

                // block the upgrade to a post-Stockholm version
                if (Helpers.PostStockholm(upgradePlatformVersion))
                {
                    switch (result.ToLowerInvariant())
                    {
                    case "not_enough_space":
                        return(new HostNotSafeToUpgradeProblem(this, Host, HostNotSafeToUpgradeReason.NotEnoughSpace));

                    case "vdi_present":
                        return(new HostNotSafeToUpgradeProblem(this, Host, HostNotSafeToUpgradeReason.VdiPresent));

                    case "utility_part_present":
                        return(new HostNotSafeToUpgradeProblem(this, Host, HostNotSafeToUpgradeReason.UtilityPartitionPresent));

                    case "legacy_partition_table":
                        return(new HostNotSafeToUpgradeProblem(this, Host, HostNotSafeToUpgradeReason.LegacyPartitionTable));

                    default:
                        return(new HostNotSafeToUpgradeProblem(this, Host, HostNotSafeToUpgradeReason.Default));
                    }
                }

                // add a warning for older or unknown upgrade version
                switch (result.ToLowerInvariant())
                {
                case "not_enough_space":
                    return(new HostNotSafeToUpgradeWarning(this, Host, HostNotSafeToUpgradeReason.NotEnoughSpace));

                case "vdi_present":
                    return(new HostNotSafeToUpgradeWarning(this, Host, HostNotSafeToUpgradeReason.VdiPresent));

                case "utility_part_present":
                    return(new HostNotSafeToUpgradeWarning(this, Host, HostNotSafeToUpgradeReason.UtilityPartitionPresent));

                case "legacy_partition_table":
                    return(new HostNotSafeToUpgradeWarning(this, Host, HostNotSafeToUpgradeReason.LegacyPartitionTable));

                default:
                    return(new HostNotSafeToUpgradeWarning(this, Host, HostNotSafeToUpgradeReason.Default));
                }
            }
            catch (Exception exception)
            {
                //note: handle the case when we get UNKNOWN_XENAPI_PLUGIN_FUNCTION - testSafe2Upgrade
                log.Warn($"Plugin call prepare_host_upgrade.testSafe2Upgrade on {Host.Name()} threw an exception.", exception);
            }

            return(null);
        }
        protected override List <CheckGroup> GenerateChecks(Pool_patch patch)
        {
            var groups = new List <CheckGroup>();

            List <Host> hostsToUpgrade         = new List <Host>();
            List <Host> hostsToUpgradeOrUpdate = new List <Host>();

            foreach (var pool in SelectedPools)
            {
                var poolHostsToUpgrade = pool.HostsToUpgrade();
                hostsToUpgrade.AddRange(poolHostsToUpgrade);
                hostsToUpgradeOrUpdate.AddRange(ApplyUpdatesToNewVersion
                    ? HostsToUpgradeOrUpdate(pool)
                    : poolHostsToUpgrade);
            }

            //XenCenter version check (if any of the selected server version is not the latest)
            var latestCrVersion = Updates.XenServerVersions.FindAll(item => item.LatestCr).OrderByDescending(v => v.Version).FirstOrDefault();

            if (latestCrVersion != null &&
                hostsToUpgradeOrUpdate.Any(host => new Version(Helpers.HostProductVersion(host)) < latestCrVersion.Version))
            {
                groups.Add(new CheckGroup(Messages.CHECKING_XENCENTER_VERSION, new List <Check> {
                    new XenCenterVersionCheck(null)
                }));
            }

            //HostMaintenanceModeCheck checks - for hosts that will be upgraded or updated
            var livenessChecks = new List <Check>();

            foreach (Host host in hostsToUpgradeOrUpdate)
            {
                livenessChecks.Add(new HostLivenessCheck(host, hostsToUpgrade.Contains(host)));
            }
            groups.Add(new CheckGroup(Messages.CHECKING_HOST_LIVENESS_STATUS, livenessChecks));

            //HotfixesCheck - for hosts that will be upgraded
            var hotfixChecks = new List <Check>();

            foreach (var host in hostsToUpgrade)
            {
                if (HotfixFactory.IsHotfixRequired(host) && !ManualUpgrade)
                {
                    hotfixChecks.Add(new HostHasHotfixCheck(host));
                }
            }
            if (hotfixChecks.Count > 0)
            {
                groups.Add(new CheckGroup(Messages.CHECKING_UPGRADE_HOTFIX_STATUS, hotfixChecks));
            }

            //SafeToUpgrade- and PrepareToUpgrade- checks - in automatic mode only, for hosts that will be upgraded
            if (!ManualUpgrade)
            {
                var prepareToUpgradeChecks = new List <Check>();
                foreach (var host in hostsToUpgrade)
                {
                    prepareToUpgradeChecks.Add(new PrepareToUpgradeCheck(host, InstallMethodConfig));
                }
                groups.Add(new CheckGroup(Messages.CHECKING_PREPARE_TO_UPGRADE, prepareToUpgradeChecks));

                var safeToUpgradeChecks = new List <Check>();
                foreach (var host in hostsToUpgrade)
                {
                    safeToUpgradeChecks.Add(new SafeToUpgradeCheck(host));
                }
                groups.Add(new CheckGroup(Messages.CHECKING_SAFE_TO_UPGRADE, safeToUpgradeChecks));
            }

            //vSwitch controller check - for each pool
            var vSwitchChecks = (from Host server in SelectedMasters
                                 let check = new VSwitchControllerCheck(server, InstallMethodConfig, ManualUpgrade)
                                             where check.CanRun()
                                             select check as Check).ToList();

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

            //protocol check - for each pool
            var sslChecks = (from Host server in SelectedMasters
                             let check = new PoolLegacySslCheck(server, InstallMethodConfig, ManualUpgrade)
                                         where check.CanRun()
                                         select check as Check).ToList();

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

            //power on mode check - for each host
            var iloChecks = (from Host server in hostsToUpgradeOrUpdate
                             let check = new PowerOniLoCheck(server, InstallMethodConfig, ManualUpgrade)
                                         where check.CanRun()
                                         select check as Check).ToList();

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

            //Checking PV guests - for hosts that have any PV guests and warn the user before the upgrade.
            var pvChecks = (from Host server in SelectedMasters
                            let check = new PVGuestsCheck(server, true, ManualUpgrade, InstallMethodConfig)
                                        where check.CanRun()
                                        select check as Check).ToList();

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

            //HA checks - for each pool
            var haChecks = (from Host server in SelectedMasters
                            select new HAOffCheck(server) as Check).ToList();

            groups.Add(new CheckGroup(Messages.CHECKING_HA_STATUS, haChecks));

            //Checking can evacuate host - for hosts that will be upgraded or updated
            var evacuateChecks = new List <Check>();

            foreach (Host host in hostsToUpgradeOrUpdate)
            {
                evacuateChecks.Add(new AssertCanEvacuateUpgradeCheck(host));
            }
            groups.Add(new CheckGroup(Messages.CHECKING_CANEVACUATE_STATUS, evacuateChecks));

            //PBDsPluggedCheck -  for hosts that will be upgraded or updated
            var pbdChecks = new List <Check>();

            foreach (Host host in hostsToUpgradeOrUpdate)
            {
                pbdChecks.Add(new PBDsPluggedCheck(host));
            }
            groups.Add(new CheckGroup(Messages.CHECKING_STORAGE_CONNECTIONS_STATUS, pbdChecks));

            //HostMemoryPostUpgradeCheck - for hosts that will be upgraded
            var mostMemoryPostUpgradeChecks = new List <Check>();

            foreach (var host in hostsToUpgrade)
            {
                mostMemoryPostUpgradeChecks.Add(new HostMemoryPostUpgradeCheck(host, InstallMethodConfig));
            }
            if (mostMemoryPostUpgradeChecks.Count > 0)
            {
                groups.Add(new CheckGroup(Messages.CHECKING_HOST_MEMORY_POST_UPGRADE, mostMemoryPostUpgradeChecks));
            }

            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));
            }

            //Checking automated updates are possible if apply updates checkbox is ticked
            if (ApplyUpdatesToNewVersion)
            {
                var automatedUpdateChecks = (from Host server in SelectedMasters
                                             select new AutomatedUpdatesLicenseCheck(server) as Check).ToList();

                automatedUpdateChecks.Add(new CfuAvailabilityCheck());

                groups.Add(new CheckGroup(Messages.CHECKING_AUTOMATED_UPDATES_POSSIBLE,
                                          automatedUpdateChecks));
            }

            return(groups);
        }