Esempio n. 1
0
        private void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            lock (_lock)
            {
                Program.Invoke(this, () =>
                {
                    dataGridView1.Rows.Clear();
                    progressBar1.Value = 0;
                    labelProgress.Text = Messages.PATCHING_WIZARD_RUNNING_PRECHECKS;
                });
                Pool_patch  patch  = e.Argument as Pool_patch;
                Pool_update update = e.Argument as Pool_update;

                LivePatchCodesByHost = new Dictionary <string, livepatch_status>();

                List <KeyValuePair <string, List <Check> > > checks = update != null?GenerateChecks(update) : GenerateChecks(patch); //patch is expected to be null for RPU

                _numberChecks = checks.Count;
                for (int i = 0; i < checks.Count; i++)
                {
                    if (_worker.CancellationPending)
                    {
                        e.Cancel = true;
                        return;
                    }

                    List <Check>      checkGroup = checks[i].Value;
                    PreCheckHeaderRow headerRow  =
                        new PreCheckHeaderRow(string.Format(Messages.PATCHING_WIZARD_PRECHECK_STATUS, checks[i].Key));
                    _worker.ReportProgress(5, headerRow);

                    PreCheckResult precheckResult = PreCheckResult.OK;
                    for (int j = 0; j < checkGroup.Count; j++)
                    {
                        if (_worker.CancellationPending)
                        {
                            e.Cancel = true;
                            return;
                        }

                        Check check = checkGroup[j];
                        foreach (PreCheckHostRow row in ExecuteCheck(check))
                        {
                            if (precheckResult != PreCheckResult.Failed && row.Problem != null)
                            {
                                precheckResult = row.PrecheckResult;
                            }
                            _worker.ReportProgress(PercentageSelectedServers(j + 1), row);
                        }
                    }

                    lock (_update_grid_lock)
                    {
                        headerRow.UpdateDescription(precheckResult);
                    }
                }
            }
        }
        private void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            lock (_lock)
            {
                Program.Invoke(this, () =>
                {
                    dataGridView1.Rows.Clear();
                    progressBar1.Value = 0;
                });
                Pool_patch patch = e.Argument as Pool_patch;

                List <KeyValuePair <string, List <Check> > > checks = GenerateChecks(patch);
                _numberChecks = checks.Count;
                for (int i = 0; i < checks.Count; i++)
                {
                    if (_worker.CancellationPending)
                    {
                        e.Cancel = true;
                        return;
                    }

                    List <Check>      checkGroup = checks[i].Value;
                    PreCheckHeaderRow headerRow  =
                        new PreCheckHeaderRow(string.Format(Messages.PATCHING_WIZARD_PRECHECK_STATUS, checks[i].Key));
                    _worker.ReportProgress(5, headerRow);

                    PreCheckResult precheckResult = PreCheckResult.OK;
                    for (int j = 0; j < checkGroup.Count; j++)
                    {
                        if (_worker.CancellationPending)
                        {
                            e.Cancel = true;
                            return;
                        }

                        Check           check = checkGroup[j];
                        PreCheckHostRow row   = ExecuteCheck(check);
                        if (precheckResult != PreCheckResult.Failed && row.Problem != null)
                        {
                            precheckResult = row.IsProblem ? PreCheckResult.Failed : PreCheckResult.Warning;
                        }
                        _worker.ReportProgress(PercentageSelectedServers(j + 1), row);
                    }

                    lock (_update_grid_lock)
                    {
                        headerRow.UpdateDescription(precheckResult);
                    }
                }
            }
        }
        void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            lock (_lock)
            {
                Program.Invoke(this, () =>
                                         {
                                             dataGridView1.Rows.Clear();
                                             progressBar1.Value = 0;
                                         });

                RevertActions.Clear();
                List<KeyValuePair<string, List<Check>>> checks = GenerateChecks();
                _numberChecks = checks.Count;
                for (int i = 0; i < checks.Count; i++)
                {
                    List<Check> checkGroup = checks[i].Value;
                    DataGridViewRow row =
                        new PreCheckHeaderRow(string.Format(Messages.DR_WIZARD_PRECHECKPAGE_HEADER, i + 1,
                                                            checks.Count, checks[i].Key));
                    _worker.ReportProgress(5, row);

                    Session metadataSession = null;

                    // execute checks
                    for (int j = 0; j < checkGroup.Count; j++)
                    {
                        if (_worker.CancellationPending)
                        {
                            e.Cancel = true;
                            return;
                        }
                        Check check = checkGroup[j];

                        // special case - AssertCanBeRecoveredCheck - we need to open the metadata database
                        if (check is AssertCanBeRecoveredCheck)
                        {
                            AssertCanBeRecoveredCheck thisCheck = check as AssertCanBeRecoveredCheck;
                            AssertCanBeRecoveredCheck prevCheck = j > 0
                                                                      ? checkGroup[j - 1] as
                                                                        AssertCanBeRecoveredCheck
                                                                      : null;
                            if (prevCheck == null || prevCheck.Vdi.uuid != thisCheck.Vdi.uuid)
                            {
                                // close previous metadata session
                                if (metadataSession != null)
                                    metadataSession.logout();

                                // open metadata database
                                VdiOpenDatabaseAction action = new VdiOpenDatabaseAction(Connection,
                                                                                         ((AssertCanBeRecoveredCheck
                                                                                          )checkGroup[0]).Vdi);
                                action.RunExternal(action.Session);
                                if (action.Succeeded && action.MetadataSession != null)
                                    metadataSession = action.MetadataSession;
                            }

                            // run check
                            if (metadataSession != null)
                            {
                                thisCheck.MetadataSession = metadataSession;
                                row = ExecuteCheck(thisCheck);
                                _worker.ReportProgress(PercentageSelectedObjects(j + 1), row);

                                // close metadata session if this is the last check
                                if (j == checkGroup.Count - 1)
                                    metadataSession.logout();
                            }
                        }
                        else
                        {
                            row = ExecuteCheck(check);
                            _worker.ReportProgress(PercentageSelectedObjects(j + 1), row);
                        }
                    }
                }
            }
        }
        private void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            var bgw = sender as BackgroundWorker;

            if (bgw == null)
            {
                return;
            }

            lock (_lock)
            {
                bgw.ReportProgress(0, null);
                Program.Invoke(this, () =>
                {
                    dataGridView1.Rows.Clear();
                    labelProgress.Text = Messages.PATCHING_WIZARD_RUNNING_PRECHECKS;
                    OnPageUpdated();
                });
                Pool_patch  patch  = e.Argument as Pool_patch;
                Pool_update update = e.Argument as Pool_update;

                LivePatchCodesByHost = new Dictionary <string, livepatch_status>();

                // Note: represent the groups as list so as to enforce the order of checks;
                // a dictionary that looks sensible from a first look is not guranteed to
                // keep the order, especially if items are removed (although not the case here)
                var groups = update != null?GenerateChecks(update) : GenerateChecks(patch);   //patch is expected to be null for RPU

                int totalChecks    = groups.Sum(c => c.Value == null ? 0 : c.Value.Count);
                int doneCheckIndex = 0;

                allRows.Clear();

                foreach (var group in groups)
                {
                    if (bgw.CancellationPending)
                    {
                        e.Cancel = true;
                        return;
                    }

                    var headerRow = new PreCheckHeaderRow(string.Format(Messages.PATCHING_WIZARD_PRECHECK_STATUS, group.Key));
                    //multiply with 100 first, otherwise the quotient is 0
                    bgw.ReportProgress(doneCheckIndex * 100 / totalChecks, headerRow);

                    PreCheckResult precheckResult = PreCheckResult.OK;
                    var            checks         = group.Value;

                    foreach (var check in checks)
                    {
                        if (bgw.CancellationPending)
                        {
                            e.Cancel = true;
                            return;
                        }

                        var rows = ExecuteCheck(check);
                        doneCheckIndex++;

                        foreach (PreCheckHostRow row in rows)
                        {
                            if (precheckResult != PreCheckResult.Failed && row.Problem != null)
                            {
                                precheckResult = row.PrecheckResult;
                            }

                            //multiply with 100 first, otherwise the quotient is 0
                            bgw.ReportProgress(doneCheckIndex * 100 / totalChecks, row);
                        }
                    }

                    lock (_update_grid_lock)
                    {
                        headerRow.UpdateDescription(precheckResult);
                    }
                }
            }
        }
        private void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            lock (_lock)
            {
                Program.Invoke(this, () =>
                                         {
                                             dataGridView1.Rows.Clear();
                                             progressBar1.Value = 0;
                                         });
                Pool_patch patch = e.Argument as Pool_patch;

                List<KeyValuePair<string, List<Check>>> checks = GenerateChecks(patch);
                _numberChecks = checks.Count;
                for (int i = 0; i < checks.Count; i++)
                {
                    if (_worker.CancellationPending)
                    {
                        e.Cancel = true;
                        return;
                    }

                    List<Check> checkGroup = checks[i].Value;
                    PreCheckHeaderRow headerRow =
                        new PreCheckHeaderRow(string.Format(Messages.PATCHING_WIZARD_PRECHECK_STATUS, checks[i].Key));
                    _worker.ReportProgress(5, headerRow);

                    PreCheckResult precheckResult = PreCheckResult.OK;
                    for (int j = 0; j < checkGroup.Count; j++)
                    {
                        if (_worker.CancellationPending)
                        {
                            e.Cancel = true;
                            return;
                        }

                        Check check = checkGroup[j];
                        PreCheckHostRow row = ExecuteCheck(check);
                        if (precheckResult != PreCheckResult.Failed && row.Problem != null)
                            precheckResult = row.IsProblem ? PreCheckResult.Failed : PreCheckResult.Warning;
                        _worker.ReportProgress(PercentageSelectedServers(j + 1), row);
                    }

                    lock (_update_grid_lock)
                    {
                        headerRow.UpdateDescription(precheckResult);
                    }
                }
            }
        }
        void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            lock (_lock)
            {
                Program.Invoke(this, () =>
                {
                    dataGridView1.Rows.Clear();
                    progressBar1.Value = 0;
                });

                RevertActions.Clear();
                List <KeyValuePair <string, List <Check> > > checks = GenerateChecks();
                _numberChecks = checks.Count;
                for (int i = 0; i < checks.Count; i++)
                {
                    List <Check>    checkGroup = checks[i].Value;
                    DataGridViewRow row        =
                        new PreCheckHeaderRow(string.Format(Messages.DR_WIZARD_PRECHECKPAGE_HEADER, i + 1,
                                                            checks.Count, checks[i].Key));
                    _worker.ReportProgress(5, row);

                    Session metadataSession = null;

                    // execute checks
                    for (int j = 0; j < checkGroup.Count; j++)
                    {
                        if (_worker.CancellationPending)
                        {
                            e.Cancel = true;
                            return;
                        }
                        Check check = checkGroup[j];

                        // special case - AssertCanBeRecoveredCheck - we need to open the metadata database
                        if (check is AssertCanBeRecoveredCheck)
                        {
                            AssertCanBeRecoveredCheck thisCheck = check as AssertCanBeRecoveredCheck;
                            AssertCanBeRecoveredCheck prevCheck = j > 0
                                                                      ? checkGroup[j - 1] as
                                                                  AssertCanBeRecoveredCheck
                                                                      : null;
                            if (prevCheck == null || prevCheck.Vdi.uuid != thisCheck.Vdi.uuid)
                            {
                                // close previous metadata session
                                if (metadataSession != null)
                                {
                                    metadataSession.logout();
                                }

                                // open metadata database
                                VdiOpenDatabaseAction action = new VdiOpenDatabaseAction(Connection,
                                                                                         ((AssertCanBeRecoveredCheck
                                                                                           )checkGroup[0]).Vdi);
                                action.RunExternal(action.Session);
                                if (action.Succeeded && action.MetadataSession != null)
                                {
                                    metadataSession = action.MetadataSession;
                                }
                            }

                            // run check
                            if (metadataSession != null)
                            {
                                thisCheck.MetadataSession = metadataSession;
                                row = ExecuteCheck(thisCheck);
                                _worker.ReportProgress(PercentageSelectedObjects(j + 1), row);

                                // close metadata session if this is the last check
                                if (j == checkGroup.Count - 1)
                                {
                                    metadataSession.logout();
                                }
                            }
                        }
                        else
                        {
                            row = ExecuteCheck(check);
                            _worker.ReportProgress(PercentageSelectedObjects(j + 1), row);
                        }
                    }
                }
            }
        }
        private void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            lock (_lock)
            {
                Program.Invoke(this, () =>
                                         {
                                             dataGridView1.Rows.Clear();
                                             progressBar1.Value = 0;
                                             labelProgress.Text = Messages.PATCHING_WIZARD_RUNNING_PRECHECKS;
                                         });
                Pool_patch patch = e.Argument as Pool_patch;
                Pool_update update = e.Argument as Pool_update;

                LivePatchCodesByHost = new Dictionary<string, livepatch_status>();

                List<KeyValuePair<string, List<Check>>> checks = update != null ? GenerateChecks(update) : GenerateChecks(patch); //patch is expected to be null for RPU
                _numberChecks = checks.Count;
                for (int i = 0; i < checks.Count; i++)
                {
                    if (_worker.CancellationPending)
                    {
                        e.Cancel = true;
                        return;
                    }

                    List<Check> checkGroup = checks[i].Value;
                    PreCheckHeaderRow headerRow =
                        new PreCheckHeaderRow(string.Format(Messages.PATCHING_WIZARD_PRECHECK_STATUS, checks[i].Key));
                    _worker.ReportProgress(5, headerRow);

                    PreCheckResult precheckResult = PreCheckResult.OK;
                    for (int j = 0; j < checkGroup.Count; j++)
                    {
                        if (_worker.CancellationPending)
                        {
                            e.Cancel = true;
                            return;
                        }

                        Check check = checkGroup[j];
                        foreach (PreCheckHostRow row in ExecuteCheck(check))
                        {
                            if (precheckResult != PreCheckResult.Failed && row.Problem != null)
                                precheckResult = row.PrecheckResult;
                            _worker.ReportProgress(PercentageSelectedServers(j + 1), row);
                        }
                    }

                    lock (_update_grid_lock)
                    {
                        headerRow.UpdateDescription(precheckResult);
                    }
                }
            }
        }