private HostPlan GetSubTasksFor(Host host)
        {
            var runningVMs = host.GetRunningVMs();

            UpgradeHostPlanAction upgradeAction;

            if (ManualModeSelected)
            {
                upgradeAction = new UpgradeManualHostPlanAction(host, this);
            }
            else
            {
                upgradeAction = new UpgradeAutomatedHostPlanAction(host, this, InstallMethodConfig);
            }

            var initialPlanActions = new List <PlanAction>()
            {
                new EvacuateHostPlanAction(host),
                upgradeAction,
                new BringBabiesBackAction(runningVMs, host, true)
            };

            return(new HostPlan(host, initialPlanActions, null, new List <PlanAction>()));
        }
Exemple #2
0
        private void ManageSemiAutomaticPlanAction(UpgradeManualHostPlanAction planAction)
        {
            if (UpgradeStatus == RollingUpgradeStatus.Cancelled)
            {
                return;
            }

            var upgradeHostPlanAction = planAction;
            //Show dialog prepare host boot from CD or PXE boot and click OK to reboot
            string msg = string.Format(Messages.ROLLING_UPGRADE_REBOOT_MESSAGE, planAction.Host.Name());

            UpgradeManualHostPlanAction action = upgradeHostPlanAction;

            Program.Invoke(this, () =>
            {
                using (Dialog = new NotModalThreeButtonDialog(SystemIcons.Information, msg, Messages.REBOOT, Messages.SKIP_SERVER))
                {
                    Dialog.ShowDialog(this);

                    if (Dialog.DialogResult != DialogResult.OK) // Cancel or Unknown
                    {
                        completedTitleLabel = Messages.ROLLING_UPGRADE_UPGRADE_NOT_COMPLETED;
                        if (action.Host.IsMaster())
                        {
                            throw new ApplicationException(Messages.EXCEPTION_USER_CANCELLED_MASTER);
                        }

                        throw new ApplicationException(Messages.EXCEPTION_USER_CANCELLED);
                    }
                }
            });
            string beforeRebootProductVersion = upgradeHostPlanAction.Host.LongProductVersion();
            string hostName = upgradeHostPlanAction.Host.Name();

            upgradeHostPlanAction.Timeout += new EventHandler(upgradeHostPlanAction_Timeout);
            try
            {
                do
                {
                    if (UpgradeStatus == RollingUpgradeStatus.Cancelled)
                    {
                        break;
                    }

                    //Reboot with timeout of 20 min
                    upgradeHostPlanAction.Run();

                    //if comes back and does not have a different product version
                    if (Helpers.SameServerVersion(upgradeHostPlanAction.Host, beforeRebootProductVersion))
                    {
                        using (var dialog = new NotModalThreeButtonDialog(SystemIcons.Exclamation,
                                                                          string.Format(Messages.ROLLING_UPGRADE_REBOOT_AGAIN_MESSAGE, hostName)
                                                                          , Messages.REBOOT_AGAIN_BUTTON_LABEL, Messages.SKIP_SERVER))
                        {
                            Program.Invoke(this, () => dialog.ShowDialog(this));
                            if (dialog.DialogResult != DialogResult.OK) // Cancel or Unknown
                            {
                                throw new Exception(Messages.HOST_REBOOTED_SAME_VERSION);
                            }
                            else
                            {
                                upgradeHostPlanAction = new UpgradeManualHostPlanAction(upgradeHostPlanAction.Host);
                            }
                        }
                    }
                } while (Helpers.SameServerVersion(upgradeHostPlanAction.Host, beforeRebootProductVersion));
            }
            finally
            {
                upgradeHostPlanAction.Timeout -= new EventHandler(upgradeHostPlanAction_Timeout);
            }
        }