XenAdmin.Wizards.PatchingWizard.PatchingWizard_SelectServers.EnabledRow C# (CSharp) Méthode

EnabledRow() private méthode

private EnabledRow ( XenAPI.Host host, UpdateType type, int index ) : void
host XenAPI.Host
type UpdateType
index int
Résultat void
        private void EnabledRow(Host host, UpdateType type, int index)
        {
            var row = (PatchingHostsDataGridViewRow)dataGridViewHosts.Rows[index];

            var poolOfOne = Helpers.GetPoolOfOne(host.Connection);

            if (IsInAutomaticMode)
            {
                // This check is first because it generally can't be fixed, it's a property of the host
                if (poolOfOne != null && poolOfOne.IsAutoUpdateRestartsForbidden) // Forbids update auto restarts
                {
                    row.Enabled = false;
                    row.Cells[3].ToolTipText = Messages.POOL_FORBIDS_AUTOMATED_UPDATES;
                    return;
                }

                var pool = Helpers.GetPool(host.Connection);
                if (pool != null && !pool.IsPoolFullyUpgraded) //partially upgraded pool is not supported
                {
                    row.Enabled = false;
                    row.Cells[3].ToolTipText = Messages.PATCHINGWIZARD_SELECTSERVERPAGE_AUTOMATED_UPDATES_NOT_SUPPORTED_PARTIALLY_UPGRADED;

                    return;
                }

                //check updgrade sequences
                Updates.UpgradeSequence us = Updates.GetUpgradeSequence(host.Connection);

                if (us == null) //version not supported
                {
                    row.Enabled = false;
                    row.Cells[3].ToolTipText = Messages.PATCHINGWIZARD_SELECTSERVERPAGE_AUTOMATED_UPDATES_NOT_SUPPORTED_HOST_VERSION;

                    return;
                }

                //unlicensed servers are not enabled
                if (Host.RestrictBatchHotfixApply(host))
                {
                    row.Enabled = false;
                    row.Cells[3].ToolTipText = Messages.PATCHINGWIZARD_SELECTSERVERPAGE_HOST_UNLICENSED_FOR_AUTOMATED_UPDATES;

                    return;
                }

                //if there is a host missing from the upgrade sequence
                if (host.Connection.Cache.Hosts.Any(h => !us.Keys.Contains(h)))
                {
                    row.Enabled = false;
                    row.Cells[3].ToolTipText = Messages.PATCHINGWIZARD_SELECTSERVERPAGE_SERVER_NOT_AUTO_UPGRADABLE;

                    return;
                }

                //if all hosts are up-to-date
                if (us.AllHostsUpToDate)
                {
                    row.Enabled = false;
                    row.Cells[3].ToolTipText = Messages.PATCHINGWIZARD_SELECTSERVERPAGE_SERVER_UP_TO_DATE;

                    return;
                }

                return;
            }

            List<Host> selectedHosts = null;
            if (SelectedUpdateAlert != null)
            {
                selectedHosts = SelectedUpdateAlert.DistinctHosts;
            }
            else if (FileFromDiskAlert != null)
            {
                selectedHosts = FileFromDiskAlert.DistinctHosts;
            }

            if (!host.CanApplyHotfixes && (Helpers.ElyOrGreater(host) || type != UpdateType.ISO))
            {
                row.Enabled = false;
                row.Cells[3].ToolTipText = Messages.PATCHINGWIZARD_SELECTSERVERPAGE_HOST_UNLICENSED;
                return;
            }

            switch (type)
            {
                case UpdateType.NewRetail:
                case UpdateType.Existing:
                    disableNotApplicableHosts(row, selectedHosts, host);
                    break;
                case UpdateType.ISO:
                    if (!host.CanInstallSuppPack && !Helpers.ElyOrGreater(host)) //from Ely, iso does not mean supplemental pack
                    {
                        row.Enabled = false;
                        row.Cells[3].ToolTipText = Messages.PATCHINGWIZARD_SELECTSERVERPAGE_CANNOT_INSTALL_SUPP_PACKS;
                    }
                    if (selectedHosts != null)
                    {
                        disableNotApplicableHosts(row, selectedHosts, host);
                    }
                    break;
            }
        }