Ejemplo n.º 1
0
        private void PrepareUploadActions()
        {
            OnPageUpdated();
            SuppPackVdis.Clear();
            uploadActions.Clear();

            //Upload the patches to the masters if it is necessary
            List <Host> masters = SelectedMasters;

            foreach (Host selectedServer in masters)
            {
                AsyncAction action = null;
                switch (SelectedUpdateType)
                {
                case UpdateType.Legacy:
                    if (CanUploadUpdateOnHost(SelectedNewPatchPath, selectedServer))
                    {
                        bool deleteFileOnCancel = AllDownloadedPatches.ContainsValue(SelectedNewPatchPath);
                        action = new UploadPatchAction(selectedServer.Connection, SelectedNewPatchPath, true, deleteFileOnCancel);
                    }
                    break;

                case UpdateType.ISO:
                    if (CanUploadUpdateOnHost(SelectedNewPatchPath, selectedServer))
                    {
                        _poolUpdate = null;
                        _patch      = null;

                        action = new UploadSupplementalPackAction(
                            selectedServer.Connection,
                            SelectedServers.Where(s => s.Connection == selectedServer.Connection).ToList(),
                            SelectedNewPatchPath,
                            true);
                    }
                    break;
                }
                if (action != null)
                {
                    action.Changed   += singleAction_Changed;
                    action.Completed += singleAction_Completed;
                }
                else
                {
                    _poolUpdate = GetUpdateFromUpdatePath();
                    _patch      = GetPatchFromPatchPath();
                }
                uploadActions.Add(selectedServer, action);
            }

            foreach (KeyValuePair <Host, AsyncAction> uploadAction in uploadActions)
            {
                flickerFreeListBox1.Items.Add(uploadAction);
            }

            flickerFreeListBox1.Refresh();
            OnPageUpdated();
        }
Ejemplo n.º 2
0
        private void PrepareUploadActions()
        {
            OnPageUpdated();
            SuppPackVdis.Clear();
            uploadActions.Clear();

            //Upload the patches to the masters if it is necessary
            List <Host> masters = SelectedMasters;

            foreach (Host selectedServer in masters)
            {
                AsyncAction action = null;
                switch (SelectedUpdateType)
                {
                case UpdateType.NewRetail:
                    if (_patch == null || !PatchExistsOnPool(_patch, selectedServer))
                    {
                        action = new UploadPatchAction(selectedServer.Connection, SelectedNewPatch, true);
                    }
                    break;

                case UpdateType.Existing:
                    if (!PatchExistsOnPool(_patch, selectedServer))
                    {
                        //Download patch from server Upload in the selected server
                        action = new CopyPatchFromHostToOther(SelectedExistingPatch.Connection, selectedServer,
                                                              SelectedExistingPatch);
                    }
                    break;

                case UpdateType.NewSuppPack:
                    action = new UploadSupplementalPackAction(
                        selectedServer.Connection,
                        SelectedServers.Where(s => s.Connection == selectedServer.Connection).ToList(),
                        SelectedNewPatch,
                        true);
                    break;
                }
                if (action != null)
                {
                    action.Changed   += singleAction_Changed;
                    action.Completed += singleAction_Completed;
                }
                uploadActions.Add(selectedServer, action);
            }

            foreach (KeyValuePair <Host, AsyncAction> uploadAction in uploadActions)
            {
                flickerFreeListBox1.Items.Add(uploadAction);
            }

            flickerFreeListBox1.Refresh();
            OnPageUpdated();
        }
