Exemplo n.º 1
0
        private void SummeryInfoCheck()
        {
            String str_rules = "";
            String str_job   = "";
            String c         = "";

            BackupRestoreConfig.BrSchedule schedule = new BackupRestoreConfig.BrSchedule();
            schedule.current_full_count = 0;
            if (this.scheduleBackupPage.NowRadioButtonIsChecked())
            {
                schedule.jobName      = this.optionsBackupPage._JobNameTextBox;
                schedule.scheduleType = 0;
                schedule.scheduleDate = "";
                str_rules             = HalsignUtil.ToJson(schedule);
            }
            if (this.scheduleBackupPage.OnceRadioButtonIsChecked() && !this.scheduleBackupPage.IsFullBackup)
            {
                schedule.jobName      = this.optionsBackupPage._JobNameTextBox;
                schedule.scheduleType = 1;
                schedule.scheduleDate = this.scheduleBackupPage.StartDatePickerText;
                schedule.scheduleTime = this.scheduleBackupPage.StartTimePickerText;
                str_rules             = HalsignUtil.ToJson(schedule);
                c = "s";
            }

            if (this.scheduleBackupPage.OnceRadioButtonIsChecked() && this.scheduleBackupPage.IsFullBackup)
            {
                schedule.jobName      = this.optionsBackupPage._JobNameTextBox;
                schedule.scheduleType = 5;
                schedule.scheduleDate = this.scheduleBackupPage.StartDatePickerText;
                schedule.scheduleTime = this.scheduleBackupPage.StartTimePickerText;
                str_rules             = HalsignUtil.ToJson(schedule);
                c = "q";
            }

            if (this.scheduleBackupPage.DailyRadioButtonIsChecked())
            {
                schedule.jobName           = this.optionsBackupPage._JobNameTextBox;
                schedule.scheduleType      = 2;
                schedule.scheduleDate      = this.scheduleBackupPage.StartDatePickerText;
                schedule.scheduleTime      = this.scheduleBackupPage.StartTimePickerText;
                schedule.recur             = this.scheduleBackupPage._RecurTextBox == "" ? 0 : Int32.Parse(this.scheduleBackupPage._RecurTextBox);
                schedule.expect_full_count = this.scheduleBackupPage._expectFullCheckBox?this.scheduleBackupPage._expectFullCountTextBox:0;
                str_rules = HalsignUtil.ToJson(schedule);
                c         = "t";
            }
            if (this.scheduleBackupPage.CircleRadioButtonIsChecked())
            {
                schedule.jobName           = this.optionsBackupPage._JobNameTextBox;
                schedule.scheduleType      = 4;
                schedule.scheduleDate      = this.scheduleBackupPage.StartDatePickerText;
                schedule.scheduleTime      = this.scheduleBackupPage.StartTimePickerText;
                schedule.recur             = this.scheduleBackupPage._RecurTextBox == "" ? 1 : Int32.Parse(this.scheduleBackupPage._RecurTextBox);
                schedule.expect_full_count = this.scheduleBackupPage._expectFullCheckBox ? this.scheduleBackupPage._expectFullCountTextBox : 0;
                str_rules = HalsignUtil.ToJson(schedule);
                c         = "h";
            }
            if (this.scheduleBackupPage.WeeklyRadioButtonIsChecked())
            {
                schedule.jobName      = this.optionsBackupPage._JobNameTextBox;
                schedule.scheduleType = 3;
                schedule.scheduleDate = this.scheduleBackupPage.StartDatePickerText;
                schedule.scheduleTime = this.scheduleBackupPage.StartTimePickerText;
                c = "w";
                schedule.recur             = this.scheduleBackupPage._RecurTextBox == "" ? 0 : Int32.Parse(this.scheduleBackupPage._RecurTextBox);
                schedule.expect_full_count = this.scheduleBackupPage._expectFullCheckBox ? this.scheduleBackupPage._expectFullCountTextBox : 0;
                List <int> list = new List <int>();
                if (this.scheduleBackupPage._MondayCheckBoxIsChecked())
                {
                    list.Add(1);
                }
                if (this.scheduleBackupPage._TuesdayCheckBoxIsChecked())
                {
                    list.Add(2);
                }
                if (this.scheduleBackupPage._WednesdayCheckBoxIsChecked())
                {
                    list.Add(3);
                }
                if (this.scheduleBackupPage._ThursdayCheckBoxIsChecked())
                {
                    list.Add(4);
                }
                if (this.scheduleBackupPage._FridayCheckBoxIsChecked())
                {
                    list.Add(5);
                }
                if (this.scheduleBackupPage._SaturdayCheckBoxIsChecked())
                {
                    list.Add(6);
                }
                if (this.scheduleBackupPage._SundayCheckBoxIsChecked())
                {
                    list.Add(0);
                }
                schedule.weeklyDays = list;
                str_rules           = HalsignUtil.ToJson(schedule);
            }
            str_rules = str_rules.Replace("\\/", "/");

            if (!c.Equals(""))
            {
                BackupRestoreConfig.Job job = new BackupRestoreConfig.Job();
                job.job_name = this.optionsBackupPage._JobNameTextBox;
                job.host     = "";
                job.key      = "halsign_br_job_s";
                job.request  = c + this.optionsBackupPage._JobNameTextBox.TrimEnd().TrimStart() + "|";
                TimeSpan ts = DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1, 0, 0, 0));
                ts = new DateTime(this.scheduleBackupPage.StartDatePickerValue.Year, this.scheduleBackupPage.StartDatePickerValue.Month,
                                  this.scheduleBackupPage.StartDatePickerValue.Day, this.scheduleBackupPage.StartTimePickerValue.Hour, this.scheduleBackupPage.StartTimePickerValue.Minute,
                                  this.scheduleBackupPage.StartTimePickerValue.Second).Subtract(new DateTime(1970, 1, 1, 0, 0, 0).ToLocalTime());
                job.start_time         = "";
                job.progress           = -1;
                job.total_storage      = -1;
                job.modify_time        = "";
                job.pid                = -1;
                job.retry              = -1;
                job.speed              = -1;
                job.status             = 0;
                job.current_full_count = 0;
                if (c.Equals("s"))
                {
                    job.schedule_type = 1;
                }
                else if (c.Equals("q"))
                {
                    job.schedule_type = 5;
                }
                else if (c.Equals("t"))
                {
                    job.schedule_type = 2;
                }
                else if (c.Equals("h"))
                {
                    job.schedule_type = 4;
                }
                else if (c.Equals("w"))
                {
                    job.schedule_type = 3;
                }
                job.expect_full_count = this.scheduleBackupPage.IsFullBackup ? 0 : (this.scheduleBackupPage._expectFullCheckBox ? this.scheduleBackupPage._expectFullCountTextBox : 0);
                str_job = HalsignUtil.ToJson(job);
            }
            Dictionary <string, string> _dconf = new Dictionary <string, string>();

            _dconf.Add("job_name", this.optionsBackupPage._JobNameTextBox.TrimEnd().TrimStart());
            //_dconf.Add("command", this.optionsBackupPage.IsFullBackup ? "b" : "i");
            _dconf.Add("command", this.scheduleBackupPage.IsFullBackup ? "b" : "i");
            _dconf.Add("is_now", this.scheduleBackupPage.NowRadioButtonIsChecked().ToString());
            _dconf.Add("backup_rules", str_rules);
            _dconf.Add("backup_job", str_job);

            BackupAction action = new BackupAction(Messages.BACKUP_VM, BackupRestoreConfig.BackupActionKind.Backup, this._xenModelObject, this.vmCheckedList, _dconf, this.vdi_dictionary);

            if (action != null)
            {
                ProgressBarStyle     progressBarStyle = ProgressBarStyle.Marquee;
                ActionProgressDialog dialog           = new ActionProgressDialog(action, progressBarStyle);
                dialog.ShowCancel = false;
                dialog.ShowDialog(this);
                if (!action.Succeeded || !string.IsNullOrEmpty(action.Result))
                {
                    base.FinishCanceled();
                }
                else
                {
                    base.FinishWizard();
                }
            }

            if (!(this._xenModelObject is Host))
            {
                // todo Program.MainWindow.SwitchToTab(MainWindow.Tab.BR);
                if (this._xenModelObject is VM)
                {
                    VM vm = this._xenModelObject as VM;
                    vm.NotifyPropertyChanged("other_config");
                }
            }
        }
Exemplo n.º 2
0
        private void ToolStripMenuItemDownload_Click(object sender, EventArgs e)
        {
            DataGridViewRow clickedRow = FindAlertRow(sender as ToolStripMenuItem);

            if (clickedRow == null)
            {
                return;
            }

            XenServerPatchAlert patchAlert = (XenServerPatchAlert)clickedRow.Tag;

            if (patchAlert == null)
            {
                return;
            }

            string patchUri = patchAlert.Patch.PatchUrl;

            if (string.IsNullOrEmpty(patchUri))
            {
                return;
            }

            Uri    address  = new Uri(patchUri);
            string tempFile = Path.GetTempFileName();

            var action = new DownloadAndUnzipXenServerPatchAction(patchAlert.Description, address, tempFile);
            ActionProgressDialog dialog = new ActionProgressDialog(action, ProgressBarStyle.Continuous, false)
            {
                ShowCancel = true
            };

            action.Completed += s =>
            {
                if (action.Succeeded)
                {
                    Program.Invoke(Program.MainWindow, () =>
                    {
                        var wizard = new PatchingWizard();
                        wizard.Show();
                        wizard.NextStep();
                        wizard.AddFile(action.PatchPath);
                        wizard.NextStep();

                        var hosts = patchAlert.DistinctHosts;
                        if (hosts.Count > 0)
                        {
                            wizard.SelectServers(hosts);
                        }
                        else
                        {
                            string disconnectedServerNames =
                                clickedRow.Cells[ColumnLocation.Index].Value.ToString();

                            new ThreeButtonDialog(
                                new ThreeButtonDialog.Details(SystemIcons.Warning,
                                                              string.Format(Messages.UPDATES_WIZARD_DISCONNECTED_SERVER,
                                                                            disconnectedServerNames),
                                                              Messages.UPDATES_WIZARD)).ShowDialog(this);
                        }
                    });
                }
            };

            dialog.Show(this);
        }
