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;
            }
        }
Beispiel #2
0
        private void EnabledRow(Host host, UpdateType type, int index)
        {
            var row = (PatchingHostsDataGridViewRow)dataGridViewHosts.Rows[index];

            if (IsInAutomaticMode)
            {
                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_AUTO_UPDATE_NOT_SUPPORTED_PARTIALLY_UPGRADED;

                    return;
                }

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

                if (us == null) //version not supported
                {
                    row.Enabled = false;
                    row.Cells[3].ToolTipText = Messages.PATCHINGWIZARD_SELECTSERVERPAGE_AUTO_UPDATE_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_BATCH_UPDATING;

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

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

            if (poolOfOne != null && poolOfOne.IsPatchingForbidden)
            {
                row.Enabled = false;
                row.Cells[3].ToolTipText = Messages.PATCHINGWIZARD_SELECTSERVERPAGE_PATCHING_FORBIDDEN;
                return;
            }

            if (type != UpdateType.NewSuppPack && !host.CanApplyHotfixes)
            {
                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.NewSuppPack:
                if (!host.CanInstallSuppPack)
                {
                    row.Enabled = false;
                    row.Cells[3].ToolTipText = Messages.PATCHINGWIZARD_SELECTSERVERPAGE_CANNOT_INSTALL_SUPP_PACKS;
                }
                break;
            }
        }