Ejemplo n.º 3
0
        protected override List <HostPlan> GenerateHostPlans(Pool pool, out List <Host> applicableHosts)
        {
            var master      = Helpers.GetMaster(pool);
            var planActions = new List <PlanAction>();

            var alertPatch = SelectedUpdateAlert == null ? null : SelectedUpdateAlert.Patch;

            bool download = alertPatch != null && PatchFromDisk.Key == null &&
                            (!AllDownloadedPatches.ContainsKey(alertPatch) || !File.Exists(AllDownloadedPatches[alertPatch]));

            if (download)
            {
                planActions.Add(new DownloadPatchPlanAction(master.Connection, alertPatch, AllDownloadedPatches, PatchFromDisk));
            }

            var skipDiskSpaceCheck = SelectedUpdateType != UpdateType.Legacy ||
                                     Helpers.ElyOrGreater(master.Connection); //this is superfluous; just added for completeness

            if (alertPatch != null)
            {
                planActions.Add(new UploadPatchToMasterPlanAction(this, master.Connection, alertPatch,
                                                                  PatchMappings, AllDownloadedPatches, PatchFromDisk, skipDiskSpaceCheck));
            }
            else if (!string.IsNullOrEmpty(SelectedPatchFilePath))
            {
                var servers = SelectedServers.Where(s => s.Connection == master.Connection).ToList();
                planActions.Add(new UploadPatchToMasterPlanAction(this, master.Connection, servers, SelectedPatchFilePath,
                                                                  SelectedUpdateType, PatchMappings, skipDiskSpaceCheck));
            }

            var hostPlan = new HostPlan(master, null, planActions, null);

            applicableHosts = new List <Host> {
                master
            };
            return(new List <HostPlan> {
                hostPlan
            });
        }
Ejemplo n.º 4
0
        private Dictionary <Pool, StringBuilder> ModePoolUpdate(out bool someHostMayRequireRestart)
        {
            someHostMayRequireRestart = false;

            if (PoolUpdate == null || PoolUpdate.after_apply_guidance == null || PoolUpdate.after_apply_guidance.Count == 0)
            {
                return(null);
            }

            var applicableServers = SelectedServers.Where(h => !PoolUpdate.AppliedOn(h)).ToList();
            var serversPerPool    = GroupServersPerPool(SelectedPools, applicableServers);

            var total = new Dictionary <Pool, StringBuilder>();

            foreach (var guide in PoolUpdate.after_apply_guidance)
            {
                var result = GetGuidanceList(guide, serversPerPool, LivePatchCodesByHost, out someHostMayRequireRestart);
                if (result == null)
                {
                    continue;
                }
                foreach (var kvp in result)
                {
                    if (total.ContainsKey(kvp.Key))
                    {
                        total[kvp.Key].Append(kvp.Value).AppendLine();
                    }
                    else
                    {
                        total[kvp.Key] = kvp.Value;
                    }
                }
            }

            return(total);
        }