Exemplo n.º 3
0
        private void ButtonRemove_Click(object sender, EventArgs e)
        {
            Program.AssertOnEventThread();

            // Double check, this method is called from a context menu as well and the state could have changed under it
            if (!ButtonRemove.Enabled)
            {
                return;
            }

            var subjectsToRemove = GridViewSubjectList.SelectedRows.Cast <AdSubjectRow>().Select(r => r.subject).ToList();

            if (subjectsToRemove.Count < 1)
            {
                return;
            }

            var removeMessage = subjectsToRemove.Count == 1
                ? string.Format(Messages.QUESTION_REMOVE_AD_USER_ONE, subjectsToRemove[0].DisplayName ?? subjectsToRemove[0].SubjectName)
                : string.Format(Messages.QUESTION_REMOVE_AD_USER_MANY, subjectsToRemove.Count);

            string adminMessage = null;
            var    conn         = subjectsToRemove.FirstOrDefault(s => s.Connection != null)?.Connection;

            if (conn != null && Helpers.StockholmOrGreater(conn) && !conn.Cache.Hosts.Any(Host.RestrictPoolSecretRotation))
            {
                var poolAdminsToRemove = (from Subject s in subjectsToRemove
                                          let roles = s.Connection.ResolveAll(s.roles)
                                                      where roles.Any(r => r.name_label == Role.MR_ROLE_POOL_ADMIN)
                                                      select s).ToList();

                if (subjectsToRemove.Count == poolAdminsToRemove.Count)
                {
                    adminMessage = poolAdminsToRemove.Count == 1
                        ? Messages.QUESTION_ADMIN_EXIT_PROCEDURE_ONE
                        : Messages.QUESTION_ADMIN_EXIT_PROCEDURE_MANY;
                }
                else if (poolAdminsToRemove.Count > 0)
                {
                    adminMessage = poolAdminsToRemove.Count == 1
                        ? Messages.QUESTION_ADMIN_EXIT_PROCEDURE_ONE_OF_MANY
                        : string.Format(Messages.QUESTION_ADMIN_EXIT_PROCEDURE_SOME_OF_MANY, poolAdminsToRemove.Count);
                }

                if (!string.IsNullOrEmpty(adminMessage))
                {
                    removeMessage = string.Format("{0}\n\n{1} {2}", removeMessage, adminMessage, Messages.QUESTION_ADMIN_EXIT_PROCEDURE_ADVISORY);
                }
            }

            using (var dlg = new WarningDialog(removeMessage,
                                               ThreeButtonDialog.ButtonYes,
                                               new ThreeButtonDialog.TBDButton(Messages.NO_BUTTON_CAPTION, DialogResult.No, selected: true))
            {
                WindowTitle = Messages.AD_FEATURE_NAME
            })
            {
                //CA-64818: DialogResult can be No if the No button has been hit
                //or Cancel if the dialog has been closed from the control box

                if (dlg.ShowDialog(this) != DialogResult.Yes)
                {
                    return;
                }
            }

            // Warn if user is revoking his currently-in-use credentials
            Session session = _connection.Session;

            if (session != null && session.SessionSubject != null)
            {
                foreach (Subject entry in subjectsToRemove)
                {
                    if (entry.opaque_ref == session.SessionSubject)
                    {
                        string subjectName = entry.DisplayName ?? entry.SubjectName;
                        if (subjectName == null)
                        {
                            subjectName = entry.subject_identifier;
                        }
                        else
                        {
                            subjectName = subjectName.Ellipsise(256);
                        }
                        string msg = string.Format(entry.IsGroup ? Messages.AD_CONFIRM_SUICIDE_GROUP : Messages.AD_CONFIRM_SUICIDE,
                                                   subjectName, Helpers.GetName(_connection).Ellipsise(50));

                        DialogResult r;
                        using (var dlg = new WarningDialog(msg,
                                                           ThreeButtonDialog.ButtonYes,
                                                           new ThreeButtonDialog.TBDButton(Messages.NO_BUTTON_CAPTION, DialogResult.No, selected: true))
                        {
                            WindowTitle = Messages.AD_FEATURE_NAME
                        })
                        {
                            r = dlg.ShowDialog(this);
                        }

                        //CA-64818: DialogResult can be No if the No button has been hit
                        //or Cancel if the dialog has been closed from the control box
                        if (r != DialogResult.Yes)
                        {
                            return;
                        }

                        break;
                    }
                }
            }

            var action = new AddRemoveSubjectsAction(_connection, new List <string>(), subjectsToRemove);

            using (var dlog = new ActionProgressDialog(action, ProgressBarStyle.Continuous))
                dlog.ShowDialog(this);
        }
Exemplo n.º 4
0
        protected override void FinishWizard()
        {
            // If the user has chosen a file that already exists, get confirmation
            string path = bugToolPageDestination1.OutputFile;

            if (File.Exists(path))
            {
                DialogResult dialogResult;
                using (var dlg = new ThreeButtonDialog(
                           new ThreeButtonDialog.Details(SystemIcons.Warning, string.Format(Messages.FILE_X_EXISTS_OVERWRITE, path), Messages.XENCENTER),
                           ThreeButtonDialog.ButtonOK,
                           new ThreeButtonDialog.TBDButton(Messages.CANCEL, DialogResult.Cancel, ThreeButtonDialog.ButtonType.CANCEL, true)))
                {
                    dialogResult = dlg.ShowDialog(this);
                }
                if (dialogResult != DialogResult.OK)
                {
                    FinishCanceled();
                    return;
                }
            }

            // Check we can write to the destination file - otherwise we only find out at the
            // end of the ZipStatusReportAction, and the downloaded server files are lost,
            // and the user will have to run the wizard again.
            try
            {
                using (FileStream temp = File.OpenWrite(path))
                {
                    // Yay, it worked
                }
            }
            catch (Exception exn)
            {
                // Failure
                using (var dlg = new ThreeButtonDialog(
                           new ThreeButtonDialog.Details(
                               SystemIcons.Error,
                               string.Format(Messages.COULD_NOT_WRITE_FILE, path, exn.Message),
                               Messages.XENCENTER)))
                {
                    dlg.ShowDialog(this);
                }
                FinishCanceled();
                return;
            }

            // Proceed to finish the wizard and start the zip action

            // zip up the report files and save them to the chosen file
            Actions.ZipStatusReportAction action =
                new Actions.ZipStatusReportAction(bugToolPageRetrieveData.OutputFolder, bugToolPageDestination1.OutputFile);
            using (var dialog = new ActionProgressDialog(action, ProgressBarStyle.Blocks))
            {
                dialog.ShowCancel = true;
                dialog.ShowDialog();
            }

            if (!action.Succeeded)
            {
                // Close. We can't recover from a partially-completed ZipStatusReportAction.
                base.FinishWizard();
                return;
            }

            // upload the report files
            if (bugToolPageDestination1.Upload)
            {
                var uploadAction = new Actions.UploadServerStatusReportAction(bugToolPageDestination1.OutputFile,
                                                                              bugToolPageDestination1.UploadToken, bugToolPageDestination1.CaseNumber,
                                                                              Registry.HealthCheckUploadDomainName, false);
                using (var dialog = new ActionProgressDialog(uploadAction, ProgressBarStyle.Marquee)
                {
                    ShowCancel = true
                })
                    dialog.ShowDialog();
            }

            // Save away the output path for next time
            XenAdmin.Properties.Settings.Default.ServerStatusPath = bugToolPageDestination1.OutputFile;

            log.Debug("Cleaning up crash dump logs on server");
            var capabilities = bugToolPageSelectCapabilities1.Capabilities;

            foreach (Capability c in capabilities)
            {
                if (c.Key == "host-crashdump-dumps" && c.Checked)
                {
                    var hostList = bugToolPageSelectHosts1.SelectedHosts;
                    if (!hostList.Any(h => h.HasCrashDumps()))
                    {
                        break;
                    }

                    DialogResult result;
                    using (var dlg = new ThreeButtonDialog(
                               new ThreeButtonDialog.Details(null, Messages.REMOVE_CRASHDUMP_QUESTION, Messages.REMOVE_CRASHDUMP_FILES),
                               ThreeButtonDialog.ButtonYes,
                               ThreeButtonDialog.ButtonNo))
                    {
                        result = dlg.ShowDialog(this);
                    }
                    if (result == DialogResult.Yes)
                    {
                        foreach (Host host in hostList)
                        {
                            if (host != null && host.HasCrashDumps())
                            {
                                new Actions.DestroyHostCrashDumpAction(host).RunAsync();
                            }
                        }
                    }
                    break;
                }
            }
            base.FinishWizard();
        }
Exemplo n.º 5
0
        private bool EnableWlb()
        {
            // Enable WLB.
            EnableWLBAction action = new EnableWLBAction(_pool);
            // We will need to re-enable buttons when the action completes
            action.Completed += Program.MainWindow.action_Completed;
            using (var dialog = new ActionProgressDialog(action, ProgressBarStyle.Blocks))
            {
                dialog.ShowCancel = true;
                dialog.ShowDialog(this);
            }

            Program.MainWindow.UpdateToolbars();
            return action.Succeeded;
        }
        private void SaveSubscription()
        {
            if (this._subscription == null)
            {
                _subscription = new WlbReportSubscription(String.Empty);
                _subscription.SubscriberName = GetLoggedInAsText();
                _subscription.Created = DateTime.UtcNow;
            }
            _subscription.Name = this.subNameTextBox.Text;
            _subscription.Description = this.subNameTextBox.Text;

            DateTime utcExecuteTime;
            WlbScheduledTask.WlbTaskDaysOfWeek utcDaysOfWeek;
            WlbScheduledTask.GetUTCTaskTimes((WlbScheduledTask.WlbTaskDaysOfWeek)this.schedDeliverComboBox.SelectedValue, this.dateTimePickerSubscriptionRunTime.Value, out utcDaysOfWeek, out utcExecuteTime);
            _subscription.ExecuteTimeOfDay = utcExecuteTime;
            _subscription.DaysOfWeek = utcDaysOfWeek;
            if (_subscription.DaysOfWeek != WlbScheduledTask.WlbTaskDaysOfWeek.All)
            {
                _subscription.TriggerType = (int)WlbScheduledTask.WlbTaskTriggerType.Weekly;
            }
            else
            {
                _subscription.TriggerType = (int)WlbScheduledTask.WlbTaskTriggerType.Daily;
            }
            _subscription.Enabled = true;
            _subscription.EnableDate = this.dateTimePickerSchedStart.Value == DateTime.MinValue ? DateTime.UtcNow : this.dateTimePickerSchedStart.Value.ToUniversalTime();
            _subscription.DisableDate = this.dateTimePickerSchedEnd.Value == DateTime.MinValue ? DateTime.UtcNow.AddMonths(1) : this.dateTimePickerSchedEnd.Value.ToUniversalTime();
            _subscription.LastTouched = DateTime.UtcNow;
            _subscription.LastTouchedBy = GetLoggedInAsText();

            // store email info
            _subscription.EmailTo = this.emailToTextBox.Text.Trim();
            _subscription.EmailCc = this.emailCcTextBox.Text.Trim();
            _subscription.EmailBcc = this.emailBccTextBox.Text.Trim();
            _subscription.EmailReplyTo = this.emailReplyTextBox.Text.Trim();
            _subscription.EmailSubject = this.emailSubjectTextBox.Text.Trim();
            _subscription.EmailComment = this.emailCommentRichTextBox.Text;

            // store reoprt Info
            //sub.ReportId = ;
            _subscription.ReportRenderFormat = this.rpRenderComboBox.SelectedIndex;
            Dictionary<string, string> rps = new Dictionary<string, string>();
            foreach(string key in this._rpParams.Keys)
            {
                if (String.Compare(key, WlbReportSubscription.REPORT_NAME, true) == 0)
                    _subscription.ReportName = this._rpParams[WlbReportSubscription.REPORT_NAME];
                else
                {
                    //Get start date range
                    if (String.Compare(key, "start", true) == 0)
                    {
                        rps.Add(key, ((this.rpParamComboBox.SelectedIndex + 1) * (-7)+1).ToString());
                    }
                    else
                    {
                        rps.Add(key, _rpParams[key]);
                    }
                }
            }
            _subscription.ReportParameters = rps;

            SendWlbConfigurationAction action = new SendWlbConfigurationAction(this._pool, _subscription.ToDictionary(), SendWlbConfigurationKind.SetReportSubscription);
            using (var dialog = new ActionProgressDialog(action, ProgressBarStyle.Blocks))
            {
                dialog.ShowCancel = true;
                dialog.ShowDialog(this);
            }

            if (action.Succeeded)
            {
                DialogResult = DialogResult.OK;
                this.Close();
            }
            else if(!action.Cancelled)
            {
                using (var dlg = new ThreeButtonDialog(
                   new ThreeButtonDialog.Details(
                       SystemIcons.Error,
                       String.Format(Messages.WLB_SUBSCRIPTION_ERROR, _subscription.Description),
                       Messages.XENCENTER)))
                {
                    dlg.ShowDialog(this);
                }
                //log.ErrorFormat("There was an error calling SendWlbConfigurationAction to SetReportSubscription {0}, Action Result: {1}.", _subscription.Description, action.Result);
                DialogResult = DialogResult.None;
            }
        }
Exemplo n.º 7
0
        private void SaveSubscription()
        {
            if (this._subscription == null)
            {
                _subscription = new WlbReportSubscription(String.Empty);
                _subscription.SubscriberName = GetLoggedInAsText();
                _subscription.Created        = DateTime.UtcNow;
            }
            _subscription.Name        = this.subNameTextBox.Text;
            _subscription.Description = this.subNameTextBox.Text;

            DateTime utcExecuteTime;

            WlbScheduledTask.WlbTaskDaysOfWeek utcDaysOfWeek;
            WlbScheduledTask.GetUTCTaskTimes((WlbScheduledTask.WlbTaskDaysOfWeek) this.schedDeliverComboBox.SelectedValue, this.dateTimePickerSubscriptionRunTime.Value, out utcDaysOfWeek, out utcExecuteTime);
            _subscription.ExecuteTimeOfDay = utcExecuteTime;
            _subscription.DaysOfWeek       = utcDaysOfWeek;
            if (_subscription.DaysOfWeek != WlbScheduledTask.WlbTaskDaysOfWeek.All)
            {
                _subscription.TriggerType = (int)WlbScheduledTask.WlbTaskTriggerType.Weekly;
            }
            else
            {
                _subscription.TriggerType = (int)WlbScheduledTask.WlbTaskTriggerType.Daily;
            }
            _subscription.Enabled       = true;
            _subscription.EnableDate    = this.dateTimePickerSchedStart.Value == DateTime.MinValue ? DateTime.UtcNow : this.dateTimePickerSchedStart.Value.ToUniversalTime();
            _subscription.DisableDate   = this.dateTimePickerSchedEnd.Value == DateTime.MinValue ? DateTime.UtcNow.AddMonths(1) : this.dateTimePickerSchedEnd.Value.ToUniversalTime();
            _subscription.LastTouched   = DateTime.UtcNow;
            _subscription.LastTouchedBy = GetLoggedInAsText();

            // store email info
            _subscription.EmailTo      = this.emailToTextBox.Text.Trim();
            _subscription.EmailCc      = this.emailCcTextBox.Text.Trim();
            _subscription.EmailBcc     = this.emailBccTextBox.Text.Trim();
            _subscription.EmailReplyTo = this.emailReplyTextBox.Text.Trim();
            _subscription.EmailSubject = this.emailSubjectTextBox.Text.Trim();
            _subscription.EmailComment = this.emailCommentRichTextBox.Text;

            // store reoprt Info
            //sub.ReportId = ;
            _subscription.ReportRenderFormat = this.rpRenderComboBox.SelectedIndex;
            Dictionary <string, string> rps = new Dictionary <string, string>();

            foreach (string key in this._rpParams.Keys)
            {
                if (String.Compare(key, WlbReportSubscription.REPORT_NAME, true) == 0)
                {
                    _subscription.ReportName = this._rpParams[WlbReportSubscription.REPORT_NAME];
                }
                else
                {
                    //Get start date range
                    if (String.Compare(key, "start", true) == 0)
                    {
                        rps.Add(key, ((this.rpParamComboBox.SelectedIndex + 1) * (-7) + 1).ToString());
                    }
                    else
                    {
                        rps.Add(key, _rpParams[key]);
                    }
                }
            }
            _subscription.ReportParameters = rps;

            SendWlbConfigurationAction action = new SendWlbConfigurationAction(this._pool, _subscription.ToDictionary(), SendWlbConfigurationKind.SetReportSubscription);

            using (var dialog = new ActionProgressDialog(action, ProgressBarStyle.Blocks))
            {
                dialog.ShowCancel = true;
                dialog.ShowDialog(this);
            }

            if (action.Succeeded)
            {
                DialogResult = DialogResult.OK;
                this.Close();
            }
            else if (!action.Cancelled)
            {
                using (var dlg = new ErrorDialog(string.Format(Messages.WLB_SUBSCRIPTION_ERROR, _subscription.Description)))
                {
                    dlg.ShowDialog(this);
                }
                //log.ErrorFormat("There was an error calling SendWlbConfigurationAction to SetReportSubscription {0}, Action Result: {1}.", _subscription.Description, action.Result);
                DialogResult = DialogResult.None;
            }
        }
Exemplo n.º 8
0
        private void ButtonRemove_Click(object sender, EventArgs e)
        {
            Program.AssertOnEventThread();

            // Double check, this method is called from a context menu as well and the state could have changed under it
            if (!ButtonRemove.Enabled)
            {
                return;
            }

            List <Subject> subjectsToRemove = new List <Subject>();

            foreach (AdSubjectRow r in GridViewSubjectList.SelectedRows)
            {
                subjectsToRemove.Add(r.subject);
            }

            var removeMessage = subjectsToRemove.Count == 1
                ? string.Format(Messages.QUESTION_REMOVE_AD_USER_ONE, subjectsToRemove[0].DisplayName ?? subjectsToRemove[0].SubjectName)
                : string.Format(Messages.QUESTION_REMOVE_AD_USER_MANY, subjectsToRemove.Count);

            DialogResult questionDialog;

            using (var dlg = new ThreeButtonDialog(
                       new ThreeButtonDialog.Details(
                           null,
                           removeMessage,
                           Messages.AD_FEATURE_NAME),
                       ThreeButtonDialog.ButtonYes,
                       new ThreeButtonDialog.TBDButton(Messages.NO_BUTTON_CAPTION, DialogResult.No, ThreeButtonDialog.ButtonType.CANCEL, true)))
            {
                questionDialog = dlg.ShowDialog(this);
            }

            //CA-64818: DialogResult can be No if the No button has been hit
            //or Cancel if the dialog has been closed from the control box
            if (questionDialog != DialogResult.Yes)
            {
                return;
            }

            // Warn if user is revoking his currently-in-use credentials
            Session session = _connection.Session;

            if (session != null && session.Subject != null)
            {
                foreach (Subject entry in subjectsToRemove)
                {
                    if (entry.opaque_ref == session.Subject)
                    {
                        string subjectName = entry.DisplayName ?? entry.SubjectName;
                        if (subjectName == null)
                        {
                            subjectName = entry.subject_identifier;
                        }
                        else
                        {
                            subjectName = subjectName.Ellipsise(256);
                        }
                        string msg = string.Format(entry.IsGroup ? Messages.AD_CONFIRM_SUICIDE_GROUP : Messages.AD_CONFIRM_SUICIDE,
                                                   subjectName, Helpers.GetName(_connection).Ellipsise(50));

                        DialogResult r;
                        using (var dlg = new ThreeButtonDialog(
                                   new ThreeButtonDialog.Details(
                                       SystemIcons.Warning,
                                       msg,
                                       Messages.AD_FEATURE_NAME),
                                   ThreeButtonDialog.ButtonYes,
                                   new ThreeButtonDialog.TBDButton(Messages.NO_BUTTON_CAPTION, DialogResult.No, ThreeButtonDialog.ButtonType.CANCEL, true)))
                        {
                            r = dlg.ShowDialog(this);
                        }

                        //CA-64818: DialogResult can be No if the No button has been hit
                        //or Cancel if the dialog has been closed from the control box
                        if (r != DialogResult.Yes)
                        {
                            return;
                        }

                        break;
                    }
                }
            }

            var action = new AddRemoveSubjectsAction(_connection, new List <string>(), subjectsToRemove);

            using (var dlog = new ActionProgressDialog(action, ProgressBarStyle.Continuous))
                dlog.ShowDialog(this);
        }