Ejemplo n.º 5
0
        public override void PageLoaded(PageLoadedDirection direction)
        {
            base.PageLoaded(direction);

            if (_thisPageHasBeenCompleted)
            {
                actionsWorker = null;
                return;
            }

            if (!IsAutomaticMode)
            {
                textBoxLog.Text = ManualTextInstructions;

                List <AsyncAction> actions = new List <AsyncAction>();

                if (SelectedUpdateType == UpdateType.ISO && PoolUpdate != null)
                {
                    //Ely or greater: iso update format
                    foreach (var server in SelectedServers)
                    {
                        actions.Add(new ApplyUpdateAction(PoolUpdate, server));
                    }
                }
                else
                {
                    //legacy mode
                    if (SelectedUpdateType != UpdateType.ISO)
                    {
                        foreach (var server in SelectedServers)
                        {
                            actions.Add(new ApplyPatchAction(Patch, server));
                        }
                    }
                    else
                    {
                        actions.Add(new InstallSupplementalPackAction(SuppPackVdis, false));
                    }
                }

                if (RemoveUpdateFile && SelectedUpdateType != UpdateType.ISO)
                {
                    foreach (Pool pool in SelectedPools)
                    {
                        actions.Add(new PoolPatchCleanAction(pool, Patch, false));
                    }
                }

                using (var multipleAction = new MultipleAction(Connection, "", "", "", actions, true, true, true))
                {
                    multipleAction.Changed   += action_Changed;
                    multipleAction.Completed += action_Completed;
                    multipleAction.RunAsync();
                }
                return;
            }

            _nextEnabled = false;
            OnPageUpdated();

            List <PlanAction> planActions = new List <PlanAction>();

            foreach (Pool pool in SelectedPools)
            {
                var  poolHosts = new List <Host>(pool.Connection.Cache.Hosts);
                Host master    = SelectedServers.Find(host => host.IsMaster() && poolHosts.Contains(host));

                //For Ely or greater: ISO updates only
                if (SelectedUpdateType == UpdateType.ISO && Helpers.ElyOrGreater(pool.Connection)) //updates for Ely (or higher) are always ISO
                {
                    var poolUpdates = new List <Pool_update>(pool.Connection.Cache.Pool_updates);
                    var poolUpdate  = poolUpdates.FirstOrDefault(u => u != null && string.Equals(u.uuid, PoolUpdate.uuid, StringComparison.OrdinalIgnoreCase));

                    //master first
                    if (master != null && !poolUpdate.AppliedOn(master))
                    {
                        planActions.AddRange(CompilePoolUpdateActionList(master, poolUpdate));
                    }

                    //other hosts
                    foreach (var host in SelectedServers.Where(s => poolHosts.Contains(s) && !s.IsMaster() && !poolUpdate.AppliedOn(s)).ToList())
                    {
                        planActions.AddRange(CompilePoolUpdateActionList(host, poolUpdate));
                    }
                }
                // Legacy (pre-Ely) case: either ISO for supplemental packs (Pool_patch == null) or patch (Pool_patch != null)
                else
                {
                    Pool_patch poolPatch = null;

                    if (SelectedUpdateType != UpdateType.ISO)
                    {
                        List <Pool_patch> poolPatches = new List <Pool_patch>(pool.Connection.Cache.Pool_patches);

                        poolPatch = poolPatches.Find(delegate(Pool_patch otherPatch)
                        {
                            if (Patch != null)
                            {
                                return(string.Equals(otherPatch.uuid, Patch.uuid, StringComparison.OrdinalIgnoreCase));
                            }
                            return(false);
                        });
                    }

                    //master first
                    if (master != null && (poolPatch == null || poolPatch.AppliedOn(master) == DateTime.MaxValue))
                    {
                        planActions.AddRange(CompileActionList(master, poolPatch));
                    }

                    foreach (Host server in SelectedServers)
                    {
                        if (poolHosts.Contains(server))
                        {
                            if (!server.IsMaster())
                            {
                                // check patch isn't already applied here
                                if (poolPatch == null || poolPatch.AppliedOn(server) == DateTime.MaxValue)
                                {
                                    planActions.AddRange(CompileActionList(server, poolPatch));
                                }
                            }
                        }
                    }

                    if (RemoveUpdateFile)
                    {
                        planActions.Add(new RemoveUpdateFile(pool, poolPatch));
                    }
                }
            } //end pool in foreach

            planActions.Add(new UnwindProblemsAction(ProblemsResolvedPreCheck));

            actionsWorker         = new BackgroundWorker();
            actionsWorker.DoWork += new DoWorkEventHandler(PatchingWizardAutomaticPatchWork);
            actionsWorker.WorkerReportsProgress      = true;
            actionsWorker.ProgressChanged           += new ProgressChangedEventHandler(actionsWorker_ProgressChanged);
            actionsWorker.RunWorkerCompleted        += new RunWorkerCompletedEventHandler(actionsWorker_RunWorkerCompleted);
            actionsWorker.WorkerSupportsCancellation = true;
            actionsWorker.RunWorkerAsync(planActions);
        }
        protected override List <CheckGroup> GenerateChecks(Pool_patch patch)
        {
            var groups = new List <CheckGroup>();

            //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 &&
                SelectedServers.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
            var livenessChecks = new List <Check>();

            foreach (Host host in SelectedServers)
            {
                livenessChecks.Add(new HostMaintenanceModeCheck(host));
            }

            groups.Add(new CheckGroup(Messages.CHECKING_HOST_LIVENESS_STATUS, livenessChecks));

            //HA checks
            var haChecks = new List <Check>();

            foreach (Pool pool in SelectedPools)
            {
                Host host = pool.Connection.Resolve(pool.master);

                if (host == null)
                {
                    continue;
                }

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

            //Checking can evacuate host
            var evacuateChecks = new List <Check>();

            foreach (Host host in SelectedServers)
            {
                evacuateChecks.Add(new AssertCanEvacuateUpgradeCheck(host));
            }

            groups.Add(new CheckGroup(Messages.CHECKING_CANEVACUATE_STATUS, evacuateChecks));

            //PBDsPluggedCheck
            var pbdChecks = new List <Check>();

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


            //HotfixesCheck required for MNR, Cowley, Boston and Sanibel
            var hotfixChecks = new List <Check>();

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


            //iSL (StorageLink) check - CA-223486: only for pre-Creedence
            var preCreedenceServers = SelectedServers.Where(h => !Helpers.CreedenceOrGreater(h)).ToList();

            if (preCreedenceServers.Any())
            {
                var srLinkChecks = new List <Check>();
                foreach (Host host in preCreedenceServers)
                {
                    srLinkChecks.Add(new HostHasUnsupportedStorageLinkSRCheck(host));
                }
                groups.Add(new CheckGroup(Messages.CHECKING_STORAGELINK_STATUS, srLinkChecks));
            }

            //SafeToUpgradeCheck - in automatic mode only
            if (!ManualUpgrade)
            {
                var upgradeChecks = new List <Check>();
                foreach (Host host in SelectedServers)
                {
                    upgradeChecks.Add(new SafeToUpgradeCheck(host));
                }

                groups.Add(new CheckGroup(Messages.CHECKING_SAFE_TO_UPGRADE, upgradeChecks));
            }

            return(groups);
        }
        protected override List <KeyValuePair <string, List <Check> > > GenerateChecks(Pool_patch patch)
        {
            List <KeyValuePair <string, List <Check> > > checks = new List <KeyValuePair <string, List <Check> > >();

            //HostMaintenanceModeCheck checks
            checks.Add(new KeyValuePair <string, List <Check> >(Messages.CHECKING_HOST_LIVENESS_STATUS, new List <Check>()));
            List <Check> checkGroup = checks[checks.Count - 1].Value;

            foreach (Host host in SelectedServers)
            {
                checkGroup.Add(new HostMaintenanceModeCheck(host));
            }

            //HA checks
            checks.Add(new KeyValuePair <string, List <Check> >(Messages.CHECKING_HA_STATUS, new List <Check>()));
            checkGroup = checks[checks.Count - 1].Value;
            foreach (Pool pool in SelectedPools)
            {
                Host host = pool.Connection.Resolve(pool.master);

                if (host == null)
                {
                    continue;
                }

                checkGroup.Add(new HAOffCheck(host));
            }

            //Checking can evacuate host
            checks.Add(new KeyValuePair <string, List <Check> >(Messages.CHECKING_CANEVACUATE_STATUS, new List <Check>()));
            checkGroup = checks[checks.Count - 1].Value;
            foreach (Host host in SelectedServers)
            {
                checkGroup.Add(new AssertCanEvacuateUpgradeCheck(host));
            }

            //PBDsPluggedCheck
            checks.Add(new KeyValuePair <string, List <Check> >(Messages.CHECKING_STORAGE_CONNECTIONS_STATUS, new List <Check>()));
            checkGroup = checks[checks.Count - 1].Value;
            foreach (Host host in SelectedServers)
            {
                checkGroup.Add(new PBDsPluggedCheck(host));
            }


            //HotfixesCheck required for MNR, Cowley, Boston and Sanibel
            bool titleAdded = false;

            foreach (var host in SelectedServers)
            {
                if (new HotfixFactory().IsHotfixRequired(host) && !ManualUpgrade)
                {
                    if (!titleAdded)
                    {
                        checks.Add(new KeyValuePair <string, List <Check> >(Messages.CHECKING_UPGRADE_HOTFIX_STATUS,
                                                                            new List <Check>()));
                        checkGroup = checks[checks.Count - 1].Value;
                        titleAdded = true;
                    }
                    checkGroup.Add(new HostHasHotfixCheck(host));
                }
            }

            //iSL (StorageLink) check - CA-223486: only for pre-Creedence
            var preCreedenceServers = SelectedServers.Where(h => !Helpers.CreedenceOrGreater(h)).ToList();

            if (preCreedenceServers.Any())
            {
                checks.Add(new KeyValuePair <string, List <Check> >(Messages.CHECKING_STORAGELINK_STATUS, new List <Check>()));
                checkGroup = checks[checks.Count - 1].Value;
                foreach (Host host in preCreedenceServers)
                {
                    checkGroup.Add(new HostHasUnsupportedStorageLinkSRCheck(host));
                }
            }

            //SafeToUpgradeCheck - in automatic mode only
            if (!ManualUpgrade)
            {
                checks.Add(new KeyValuePair <string, List <Check> >(Messages.CHECKING_SAFE_TO_UPGRADE, new List <Check>()));
                checkGroup = checks[checks.Count - 1].Value;

                foreach (Host host in SelectedServers)
                {
                    checkGroup.Add(new SafeToUpgradeCheck(host));
                }
            }

            return(checks);
        }