Exemplo n.º 9
0
        private void ToolStripMenuItemDownload_Click(object sender, EventArgs e)
        {
            if (dataGridViewUpdates.SelectedRows.Count == 0)
            {
                return;
            }

            XenServerPatchAlert patchAlert = dataGridViewUpdates.SelectedRows[0].Tag as XenServerPatchAlert;

            if (patchAlert == null)
            {
                return;
            }

            string patchUri = patchAlert.Patch.PatchUrl;

            if (string.IsNullOrEmpty(patchUri))
            {
                return;
            }

            Uri    address  = new Uri(patchUri);
            string tempFile = Path.GetTempFileName();

            var action = new DownloadAndUnzipXenServerPatchAction(patchAlert.Description, address, tempFile);
            ActionProgressDialog dialog = new ActionProgressDialog(action, ProgressBarStyle.Continuous, false)
            {
                ShowCancel = true
            };

            dialog.ShowDialog(this);

            if (action.Succeeded)
            {
                var wizard = new PatchingWizard();
                wizard.Show();
                wizard.NextStep();
                wizard.AddFile(action.PatchPath);
                wizard.NextStep();

                var hosts = patchAlert.DistinctHosts;
                if (hosts.Count > 0)
                {
                    wizard.SelectServers(hosts);
                    if (wizard.CurrentStepTabPage.EnableNext())
                    {
                        wizard.NextStep();
                    }
                }
                else
                {
                    string disconnectedServerNames =
                        dataGridViewUpdates.SelectedRows[0].Cells[ColumnLocation.Index].Value.ToString();

                    new ThreeButtonDialog(
                        new ThreeButtonDialog.Details(SystemIcons.Warning,
                                                      string.Format(Messages.UPDATES_WIZARD_DISCONNECTED_SERVER,
                                                                    disconnectedServerNames),
                                                      Messages.UPDATES_WIZARD)).ShowDialog(this);
                }
            }
        }
Exemplo n.º 10
0
        private void generateGeneralBox()
        {
            GeneralDataList.Add(new GeneralDataStructure(FriendlyName("host.name_label"), Helpers.GetName(this.xenModelObject), General));
            GeneralDataList.Add(new GeneralDataStructure(FriendlyName("host.name_description"), this.xenModelObject.Description, General));
            GeneralDataList.Add(new GeneralDataStructure(Messages.FOLDER, this.xenModelObject.Path, General));
            GeneralDataList.Add(new GeneralDataStructure(Messages.TAGS, this.TagsString(), General));
            if (this.xenModelObject is XenObject <XenAPI.SR> )
            {
                XenAPI.SR xenObject = this.xenModelObject as XenAPI.SR;
                GeneralDataList.Add(new GeneralDataStructure(Messages.TYPE, xenObject.FriendlyTypeName, General));
                if ((xenObject.content_type != "iso") && (xenObject.GetSRType(false) != XenAPI.SR.SRTypes.udev))
                {
                    GeneralDataList.Add(new GeneralDataStructure(FriendlyName("SR.size"), xenObject.SizeString, General));
                }
                if (xenObject.GetScsiID() != null && xenObject.GetScsiID().Count > 0)
                {
                    foreach (String scsiid in xenObject.GetScsiID())
                    {
                        if (xenObject.GetSRType(true) == SR.SRTypes.lvmobond)
                        {
                            if (CanAddLUN(scsiid) || isLunBondRed(scsiid))
                            {
                                List <ToolStripMenuItem> ctxMenuItems = new List <ToolStripMenuItem>();
                                ToolStripMenuItem        itm          = new ToolStripMenuItem(Messages.ADD)
                                {
                                    Image = Resources._000_StorageBroken_h32bit_16
                                };
                                itm.Click += delegate
                                {
                                    List <FibreChannelDevice> devices;
                                    var success = LVMoBond.FiberChannelScan(this, xenObject.Connection, out devices);
                                    Program.MainWindow.ShowPerConnectionWizard(this.xenModelObject.Connection, new AddLUNDialog(xenObject, devices));
                                };

                                ctxMenuItems.Add(itm);
                                GeneralDataList.Add(new GeneralDataStructure(FriendlyName("SR.scsiid"), scsiid ?? Messages.UNKNOWN, General, Color.Red, ctxMenuItems));
                            }
                            else if (canissciRemove())
                            {
                                List <ToolStripMenuItem> ctxMenuItems = new List <ToolStripMenuItem>();
                                ToolStripMenuItem        itm          = new ToolStripMenuItem(Messages.REMOVE)
                                {
                                    Image = Resources._000_StorageBroken_h32bit_16
                                };
                                itm.Click += delegate
                                {
                                    AsyncAction          Action = new SrRemoveLUNAction(xenObject.Connection, xenObject, scsiid);
                                    ActionProgressDialog dialog = new ActionProgressDialog(Action, ProgressBarStyle.Marquee)
                                    {
                                        ShowCancel = true
                                    };
                                    dialog.ShowDialog(this);
                                };
                                ctxMenuItems.Add(itm);
                                if (isLunBondRed(scsiid))
                                {
                                    GeneralDataList.Add(new GeneralDataStructure(FriendlyName("SR.scsiid"), scsiid ?? Messages.UNKNOWN, General, Color.Red, ctxMenuItems));
                                }
                                else
                                {
                                    GeneralDataList.Add(new GeneralDataStructure(FriendlyName("SR.scsiid"), scsiid ?? Messages.UNKNOWN, General, ctxMenuItems));
                                }
                            }
                            else
                            {
                                GeneralDataList.Add(new GeneralDataStructure(FriendlyName("SR.scsiid"), scsiid ?? Messages.UNKNOWN, General));
                            }
                        }
                        else if (xenObject.GetSRType(true) == SR.SRTypes.lvmomirror && xenObject.other_config.ContainsKey("_type"))
                        {
                            if (CanAddMirrorLUN(scsiid))
                            {
                                List <ToolStripMenuItem> ctxMenuItems = new List <ToolStripMenuItem>();
                                ToolStripMenuItem        itm          = new ToolStripMenuItem(Messages.ADD)
                                {
                                    Image = Resources._000_StorageBroken_h32bit_16
                                };
                                itm.Click += delegate
                                {
                                    // Program.MainWindow.ShowPerConnectionWizard(this.xenModelObject.Connection, new AddMirrorIscsiDialog(xenObject));
                                    AddMirrorIscsiDialog dlg = new AddMirrorIscsiDialog(xenObject);
                                    dlg.ShowDialog();
                                };

                                ctxMenuItems.Add(itm);
                                if (isMirrorRed(scsiid))
                                {
                                    GeneralDataList.Add(new GeneralDataStructure(FriendlyName("SR.scsiid"), scsiid ?? Messages.UNKNOWN, General, Color.Red, ctxMenuItems));
                                }
                                else
                                {
                                    GeneralDataList.Add(new GeneralDataStructure(FriendlyName("SR.scsiid"), scsiid ?? Messages.UNKNOWN, General, ctxMenuItems));
                                }
                            }
                            else if (canMirrorissciRemove())
                            {
                                List <ToolStripMenuItem> ctxMenuItems = new List <ToolStripMenuItem>();
                                ToolStripMenuItem        itm          = new ToolStripMenuItem(Messages.REMOVE)
                                {
                                    Image = Resources._000_StorageBroken_h32bit_16
                                };
                                itm.Click += delegate
                                {
                                    AsyncAction          Action = new SrRemoveMirrorLUNAction(xenObject.Connection, xenObject, scsiid);
                                    ActionProgressDialog dialog = new ActionProgressDialog(Action, ProgressBarStyle.Marquee)
                                    {
                                        ShowCancel = true
                                    };
                                    dialog.ShowDialog(this);
                                };
                                ctxMenuItems.Add(itm);
                                if (isMirrorRed(scsiid))
                                {
                                    GeneralDataList.Add(new GeneralDataStructure(FriendlyName("SR.scsiid"), scsiid ?? Messages.UNKNOWN, General, Color.Red, ctxMenuItems));
                                }
                                else
                                {
                                    GeneralDataList.Add(new GeneralDataStructure(FriendlyName("SR.scsiid"), scsiid ?? Messages.UNKNOWN, General, ctxMenuItems));
                                }
                            }
                            else
                            {
                                GeneralDataList.Add(new GeneralDataStructure(FriendlyName("SR.scsiid"), scsiid ?? Messages.UNKNOWN, General));
                            }
                        }
                        else if (xenObject.GetSRType(true) == SR.SRTypes.lvmomirror && !xenObject.other_config.ContainsKey("_type"))
                        {
                            if (CanAddMirrorLUN(scsiid))
                            {
                                List <ToolStripMenuItem> ctxMenuItems = new List <ToolStripMenuItem>();
                                ToolStripMenuItem        itm          = new ToolStripMenuItem(Messages.ADD)
                                {
                                    Image = Resources._000_StorageBroken_h32bit_16
                                };
                                itm.Click += delegate
                                {
                                    List <FibreChannelDevice> devices;
                                    var success = LVMoMirror.FiberChannelScan(this, xenObject.Connection, out devices);
                                    Program.MainWindow.ShowPerConnectionWizard(this.xenModelObject.Connection, new AddMirrorLUNDialog(xenObject, devices));
                                };

                                ctxMenuItems.Add(itm);
                                if (isMirrorRed(scsiid))
                                {
                                    GeneralDataList.Add(new GeneralDataStructure(FriendlyName("SR.scsiid"), scsiid ?? Messages.UNKNOWN, General, Color.Red, ctxMenuItems));
                                }
                                else
                                {
                                    GeneralDataList.Add(new GeneralDataStructure(FriendlyName("SR.scsiid"), scsiid ?? Messages.UNKNOWN, General, ctxMenuItems));
                                }
                            }
                            else if (canMirrorissciRemove())
                            {
                                List <ToolStripMenuItem> ctxMenuItems = new List <ToolStripMenuItem>();
                                ToolStripMenuItem        itm          = new ToolStripMenuItem(Messages.REMOVE)
                                {
                                    Image = Resources._000_StorageBroken_h32bit_16
                                };
                                itm.Click += delegate
                                {
                                    AsyncAction          Action = new SrRemoveMirrorLUNAction(xenObject.Connection, xenObject, scsiid);
                                    ActionProgressDialog dialog = new ActionProgressDialog(Action, ProgressBarStyle.Marquee)
                                    {
                                        ShowCancel = true
                                    };
                                    dialog.ShowDialog(this);
                                };
                                ctxMenuItems.Add(itm);
                                if (isMirrorRed(scsiid))
                                {
                                    GeneralDataList.Add(new GeneralDataStructure(FriendlyName("SR.scsiid"), scsiid ?? Messages.UNKNOWN, General, Color.Red, ctxMenuItems));
                                }
                                else
                                {
                                    GeneralDataList.Add(new GeneralDataStructure(FriendlyName("SR.scsiid"), scsiid ?? Messages.UNKNOWN, General, ctxMenuItems));
                                }
                            }
                            else
                            {
                                GeneralDataList.Add(new GeneralDataStructure(FriendlyName("SR.scsiid"), scsiid ?? Messages.UNKNOWN, General));
                            }
                        }
                        else
                        {
                            GeneralDataList.Add(new GeneralDataStructure(FriendlyName("SR.scsiid"), scsiid ?? Messages.UNKNOWN, General));
                        }
                    }
                }

                if ((Program.MainWindow.SelectionManager.Selection.HostAncestor == null) && (Program.MainWindow.SelectionManager.Selection.PoolAncestor == null))
                {
                    IXenObject o = Helpers.GetPool(xenObject.Connection);
                    if (o != null)
                    {
                        GeneralDataList.Add(new GeneralDataStructure(Messages.POOL, Helpers.GetName(o), General));
                    }
                    else
                    {
                        o = Helpers.GetMaster(xenObject.Connection);
                        if (o != null)
                        {
                            GeneralDataList.Add(new GeneralDataStructure(Messages.SERVER, Helpers.GetName(o), General));
                        }
                    }
                }
            }

            GeneralDataList.Add(new GeneralDataStructure(FriendlyName("host.uuid"), GetUUID(this.xenModelObject), General));
        }
Exemplo n.º 11
0
        private void buttonNfsScan_Click(object sender, EventArgs e)
        {
            NfsScanButton.Enabled = false;

            // Perform an SR.probe to see if there is already an SR present
            Dictionary <String, String> dconf = new Dictionary <String, String>();

            string[] fullpath = NfsServerPathTextBox.Text.Split(new char[] { ':' });
            dconf[SERVER] = fullpath[0];
            if (fullpath.Length > 1)
            {
                dconf[SERVERPATH] = fullpath[1];
            }
            dconf[OPTIONS] = serverOptionsTextBox.Text;

            Host master = Helpers.GetMaster(Connection);

            if (master == null)
            {
                return;
            }

            // Start probe
            SrProbeAction        action = new SrProbeAction(Connection, master, SR.SRTypes.nfs, dconf);
            ActionProgressDialog dialog = new ActionProgressDialog(action, ProgressBarStyle.Marquee);

            dialog.ShowCancel = true;
            dialog.ShowDialog(this);

            try
            {
                NfsScanButton.Enabled = true;
                if (radioButtonNfsNew.Enabled)
                {
                    radioButtonNfsNew.Checked = true;
                }

                listBoxNfsSRs.Items.Clear();

                if (!action.Succeeded)
                {
                    return;
                }

                List <SR.SRInfo> SRs = SR.ParseSRListXML(action.Result);
                if (SRs.Count == 0)
                {
                    // Disable box
                    panelNfsReattach.Enabled = false;
                    listBoxNfsSRs.Items.Add(Messages.NEWSR_NFS_NO_SRS_FOUND);
                    return;
                }

                // Fill box
                foreach (SR.SRInfo info in SRs)
                {
                    listBoxNfsSRs.Items.Add(info);
                }

                listBoxNfsSRs.TryAndSelectUUID();

                panelNfsReattach.Enabled = true;
            }
            finally
            {
                UpdateButtons();
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// Performs a scan of the CSLG host specified in the textboxes.
        /// </summary>
        /// <returns>True, if the scan succeeded, otherwise False.</returns>
        public bool PerformStorageSystemScan()
        {
            var items = new List <object>();
            StorageLinkCredentials        credentials = null;
            SrCslgStorageSystemScanAction scanAction  = null;

            if (_storageLinkObject != null || (Connection.IsConnected && !Helpers.FeatureForbidden(Connection, Host.RestrictStorageChoices) && Helpers.MidnightRideOrGreater(Connection)))
            {
                if (_srToReattach == null || _srToReattach.type == "cslg")
                {
                    credentials = GetStorageLinkCredentials(Connection);

                    if (credentials != null && credentials.IsValid)
                    {
                        scanAction = new SrCslgStorageSystemScanAction(Program.MainWindow, Connection,
                                                                       Program.StorageLinkConnections.GetCopy(),
                                                                       credentials.Host, credentials.Username,
                                                                       credentials.PasswordSecret);
                    }
                    else if (Helpers.BostonOrGreater(Connection))
                    {
                        var action = new SrCslgAdaptersScanAction(Connection);
                        var dialog = new ActionProgressDialog(action, ProgressBarStyle.Marquee);
                        // never show the error message if it fails.
                        action.Completed += s =>
                        {
                            if (!action.Succeeded)
                            {
                                Program.Invoke(dialog, dialog.Close);
                            }
                        };

                        dialog.ShowDialog(this);
                        if (action.Succeeded)
                        {
                            var adapters = action.GetAdapters();
                            items.AddRange(Util.PopulateList <object>(adapters));
                            items.Sort((x, y) => x.ToString().CompareTo(y.ToString()));
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    if (scanAction != null)
                    {
                        var dialog = new ActionProgressDialog(scanAction, ProgressBarStyle.Marquee);

                        // never show the error message if it fails.
                        scanAction.Completed += s =>
                        {
                            if (!scanAction.Succeeded)
                            {
                                Program.Invoke(dialog, dialog.Close);
                            }
                        };

                        dialog.ShowDialog(this);

                        if (scanAction.Succeeded)
                        {
                            _storages = scanAction.CslgSystemStorages;
                            items.AddRange(Util.PopulateList <object>(_storages));
                            items.Sort((x, y) => x.ToString().CompareTo(y.ToString()));
                        }
                    }
                }
            }

            bool bostonHasDell   = false;
            bool bostonHasNetapp = false;

            if (Helpers.BostonOrGreater(Connection) && items != null)
            {
                bostonHasDell   = (items.Find(item => ((StorageLinkAdapterBoston)item).Id == "DELL_EQUALLOGIC") != null);
                bostonHasNetapp = (items.Find(item => ((StorageLinkAdapterBoston)item).Id == "NETAPP") != null);
            }

            comboBoxStorageSystem.Items.Clear();

            if (_storageLinkObject != null)
            {
                // the wizard was launched with a storagelink-server, storage-system or storage-pool selected.
                if (scanAction != null && scanAction.Succeeded)
                {
                    comboBoxStorageSystem.Items.Add(new NonSelectableComboBoxItem(string.Format(Messages.CSLG_STORAGELINK_SERVER, credentials.Host), true));
                    comboBoxStorageSystem.Items.AddRange(items.ToArray());
                    comboBoxStorageSystem.Items.Add(new NonSelectableComboBoxItem(Messages.ADD_HOST, false));

                    // if a specific storage-system was selected when the wizard was launched then select that storage-system
                    // in the combo-box here.
                    var system = _storageLinkObject as StorageLinkSystem;

                    if (system == null)
                    {
                        // if a specific storage-pool was selected when the wizard was launched then select the storage-system
                        // of that storage-pool here.
                        var storagePool = _storageLinkObject as StorageLinkPool;
                        system = storagePool == null ? null : storagePool.StorageLinkSystem;
                    }

                    if (system != null)
                    {
                        comboBoxStorageSystem.SelectedItem = items.Find(o => ((CslgSystemStorage)o).StorageSystemId == system.opaque_ref);
                    }
                }
            }
            else if (_srToReattach != null)
            {
                if (_srToReattach.type == "equal")
                {
                    // a direct-connect Equallogic is being reattached. Only add this item.
                    comboBoxStorageSystem.Items.Add(Messages.CSLG_DELL_DIRECT);
                }
                else if (_srToReattach.type == "netapp")
                {
                    // a direct-connect NetApp is being reattached. Only add this item.
                    comboBoxStorageSystem.Items.Add(Messages.CSLG_NETAPP_DIRECT);
                }
                else if (credentials != null)
                {
                    // credentials can be null if we don't have a license which supports CSLG.

                    // re-attaching StorageLink SR
                    Debug.Assert(_srToReattach.type == "cslg");
                    comboBoxStorageSystem.Items.Add(new NonSelectableComboBoxItem(string.Format(Messages.CSLG_STORAGELINK_SERVER, credentials.Host), true));
                    comboBoxStorageSystem.Items.AddRange(items.ToArray());
                }
            }
            else
            {
                // a pool or host was selected in the mainwindow tree when the wizard was launched.
                bool canAdd      = scanAction != null && scanAction.Succeeded && scanAction.StorageLinkConnection != null;
                bool showHeaders = scanAction != null && scanAction.Succeeded && (items.Count > 0 || scanAction.StorageLinkConnection != null);

                if (showHeaders || Helpers.BostonOrGreater(Connection))
                {
                    if (!bostonHasDell || !bostonHasNetapp)
                    {
                        comboBoxStorageSystem.Items.Add(new NonSelectableComboBoxItem(Messages.CSLG_DIRECT_CONNECTION, true));
                    }
                }

                if (!bostonHasDell)
                {
                    comboBoxStorageSystem.Items.Add(Messages.CSLG_DELL_DIRECT);
                }
                if (!bostonHasNetapp)
                {
                    comboBoxStorageSystem.Items.Add(Messages.CSLG_NETAPP_DIRECT);
                }

                if (showHeaders)
                {
                    comboBoxStorageSystem.Items.Add(new NonSelectableComboBoxItem(string.Format(Messages.CSLG_STORAGELINK_SERVER, credentials.Host), true));
                    comboBoxStorageSystem.Items.AddRange(items.ToArray());
                }

                if (canAdd)
                {
                    comboBoxStorageSystem.Items.Add(new NonSelectableComboBoxItem(Messages.ADD_HOST, false));
                }
            }

            if (Helpers.BostonOrGreater(Connection) && items != null && items.Count > 0)
            {
                if (!bostonHasDell || !bostonHasNetapp)
                {
                    comboBoxStorageSystem.Items.Add(new NonSelectableComboBoxItem(Messages.CSLG_STORAGELINK_ADAPTERS, true));
                }
                comboBoxStorageSystem.Items.AddRange(items.ToArray());
            }

            if (comboBoxStorageSystem.SelectedIndex < 0 && comboBoxStorageSystem.Items.Count > 0)
            {
                // select the first selectable item if nothing's already been selected.
                comboBoxStorageSystem.SelectedItem = Util.PopulateList <object>(comboBoxStorageSystem.Items).Find(s => !(s is NonSelectableComboBoxItem));
                if (_srToReattach != null && _srToReattach.type == "cslg" &&
                    Helpers.BostonOrGreater(Connection))
                {
                    comboBoxStorageSystem.SelectedItem =
                        Util.PopulateList <object>(comboBoxStorageSystem.Items).Find(s =>
                    {
                        var bostonadapter = s as StorageLinkAdapterBoston;
                        if (bostonadapter != null)
                        {
                            // sm_config["md_svid"] looks like "DELL__EQUALLOGIC__{GUID}"
                            // bostonadapter.Id looks like "DELL_EQUALLOGIC"
                            // Additionally, EMC__CLARIION is always SMI-S (CA-72968)
                            if (_srToReattach.sm_config.ContainsKey("md_svid"))
                            {
                                var svid = _srToReattach.sm_config["md_svid"];
                                if (svid.Replace("__", "_").StartsWith(bostonadapter.Id))
                                {
                                    return(true);
                                }
                                if (bostonadapter.Id == "SMIS_STORAGE_SYSTEM" && svid.StartsWith("EMC__CLARIION"))
                                {
                                    return(true);
                                }
                                return(false);
                            }
                        }
                        return(false);
                    });
                }
            }
            return(true);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Performs a scan of the CSLG host specified in the textboxes.
        /// </summary>
        /// <returns>True, if the scan succeeded, otherwise False.</returns>
        public bool PerformStorageSystemScan()
        {
            var items = new List <object>();

            if (Connection.IsConnected && !Helpers.FeatureForbidden(Connection, Host.RestrictStorageChoices))
            {
                if (_srToReattach == null || _srToReattach.type == "cslg")
                {
                    var action = new SrCslgAdaptersScanAction(Connection);
                    using (var dialog = new ActionProgressDialog(action, ProgressBarStyle.Marquee))
                    {
                        // never show the error message if it fails.
                        action.Completed += s =>
                        {
                            if (!action.Succeeded)
                            {
                                Program.Invoke(dialog, dialog.Close);
                            }
                        };

                        dialog.ShowDialog(this);
                    }
                    if (action.Succeeded)
                    {
                        var adapters = action.GetAdapters();
                        items.AddRange(Util.PopulateList <object>(adapters));
                        items.Sort((x, y) => x.ToString().CompareTo(y.ToString()));
                    }
                    else
                    {
                        return(false);
                    }
                }
            }

            bool bostonHasDell   = false;
            bool bostonHasNetapp = false;

            if (items != null)
            {
                bostonHasDell   = (items.Find(item => ((StorageLinkAdapterBoston)item).Id == "DELL_EQUALLOGIC") != null);
                bostonHasNetapp = (items.Find(item => ((StorageLinkAdapterBoston)item).Id == "NETAPP") != null);
            }

            comboBoxStorageSystem.Items.Clear();

            if (_srToReattach != null)
            {
                if (_srToReattach.type == "equal")
                {
                    // a direct-connect Equallogic is being reattached. Only add this item.
                    comboBoxStorageSystem.Items.Add(Messages.CSLG_DELL_DIRECT);
                }
                else if (_srToReattach.type == "netapp")
                {
                    // a direct-connect NetApp is being reattached. Only add this item.
                    comboBoxStorageSystem.Items.Add(Messages.CSLG_NETAPP_DIRECT);
                }
            }
            else
            {
                // a pool or host was selected in the mainwindow tree when the wizard was launched.
                if (!bostonHasDell || !bostonHasNetapp)
                {
                    comboBoxStorageSystem.Items.Add(new NonSelectableComboBoxItem(Messages.CSLG_DIRECT_CONNECTION, true));
                }

                if (!bostonHasDell)
                {
                    comboBoxStorageSystem.Items.Add(Messages.CSLG_DELL_DIRECT);
                }
                if (!bostonHasNetapp)
                {
                    comboBoxStorageSystem.Items.Add(Messages.CSLG_NETAPP_DIRECT);
                }
            }

            if (items != null && items.Count > 0)
            {
                if (!bostonHasDell || !bostonHasNetapp)
                {
                    comboBoxStorageSystem.Items.Add(new NonSelectableComboBoxItem(Messages.CSLG_STORAGELINK_ADAPTERS, true));
                }
                comboBoxStorageSystem.Items.AddRange(items.ToArray());
            }

            if (comboBoxStorageSystem.SelectedIndex < 0 && comboBoxStorageSystem.Items.Count > 0)
            {
                // select the first selectable item if nothing's already been selected.
                comboBoxStorageSystem.SelectedItem = Util.PopulateList <object>(comboBoxStorageSystem.Items).Find(s => !(s is NonSelectableComboBoxItem));
                if (_srToReattach != null && _srToReattach.type == "cslg")
                {
                    comboBoxStorageSystem.SelectedItem =
                        Util.PopulateList <object>(comboBoxStorageSystem.Items).Find(s =>
                    {
                        var bostonadapter = s as StorageLinkAdapterBoston;
                        if (bostonadapter != null)
                        {
                            // sm_config["md_svid"] looks like "DELL__EQUALLOGIC__{GUID}"
                            // bostonadapter.Id looks like "DELL_EQUALLOGIC"
                            // Additionally, EMC__CLARIION is always SMI-S (CA-72968)
                            if (_srToReattach.sm_config.ContainsKey("md_svid"))
                            {
                                var svid = _srToReattach.sm_config["md_svid"];
                                if (svid.Replace("__", "_").StartsWith(bostonadapter.Id))
                                {
                                    return(true);
                                }
                                if (bostonadapter.Id == "SMIS_STORAGE_SYSTEM" && svid.StartsWith("EMC__CLARIION"))
                                {
                                    return(true);
                                }
                                return(false);
                            }
                        }
                        return(false);
                    });
                }
            }
            return(true);
        }
Exemplo n.º 14
0
        private void buttonNfsScan_Click(object sender, EventArgs e)
        {
            NfsScanButton.Enabled = false;

            // Perform an SR.probe to see if there is already an SR present
            Dictionary <String, String> dconf = new Dictionary <String, String>();

            string[] fullpath = NfsServerPathTextBox.Text.Trim().Split(new char[] { ':' });
            dconf[SERVER] = fullpath[0];
            if (fullpath.Length > 1)
            {
                dconf[SERVERPATH] = fullpath[1];
            }
            dconf[OPTIONS] = serverOptionsTextBox.Text;

            Host master = Helpers.GetMaster(Connection);

            if (master == null)
            {
                return;
            }

            if (Helpers.DundeeOrGreater(Connection))
            {
                dconf[PROBEVERSION] = string.Empty; //this needs to be passed to the API in order to get back the NFS versions supported
            }
            // Start probe
            SrProbeAction action = new SrProbeAction(Connection, master, SR.SRTypes.nfs, dconf);

            using (var dialog = new ActionProgressDialog(action, ProgressBarStyle.Marquee))
            {
                dialog.ShowCancel = true;
                dialog.ShowDialog(this);
            }

            try
            {
                NfsScanButton.Enabled = true;
                if (radioButtonNfsNew.Enabled)
                {
                    radioButtonNfsNew.Checked = true;
                }

                listBoxNfsSRs.Items.Clear();

                if (!action.Succeeded)
                {
                    return;
                }

                GetSupportedNfsVersionsAndSetUI(action.Result);

                var SRs = action.SRs ?? new List <SR.SRInfo>();
                if (SRs.Count == 0)
                {
                    // Disable box
                    ToggleReattachControlsEnabledState(false);
                    listBoxNfsSRs.Items.Add(Messages.NEWSR_NO_SRS_FOUND);
                    return;
                }

                // Fill box
                foreach (SR.SRInfo info in SRs)
                {
                    listBoxNfsSRs.Items.Add(info);
                }

                listBoxNfsSRs.TryAndSelectUUID();

                ToggleReattachControlsEnabledState(true);
            }
            finally
            {
                UpdateButtons();
            }
        }
Exemplo n.º 15
0
        private void buttonCifsScan_Click(object sender, EventArgs e)
        {
            try
            {
                CifsScanButton.Enabled = false;

                // Perform an SR.probe to see if there is already an SR present
                Dictionary <String, String> dconf = new Dictionary <String, String>();
                string[] fullpath = CifsServerPathTextBox.Text.Split(new char[] { ':' });
                dconf[SERVER] = fullpath[0];
                if (fullpath.Length > 1)
                {
                    dconf[SERVERPATH] = fullpath[1];
                }

                if (userNameTextBox.Text.Trim().Length > 0 || passwordTextBox.Text.Trim().Length > 0)
                {
                    dconf["username"] = userNameTextBox.Text;
                    dconf["password"] = passwordTextBox.Text;
                }

                Host master = Helpers.GetMaster(Connection);
                if (master == null)
                {
                    return;
                }

                // Start probe
                SrProbeAction action = new SrProbeAction(Connection, master, SR.SRTypes.smb, dconf);
                using (var dialog = new ActionProgressDialog(action, ProgressBarStyle.Marquee))
                {
                    dialog.ShowCancel = true;
                    dialog.ShowDialog(this);
                }

                if (radioButtonCifsNew.Enabled)
                {
                    radioButtonCifsNew.Checked = true;
                }

                listBoxCifsSRs.Items.Clear();

                if (!action.Succeeded)
                {
                    return;
                }

                List <SR.SRInfo> SRs = SR.ParseSRListXML(action.Result);
                if (SRs.Count == 0)
                {
                    // Disable box
                    ToggleReattachControlsEnabledState(false);
                    listBoxCifsSRs.Items.Add(Messages.NEWSR_NO_SRS_FOUND);
                    return;
                }

                // Fill box
                foreach (SR.SRInfo info in SRs)
                {
                    listBoxCifsSRs.Items.Add(info);
                }

                listBoxCifsSRs.TryAndSelectUUID();

                ToggleReattachControlsEnabledState(true);
            }
            finally
            {
                UpdateButtons();
            }
        }
Exemplo n.º 16
0
        private void InstallToolsOnManyVms(List <VM> vms)
        {
            bool newDvdDrivesRequired = false;

            foreach (VM vm in vms)
            {
                if (CanExecute(vm) && vm.FindVMCDROM() == null)
                {
                    newDvdDrivesRequired = true;
                    break;
                }
            }

            if (newDvdDrivesRequired)
            {
                DialogResult dialogResult;
                using (var dlg = new WarningDialog(Messages.NEW_DVD_DRIVES_REQUIRED,
                                                   ThreeButtonDialog.ButtonYes, ThreeButtonDialog.ButtonNo))
                {
                    dialogResult = dlg.ShowDialog(Parent);
                }
                if (dialogResult == DialogResult.Yes)
                {
                    foreach (VM vm in vms)
                    {
                        if (CanExecute(vm) && vm.FindVMCDROM() == null)
                        {
                            //do not register the event ShowUserInstruction; we show explicitly a message afterwards
                            var createDriveAction = new CreateCdDriveAction(vm);

                            using (var dlg = new ActionProgressDialog(createDriveAction, ProgressBarStyle.Marquee))
                            {
                                dlg.ShowDialog(Parent);
                            }
                        }
                    }
                    ShowMustRebootBox();
                    InstallTools?.Invoke(null);
                }
            }
            else
            {
                using (var dlg = new WarningDialog(Messages.XS_TOOLS_MESSAGE_MORE_THAN_ONE_VM,
                                                   new ThreeButtonDialog.TBDButton(Messages.INSTALL_XENSERVER_TOOLS_BUTTON,
                                                                                   DialogResult.OK, ThreeButtonDialog.ButtonType.ACCEPT, true),
                                                   ThreeButtonDialog.ButtonCancel)
                {
                    ShowLinkLabel = true,
                    LinkText = Messages.INSTALLTOOLS_READ_MORE,
                    LinkAction = () => Help.HelpManager.Launch("InstallToolsWarningDialog")
                })
                    if (dlg.ShowDialog(Parent) == DialogResult.OK && CheckToolSrs(vms.ToArray()))
                    {
                        foreach (VM vm in vms)
                        {
                            var installToolsAction = new InstallPVToolsAction(vm, Properties.Settings.Default.ShowHiddenVMs);

                            if (vms.IndexOf(vm) == 0)
                            {
                                installToolsAction.Completed += FirstInstallToolsActionCompleted;
                            }
                            else
                            {
                                installToolsAction.Completed += InstallToolsActionCompleted;
                            }

                            installToolsAction.RunAsync();
                        }

                        InstallTools?.Invoke(null);
                    }
            }
        }
Exemplo n.º 17
0
        public override void PageLeave(PageLoadedDirection direction, ref bool cancel)
        {
            if (direction == PageLoadedDirection.Back)
            {
                return;
            }

            Host master = Helpers.GetMaster(Connection);

            if (master == null)
            {
                cancel = true;
                return;
            }

            SrDescriptors = new List <LvmOhbaSrDescriptor>();

            var existingSrDescriptors = new List <LvmOhbaSrDescriptor>();
            var formatDiskDescriptors = new List <LvmOhbaSrDescriptor>();

            foreach (var device in _selectedDevices)
            {
                LvmOhbaSrDescriptor descr = CreateSrDescriptor(device);

                var action = new SrProbeAction(Connection, master, SrType, descr.DeviceConfig);
                using (var dlg = new ActionProgressDialog(action, ProgressBarStyle.Marquee))
                    dlg.ShowDialog(this);

                if (!action.Succeeded)
                {
                    cancel = true;
                    return;
                }

                descr.UUID = SrWizardHelpers.ExtractUUID(action.Result);

                if (!string.IsNullOrEmpty(SrWizardType.UUID))
                {
                    // Check LUN contains correct SR
                    if (descr.UUID == SrWizardType.UUID)
                    {
                        SrDescriptors.Add(descr);
                        continue;
                    }

                    using (var dlog = new ThreeButtonDialog(
                               new ThreeButtonDialog.Details(SystemIcons.Error,
                                                             String.Format(Messages.INCORRECT_LUN_FOR_SR, SrWizardType.SrName), Messages.XENCENTER)))
                    {
                        dlog.ShowDialog(this);
                    }

                    cancel = true;
                    return;
                }

                if (string.IsNullOrEmpty(descr.UUID))
                {
                    // No existing SRs were found on this LUN. If allowed to create
                    // a new SR, ask the user if they want to proceed and format.
                    if (!SrWizardType.AllowToCreateNewSr)
                    {
                        using (var dlog = new ThreeButtonDialog(
                                   new ThreeButtonDialog.Details(SystemIcons.Error,
                                                                 Messages.NEWSR_LUN_HAS_NO_SRS, Messages.XENCENTER)))
                        {
                            dlog.ShowDialog(this);
                        }

                        cancel = true;
                        return;
                    }

                    if (!Program.RunInAutomatedTestMode)
                    {
                        formatDiskDescriptors.Add(descr);
                    }
                }
                else
                {
                    // CA-17230: Check this isn't a detached SR. If it is then just continue
                    SR sr = SrWizardHelpers.SrInUse(descr.UUID);
                    if (sr != null)
                    {
                        SrDescriptors.Add(descr);
                        continue;
                    }

                    // We found a SR on this LUN. Will ask user for choice later.
                    existingSrDescriptors.Add(descr);
                }
            }

            if (!cancel && existingSrDescriptors.Count > 0)
            {
                var launcher = new LVMoHBAWarningDialogLauncher(this, existingSrDescriptors, true);
                launcher.ShowWarnings();
                cancel = launcher.Cancelled;
                if (!cancel && launcher.SrDescriptors.Count > 0)
                {
                    SrDescriptors.AddRange(launcher.SrDescriptors);
                }
            }

            if (!cancel && formatDiskDescriptors.Count > 0)
            {
                var launcher = new LVMoHBAWarningDialogLauncher(this, formatDiskDescriptors, false);
                launcher.ShowWarnings();
                cancel = launcher.Cancelled;
                if (!cancel && launcher.SrDescriptors.Count > 0)
                {
                    SrDescriptors.AddRange(launcher.SrDescriptors);
                }
            }

            base.PageLeave(direction, ref cancel);
        }
Exemplo n.º 18
0
        private void RunFinalAction(out bool closeWizard)
        {
            FinalAction = null;
            closeWizard = false;

            // Override the WizardBase: try running the SR create/attach. If it succeeds, close the wizard.
            // Otherwise show the error and allow the user to adjust the settings and try again.
            Pool pool = Helpers.GetPoolOfOne(xenConnection);

            if (pool == null)
            {
                log.Error("New SR Wizard: Pool has disappeared");
                new ThreeButtonDialog(
                    new ThreeButtonDialog.Details(SystemIcons.Warning, string.Format(Messages.NEW_SR_CONNECTION_LOST, Helpers.GetName(xenConnection)), Messages.XENCENTER)).ShowDialog(this);

                closeWizard = true;
                return;
            }

            Host master = xenConnection.Resolve(pool.master);

            if (master == null)
            {
                log.Error("New SR Wizard: Master has disappeared");
                new ThreeButtonDialog(
                    new ThreeButtonDialog.Details(SystemIcons.Warning, string.Format(Messages.NEW_SR_CONNECTION_LOST, Helpers.GetName(xenConnection)), Messages.XENCENTER)).ShowDialog(this);

                closeWizard = true;
                return;
            }

            if (_srToReattach != null && _srToReattach.HasPBDs && _srToReattach.Connection == xenConnection)
            {
                // Error - cannot reattach attached SR
                MessageBox.Show(this,
                                String.Format(Messages.STORAGE_IN_USE, _srToReattach.Name, Helpers.GetName(xenConnection)),
                                Text, MessageBoxButtons.OK, MessageBoxIcon.Error);

                FinishCanceled();
                return;
            }

            // show warning prompt if required
            if (!AskUserIfShouldContinue())
            {
                FinishCanceled();
                return;
            }

            List <AsyncAction> actionList = GetActions(master, m_srWizardType.DisasterRecoveryTask);

            if (actionList.Count == 1)
            {
                FinalAction = actionList[0];
            }
            else
            {
                FinalAction = new ParallelAction(xenConnection, Messages.NEW_SR_WIZARD_FINAL_ACTION_TITLE,
                                                 Messages.NEW_SR_WIZARD_FINAL_ACTION_START,
                                                 Messages.NEW_SR_WIZARD_FINAL_ACTION_END, actionList);
            }

            // if this is a Disaster Recovery Task, it could be either a "Find existing SRs" or an "Attach SR needed for DR" case
            if (m_srWizardType.DisasterRecoveryTask)
            {
                closeWizard = true;
                return;
            }

            ProgressBarStyle     progressBarStyle = FinalAction is SrIntroduceAction ? ProgressBarStyle.Blocks : ProgressBarStyle.Marquee;
            ActionProgressDialog dialog           = new ActionProgressDialog(FinalAction, progressBarStyle)
            {
                ShowCancel = true
            };

            if (m_srWizardType is SrWizardType_LvmoHba || m_srWizardType is SrWizardType_Fcoe)
            {
                ActionProgressDialog closureDialog = dialog;
                // close dialog even when there's an error for HBA SR type as there will be the Summary page displayed.
                FinalAction.Completed +=
                    s => Program.Invoke(Program.MainWindow, () =>
                {
                    if (closureDialog != null)
                    {
                        closureDialog.Close();
                    }
                });
            }
            dialog.ShowDialog(this);

            if (m_srWizardType is SrWizardType_LvmoHba || m_srWizardType is SrWizardType_Fcoe)
            {
                foreach (var asyncAction in actionList)
                {
                    AddActionToSummary(asyncAction);
                }
            }

            if (!FinalAction.Succeeded && FinalAction is SrReattachAction && _srToReattach.HasPBDs)
            {
                // reattach failed. Ensure PBDs are now unplugged and destroyed.
                dialog            = new ActionProgressDialog(new SrAction(SrActionKind.UnplugAndDestroyPBDs, _srToReattach), progressBarStyle);
                dialog.ShowCancel = false;
                dialog.ShowDialog();
            }

            // If action failed and frontend wants to stay open, just return
            if (!FinalAction.Succeeded)
            {
                DialogResult = DialogResult.None;
                FinishCanceled();

                if (m_srWizardType.AutoDescriptionRequired)
                {
                    foreach (var srDescriptor in m_srWizardType.SrDescriptors)
                    {
                        srDescriptor.Description = null;
                    }
                }

                return;
            }

            // Close wizard
            closeWizard = true;
        }
Exemplo n.º 19
0
        private bool InitializeWLB()
        {
            //combine url and port
            string wlbUrl = textboxWlbUrl.Text + ":" + textboxWLBPort.Text;

            //handle the wlb creds
            string wlbUserName = textboxWlbUserName.Text;
            string wlbPassword = textboxWlbPassword.Text;

            //handle the xenserver creds
            string xsUserName = textboxXSUserName.Text;
            string xsPassword = textboxXSPassword.Text;

            InitializeWLBAction action = new InitializeWLBAction(_pool, wlbUrl, wlbUserName, wlbPassword, xsUserName, xsPassword);
            ActionProgressDialog dialog = new ActionProgressDialog(action, ProgressBarStyle.Blocks);
            dialog.ShowCancel = true;
            dialog.ShowDialog(this);

            Program.MainWindow.UpdateToolbars();
            return action.Succeeded;
        }
Exemplo n.º 20
0
        private bool InitializeWLB()
        {
            //combine url and port
            string wlbHost = textboxWlbUrl.Text;
            string wlbPort = textboxWLBPort.Text;
            IPAddress address;
            string wlbUrl = (IPAddress.TryParse(wlbHost, out address) && address.AddressFamily == AddressFamily.InterNetworkV6) ?
                ("[" + wlbHost + "]:" + wlbPort) : (wlbHost + ":" + wlbPort);

            //handle the wlb creds
            string wlbUserName = textboxWlbUserName.Text;
            string wlbPassword = textboxWlbPassword.Text;

            //handle the xenserver creds
            string xsUserName = textboxXSUserName.Text;
            string xsPassword = textboxXSPassword.Text;

            InitializeWLBAction action = new InitializeWLBAction(_pool, wlbUrl, wlbUserName, wlbPassword, xsUserName, xsPassword);
            using (var dialog = new ActionProgressDialog(action, ProgressBarStyle.Blocks))
            {
                dialog.ShowCancel = true;
                dialog.ShowDialog(this);
            }

            Program.MainWindow.UpdateToolbars();
            return action.Succeeded;
        }
Exemplo n.º 21
0
        /// <summary>
        /// Attempts to install tools on several VMs
        /// </summary>
        /// <param name="vms"></param>
        /// <returns>Whether the action was launched (i.e., the user didn't Cancel)</returns>
        private bool MultipleVMExecute(List <VM> vms)
        {
            bool newDvdDrivesRequired = false;

            foreach (VM vm in vms)
            {
                if (CanExecute(vm) && vm.FindVMCDROM() == null)
                {
                    newDvdDrivesRequired = true;
                    break;
                }
            }

            if (newDvdDrivesRequired)
            {
                DialogResult dialogResult;
                using (var dlg = new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Warning, Messages.NEW_DVD_DRIVES_REQUIRED, Messages.XENCENTER),
                                                       ThreeButtonDialog.ButtonYes,
                                                       ThreeButtonDialog.ButtonNo))
                {
                    dialogResult = dlg.ShowDialog(Parent);
                }
                if (dialogResult == DialogResult.Yes)
                {
                    foreach (VM vm in vms)
                    {
                        if (CanExecute(vm) && vm.FindVMCDROM() == null)
                        {
                            CreateCdDriveAction createDriveAction = new CreateCdDriveAction(vm, true, NewDiskDialog.ShowMustRebootBoxCD, NewDiskDialog.ShowVBDWarningBox);
                            using (var dlg = new ActionProgressDialog(createDriveAction, ProgressBarStyle.Marquee))
                            {
                                dlg.ShowDialog(Parent);
                            }
                        }
                    }
                    ShowMustRebootBox();
                    return(true);
                }
            }
            else
            {
                List <IXenConnection> vmConnections = new List <IXenConnection>();
                foreach (VM vm in vms)
                {
                    vmConnections.Add(vm.Connection);
                }

                if (new InstallToolsWarningDialog(null, true, vmConnections).ShowDialog(Parent) == DialogResult.Yes)
                {
                    foreach (VM vm in vms)
                    {
                        var installToolsAction = new InstallPVToolsAction(vm, Properties.Settings.Default.ShowHiddenVMs);

                        if (vms.IndexOf(vm) == 0)
                        {
                            installToolsAction.Completed += FirstInstallToolsActionCompleted;
                        }
                        else
                        {
                            installToolsAction.Completed += InstallToolsActionCompleted;
                        }
                        installToolsAction.RunAsync();
                    }
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 22
0
        private WlbPoolConfiguration RetrieveWLBConfiguration()
        {
            RetrieveWlbConfigurationAction action = new RetrieveWlbConfigurationAction(_pool);
            using (ActionProgressDialog dialog = new ActionProgressDialog(action, ProgressBarStyle.Blocks))
            {
                dialog.ShowCancel = true;
                dialog.ShowDialog(this);
            }

            if (!action.Succeeded || null == action.WlbConfiguration || action.WlbConfiguration.Count == 0)
            {
                return null;
            }
            else
            {
                return new WlbPoolConfiguration(StripReportSubscriptions(action.WlbConfiguration));
            }
        }
Exemplo n.º 23
0
        /// <summary>
        /// Update by Dalei.Shou on 2013/8/16, remove the last "|0" parameter
        /// </summary>
        private void ScheduleRestoreJob()
        {
            int rowCount = this.page_VMSettings.DataGridViewRestoreInfo.RowCount;

            for (int i = 0; i < this.page_VMSettings.DataGridViewRestoreInfo.RowCount; i++)
            {
                if (this.page_VMSettings.DataGridViewRestoreInfo.Rows[i].Cells[0].Value.ToString().ToLowerInvariant() == "true")
                {
                    string[] uuidTag = this.page_VMSettings.DataGridViewRestoreInfo.Rows[i].Tag.ToString().Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries);
                    if (!restore_vdi_list.ContainsKey(uuidTag[0]))
                    {
                        restore_vdi_list.Add(uuidTag[0], uuidTag[1]);
                    }
                    else
                    {
                        string temp = string.Concat(restore_vdi_list[uuidTag[0]], "@", uuidTag[1]);
                        restore_vdi_list[uuidTag[0]] = temp;
                    }
                }
            }
            List <string> list = new List <string>();
            List <Dictionary <string, string> > listSchedule = new List <Dictionary <string, string> >();
            string schedule     = "";
            int    milliseconds = 0;

            foreach (AgentParamDataModel item in this.vmCheckedList)
            {
                string uuid_spend = "|";
                if (restore_vdi_list.ContainsKey(item.VMRestoreInfo.Substring(37, 36)))
                {
                    int l = restore_vdi_list[item.VMRestoreInfo.Substring(37, 36)].Split('@').Length;
                    if (l == 1)
                    {
                        uuid_spend += "halsign_vdi_all";
                    }
                    else
                    {
                        if (l - 1 == restore_vdi_info_list[item.VMRestoreInfo].Count)
                        {
                            uuid_spend += "halsign_vdi_all";
                        }
                        else if (l - 1 < restore_vdi_info_list[item.VMRestoreInfo].Count)
                        {
                            for (int y = 1; y < l; y++)
                            {
                                if (y == 1)
                                {
                                    uuid_spend = uuid_spend + restore_vdi_list[item.VMRestoreInfo.Substring(37, 36)].Split('@')[y];
                                }
                                else
                                {
                                    uuid_spend = uuid_spend + "@" +
                                                 restore_vdi_list[item.VMRestoreInfo.Substring(37, 36)].Split('@')[y];
                                }
                            }
                        }
                    }
                }

                list.Add(this.restore_job_name.TrimEnd().TrimStart() + "|" + this.set_storage_ip.Trim() + "|"
                         + this.set_storage_username + "|" + this.set_storage_password + "|" + item.RootPath + "|" +
                         item.VMRestoreInfo + "|"
                         + this.restore_vm_name + "|" + this.restoreDataModel.choice_sr_uuid + "|"
                         + (this._isBackupNetworkSettingChecked ? "1" : "0") + "|" +
                         (this._isNewMacAddressChecked ? "1" : "0")
                         + "|" + this.restore_network_uuid + uuid_spend);

                if (this._isOnceScheduleChecked)
                {
                    Dictionary <string, string> dconfTemp = new Dictionary <string, string>();
                    BackupRestoreConfig.Job     job       = new BackupRestoreConfig.Job();
                    job.job_name = this.restore_job_name.TrimEnd().TrimStart();

                    if (this._xenModelObject is VM)
                    {
                        VM _xenVM = this._xenModelObject as VM;
                        job.host = HalsignHelpers.VMHome(_xenVM).uuid;
                    }
                    else if (this._xenModelObject is Host)
                    {
                        Host _xenHost = _xenModelObject as Host;
                        job.host = _xenHost.uuid;
                    }
                    else
                    {
                        job.host = Helpers.GetMaster(this._xenModelObject.Connection).uuid;
                    }

                    TimeSpan ts = DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1, 0, 0, 0, 0));
                    job.key = "halsign_br_job_s_" + (Math.Floor(ts.TotalMilliseconds) + milliseconds++);

                    job.request = "o" + this.restore_job_name.TrimEnd().TrimStart() + "|" + this.set_storage_ip.Trim() +
                                  "|" + this.set_storage_username + "|" + this.set_storage_password + "|" +
                                  item.RootPath +
                                  "|" + item.VMRestoreInfo + "|" + restore_vm_name + "|" +
                                  this.restoreDataModel.choice_sr_uuid + "|"
                                  + (this._isBackupNetworkSettingChecked ? "1" : "0") + "|" +
                                  (this._isNewMacAddressChecked ? "1" : "0") + "|" + this.restore_network_uuid +
                                  uuid_spend;
                    ts = new DateTime(this.scheduleDate.Year, this.scheduleDate.Month, this.scheduleDate.Day, this.scheduleTime.Hour, this.scheduleTime.Minute,
                                      this.scheduleTime.Second).Subtract(new DateTime(1970, 1, 1, 0, 0, 0).ToLocalTime());
                    job.start_time    = Math.Floor(ts.TotalSeconds).ToString();
                    job.progress      = -1;
                    job.total_storage = -1;
                    job.modify_time   = "";
                    job.pid           = -1;
                    job.retry         = -1;
                    job.speed         = -1;
                    job.status        = 0;
                    schedule          = HalsignUtil.ToJson(job);
                    schedule          = schedule.Replace("\\/", "/");
                    dconfTemp.Add("schedule", schedule);
                    dconfTemp.Add("config_name", job.key);
                    listSchedule.Add(dconfTemp);
                }
            }

            BackupAction action = new BackupAction(_Message, BackupRestoreConfig.BackupActionKind.Restore, this._xenModelObject, list, listSchedule);

            if (action != null)
            {
                ProgressBarStyle     progressBarStyle = ProgressBarStyle.Marquee;
                ActionProgressDialog dialog           = new ActionProgressDialog(action, progressBarStyle);
                dialog.ShowCancel = false;
                dialog.ShowDialog(this);
                try
                {
                    if (!string.IsNullOrEmpty(action.Result))
                    {
                        Program.MainWindow.BringToFront();
                    }
                }
                catch
                {
                    Program.MainWindow.BringToFront();
                }
            }
        }