예제 #1
0
        protected override void ExecuteCore(SelectedItemCollection selection)
        {
            VM vm = (VM)selection[0].XenObject;

            using (var dlg = new ThreeButtonDialog(
                        new ThreeButtonDialog.Details(
                            SystemIcons.Warning,
                            string.Format(Messages.CONVERT_TEMPLATE_DIALOG_TEXT, vm.Name.Ellipsise(25)),
                            Messages.CONVERT_TO_TEMPLATE),
                        new ThreeButtonDialog.TBDButton(Messages.CONVERT, DialogResult.OK, ThreeButtonDialog.ButtonType.ACCEPT, true),
                        ThreeButtonDialog.ButtonCancel))
            {
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    List<AsyncAction> actions = new List<AsyncAction>();
                    actions.Add(new SetVMOtherConfigAction(vm.Connection, vm, "instant", "true"));
                    actions.Add(new VMToTemplateAction(vm));

                    MainWindowCommandInterface.CloseActiveWizards(vm);

                    RunMultipleActions(actions, string.Format(Messages.ACTION_VM_TEMPLATIZING_TITLE, vm.Name),
                                       Messages.ACTION_VM_TEMPLATIZING, Messages.ACTION_VM_TEMPLATIZED, true);
                }
            }
        }
예제 #2
0
 protected virtual void action_Completed(ActionBase sender)
 {
     var action = (AsyncAction)sender;
     if (action.Result == false.ToString())
         MainWindowCommandInterface.Invoke(() =>
         {
             using (var dlg =new ThreeButtonDialog(
                 new ThreeButtonDialog.Details(
                     SystemIcons.Information,
                     Messages.VIF_HOTPLUG_FAILED_MESSAGE,
                     Messages.VIF_HOTPLUG_FAILED_TITLE)))
             {
                 dlg.ShowDialog(Program.MainWindow);
             }
         });
 }
 public void LaunchUrlInBrowser()
 {
     try
     {
         if (UriToLaunch != null)
             Process.Start(UriToLaunch.AbsoluteUri);
     }
     catch (Exception)
     {
         using (var dlg = new ThreeButtonDialog(
             new ThreeButtonDialog.Details(
                 SystemIcons.Error,
                 string.Format(Messages.COULD_NOT_OPEN_URL,
                               UriToLaunch != null ? UriToLaunch.AbsoluteUri : string.Empty),
                 Messages.XENCENTER)))
         {
             dlg.ShowDialog(Program.MainWindow);
         }
     }
 }
예제 #4
0
        private void deleteButton_Click(object sender, EventArgs e)
        {
            if (tagsListView.SelectedItems.Count == 1)
            {
                string tag = tagsListView.SelectedItems[0].Text;

                DialogResult result;
                using (var tbd = new ThreeButtonDialog(
                           new ThreeButtonDialog.Details(SystemIcons.Warning, String.Format(Messages.CONFIRM_DELETE_TAG, tag), Messages.CONFIRM_DELETE_TAG_TITLE),
                           new ThreeButtonDialog.TBDButton(Messages.OK, DialogResult.OK),
                           ThreeButtonDialog.ButtonCancel))
                {
                    result = tbd.ShowDialog(this);
                }

                if (result != DialogResult.OK)
                {
                    return;
                }

                // Remove the tag from the tagsListView
                tagsListView.Items.Remove(tagsListView.SelectedItems[0]);
                setButtonEnablement();

                // Delete the tag from all resources on all servers
                DelegatedAsyncAction action = new DelegatedAsyncAction(null,
                                                                       String.Format(Messages.DELETE_ALL_TAG, tag),
                                                                       String.Format(Messages.DELETING_ALL_TAG, tag),
                                                                       String.Format(Messages.DELETED_ALL_TAG, tag),
                                                                       delegate(Session session)
                {
                    Tags.RemoveTagGlobally(tag);
                });
                action.RunAsync();
            }
        }
예제 #5
0
        private void VIFDialog_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (DialogResult == DialogResult.Cancel)
            {
                return;
            }

            if (MACAddressHasChanged())
            {
                foreach (var xenConnection in ConnectionsManager.XenConnectionsCopy.Where(c => c.IsConnected))
                {
                    foreach (VIF vif in xenConnection.Cache.VIFs)
                    {
                        var vm = xenConnection.Resolve(vif.VM);
                        if (vif != ExistingVif && vif.MAC == SelectedMac && vm != null && vm.is_a_real_vm())
                        {
                            using (var dlg = new ThreeButtonDialog(
                                       new ThreeButtonDialog.Details(SystemIcons.Warning,
                                                                     string.Format(Messages.PROBLEM_MAC_ADDRESS_IS_DUPLICATE, SelectedMac, vm.NameWithLocation()),
                                                                     Messages.PROBLEM_MAC_ADDRESS_IS_DUPLICATE_TITLE),
                                       new ThreeButtonDialog.TBDButton(Messages.YES_BUTTON_CAPTION, DialogResult.Yes),
                                       new ThreeButtonDialog.TBDButton(Messages.NO_BUTTON_CAPTION, DialogResult.No, ThreeButtonDialog.ButtonType.CANCEL, true)))
                            {
                                e.Cancel = dlg.ShowDialog(this) == DialogResult.No;
                                return;
                            }
                        }
                    }
                }
            }

            if (!ChangesHaveBeenMade)
            {
                DialogResult = DialogResult.Cancel;
            }
        }
예제 #6
0
        protected override AsyncAction CreateAction(out bool cancelled)
        {
            AsyncAction action = null;

            if (diskSpaceReq.CanCleanup)
            {
                Program.Invoke(Program.MainWindow, delegate()
                {
                    DialogResult r = new ThreeButtonDialog(
                        new ThreeButtonDialog.Details(
                           SystemIcons.Warning,
                           diskSpaceReq.GetSpaceRequirementsMessage()),
                        new ThreeButtonDialog.TBDButton(Messages.YES, DialogResult.Yes, ThreeButtonDialog.ButtonType.ACCEPT, true),
                        ThreeButtonDialog.ButtonNo
                        ).ShowDialog();


                    if (r == DialogResult.Yes)
                    {
                        action = new CleanupDiskSpaceAction(this.Server, patch, true);
                    }
                });
            }
            else
            { 
                Program.Invoke(Program.MainWindow, delegate()
                {
                    new ThreeButtonDialog(
                        new ThreeButtonDialog.Details(SystemIcons.Warning, diskSpaceReq.GetSpaceRequirementsMessage()))
                        .ShowDialog();
                });
            }
            cancelled = action == null;
            
            return action;
        }
예제 #7
0
        private void AcceptBtn_Click(object sender, EventArgs e)
        {
            List <PIF> newPIFs  = new List <PIF>();
            List <PIF> downPIFs = new List <PIF>();

            foreach (PIF pif in AllPIFs)
            {
                if (pif.IsManagementInterface(XenAdmin.Properties.Settings.Default.ShowHiddenVMs))
                {
                    downPIFs.Add(pif);
                }
            }

            foreach (NetworkingPropertiesPage page in verticalTabs.Items)
            {
                try
                {
                    CollateChanges(page, page.Tag as PIF, newPIFs);
                }
                catch (Failure)
                {
                    using (var dlg = new ThreeButtonDialog(
                               new ThreeButtonDialog.Details(
                                   SystemIcons.Warning,
                                   Messages.NETWORK_RECONFIG_CONNECTION_LOST,
                                   Messages.XENCENTER)))
                    {
                        dlg.ShowDialog(this);
                    }
                    this.Close();
                    return;
                }
            }

            bool displayWarning = false;
            bool managementInterfaceIPChanged = false;
            PIF  down_management = downPIFs.Find(PIFIsManagement);
            PIF  new_management  = newPIFs.Find(PIFIsManagement);

            if (down_management != null)
            {
                if (new_management == null)
                {
                    throw new Failure(Failure.INTERNAL_ERROR, "Bringing down the management interface without bringing another one up is impossible!");
                }

                managementInterfaceIPChanged = GetManagementInterfaceIPChanged(down_management, new_management);
                displayWarning = managementInterfaceIPChanged ||
                                 (down_management.uuid != new_management.uuid ||
                                  down_management.ip_configuration_mode != new_management.ip_configuration_mode);

                if (down_management.Equals(new_management))
                {
                    // Management interface has not changed
                    down_management = null;
                }
            }

            // Any PIFs that are in downPIFs but also in newPIFs need to be removed from the former.
            // downPIFs should contain all those that we no longer want to keep up.
            downPIFs.RemoveAll(delegate(PIF p) { return(PIFContains(newPIFs, p)); });

            // Remove any PIFs that haven't changed -- there's nothing to do for these ones.  They are in this
            // list originally so that they can be used as a filter against downPIFs.
            newPIFs.RemoveAll(delegate(PIF p) { return(!p.Changed); });

            if (newPIFs.Count > 0 || downPIFs.Count > 0)
            {
                if (displayWarning)
                {
                    string title = Pool == null ? Messages.NETWORKING_PROPERTIES_WARNING_CHANGING_MANAGEMENT_HOST
                        : Messages.NETWORKING_PROPERTIES_WARNING_CHANGING_MANAGEMENT_POOL;

                    DialogResult dialogResult;
                    using (var dlg = new ThreeButtonDialog(
                               new ThreeButtonDialog.Details(SystemIcons.Warning, title),
                               "NetworkingPropertiesPMIWarning",
                               new ThreeButtonDialog.TBDButton(Messages.NETWORKING_PROPERTIES_CHANGING_MANAGEMENT_CONTINUE, DialogResult.OK),
                               ThreeButtonDialog.ButtonCancel))
                    {
                        dialogResult = dlg.ShowDialog(this);
                    }
                    if (DialogResult.OK != dialogResult)
                    {
                        DialogResult = System.Windows.Forms.DialogResult.None;
                        return;
                    }
                }

                if (down_management == null)
                {
                    // We're actually just changing the IP address, not moving the management interface, so we just pass it in through newPIFs.
                    new_management = null;
                }
                else
                {
                    // We're switching the management interface over, so remove the old one from downPIFs -- it will be special-cased through
                    // down_management and new_management.
                    downPIFs.Remove(down_management);
                }

                // Reverse the lists so that the management interface is always last to be done.  If something's going to go wrong, then we'd like
                // the management interface to be the one that we don't break.
                newPIFs.Reverse();
                downPIFs.Reverse();

                new ChangeNetworkingAction(connection, Pool, Host, newPIFs, downPIFs, new_management, down_management,
                                           managementInterfaceIPChanged).RunAsync();
            }

            Close();
        }
예제 #8
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);
        }
예제 #9
0
 private void listViewExPowerManagementHosts_ItemCheck(object sender, ItemCheckEventArgs e)
 {
     if (!_loading)
     {
         if (listViewExPowerManagementHosts.Items[e.Index].Tag is Host)
         {
             Host host = (Host)listViewExPowerManagementHosts.Items[e.Index].Tag;
             if (!HostCannotParticipateInPowerManagement(host))
             {
                 if (e.NewValue == CheckState.Checked &&
                     (!_poolConfiguration.HostConfigurations.ContainsKey(host.uuid) ||
                      !_poolConfiguration.HostConfigurations[host.uuid].LastPowerOnSucceeded))
                 {
                     DialogResult dr =
                         new ThreeButtonDialog(
                         new ThreeButtonDialog.Details(SystemIcons.Warning, Messages.WLB_UNTESTED_HOST_WARNING, Messages.WLB_UNTESTED_HOST_CAPTION),
                         ThreeButtonDialog.ButtonYes,
                         ThreeButtonDialog.ButtonNo).ShowDialog();
                     if (dr == DialogResult.No)
                     {
                         e.NewValue = e.CurrentValue;
                     }
                     else
                     {
                         _hasChanged = true;
                     }
                 }
                 else
                 {
                     _hasChanged = true;
                 }
             }
             else
             {
                 e.NewValue = CheckState.Unchecked;
             }
         }
     }
 }
예제 #10
0
 private void DeleteGraph()
 {
     using (ThreeButtonDialog dlog = new ThreeButtonDialog(
         new ThreeButtonDialog.Details(SystemIcons.Warning,
             string.Format(Messages.DELETE_GRAPH_MESSAGE, GraphList.SelectedGraph.DisplayName),
             Messages.XENCENTER),
         ThreeButtonDialog.ButtonYes,
         ThreeButtonDialog.ButtonNo))
     {
         if (dlog.ShowDialog(this) == DialogResult.Yes)
             if (GraphList.AuthorizedRole)
             {
                 GraphList.DeleteGraph(GraphList.SelectedGraph);
                 GraphList.LoadDataSources(SaveGraphs);
             }
     }
 }
예제 #11
0
        /// <summary>
        /// In the case there being nowhere to start/resume the VM (NO_HOSTS_AVAILABLE), shows the reason why the VM could not be started
        /// on each host. If the start failed due to HA_OPERATION_WOULD_BREAK_FAILOVER_PLAN, offers to decrement ntol and try the operation
        /// again.
        /// </summary>
        /// <param name="vm"></param>
        /// <param name="f"></param>
        /// <param name="kind">The kind of the operation that failed. Must be one of Start/StartOn/Resume/ResumeOn.</param>
        public static void StartDiagnosisForm(VMStartAbstractAction VMStartAction , Failure failure)
        {

            if (failure.ErrorDescription[0] == Failure.NO_HOSTS_AVAILABLE)
            {
                // Show a dialog displaying why the VM couldn't be started on each host
                StartDiagnosisForm(VMStartAction.VM);
            }
            else if (failure.ErrorDescription[0] == Failure.HA_OPERATION_WOULD_BREAK_FAILOVER_PLAN)
            {
                // The action was blocked by HA because it would reduce the number of tolerable server failures.
                // With the user's consent, we'll reduce the number of configured failures to tolerate and try again.
                Pool pool = Helpers.GetPool(VMStartAction.VM.Connection);
                if (pool == null)
                {
                    log.ErrorFormat("Could not get pool for VM {0} in StartDiagnosisForm()", Helpers.GetName(VMStartAction.VM));
                    return;
                }

                long ntol = pool.ha_host_failures_to_tolerate;
                long newNtol = Math.Min(pool.ha_plan_exists_for - 1, ntol - 1);
                if (newNtol <= 0)
                {
                    // We would need to basically turn HA off to start this VM
                    string msg = String.Format(VMStartAction.IsStart ? Messages.HA_VM_START_NTOL_ZERO : Messages.HA_VM_RESUME_NTOL_ZERO,
                        Helpers.GetName(pool).Ellipsise(100),
                        Helpers.GetName(VMStartAction.VM).Ellipsise(100));
                    Program.Invoke(Program.MainWindow, delegate()
                    {
                        new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Warning, msg, Messages.HIGH_AVAILABILITY)).ShowDialog(Program.MainWindow);
                    });
                }
                else
                {
                    // Show 'reduce ntol?' dialog
                    string msg = String.Format(VMStartAction.IsStart ? Messages.HA_VM_START_NTOL_DROP : Messages.HA_VM_RESUME_NTOL_DROP,
                        Helpers.GetName(pool).Ellipsise(100), ntol,
                        Helpers.GetName(VMStartAction.VM).Ellipsise(100), newNtol);

                    Program.Invoke(Program.MainWindow, delegate()
                    {
                        DialogResult r = new ThreeButtonDialog(
                            new ThreeButtonDialog.Details(SystemIcons.Warning, msg, Messages.HIGH_AVAILABILITY),
                            ThreeButtonDialog.ButtonYes,
                            new ThreeButtonDialog.TBDButton(Messages.NO_BUTTON_CAPTION, DialogResult.No, ThreeButtonDialog.ButtonType.CANCEL, true)).ShowDialog(Program.MainWindow);

                        if (r == DialogResult.Yes)
                        {
                            DelegatedAsyncAction action = new DelegatedAsyncAction(VMStartAction.VM.Connection, Messages.HA_LOWERING_NTOL, null, null,
                                delegate(Session session)
                                {
                                    // Set new ntol, then retry action
                                    XenAPI.Pool.set_ha_host_failures_to_tolerate(session, pool.opaque_ref, newNtol);
                                    // ntol set succeeded, start new action
                                    VMStartAction.Clone().RunAsync();
                                });
                            action.RunAsync();
                        }
                    });
                }
            }
        }
예제 #12
0
 private void EditTask(WlbScheduledTask task)
 {
     WlbScheduledTask editTask = task.Clone();
     WlbEditScheduledTask taskEditor = new WlbEditScheduledTask(editTask);
     DialogResult dr = taskEditor.ShowDialog();
     if (DialogResult.OK == dr)
     {
         WlbScheduledTask checkTask = CheckForDuplicateTask(editTask);
         if (null != checkTask)
         {
             using (var dlg = new ThreeButtonDialog(
                new ThreeButtonDialog.Details(
                    SystemIcons.Warning,
                    Messages.WLB_TASK_SCHEDULE_CONFLICT_BLURB,
                    Messages.WLB_TASK_SCHEDULE_CONFLICT_TITLE)))
             {
                 dlg.ShowDialog(this);
             }
             SelectTask(checkTask.TaskId);
         }
         else
         {
             editTask.LastTouchedBy = _pool.Connection.Username;
             editTask.LastTouched = DateTime.UtcNow;
             _scheduledTasks.TaskList[editTask.TaskId.ToString()] = editTask;
             PopulateListView();
             _hasChanged = true;
         }
     }
 }
예제 #13
0
        private void buttonAuthorize_Click(object sender, EventArgs e)
        {
            try
            {
                Exception delegateException = null;
                log.Debug("Testing logging in with the new credentials");
                DelegatedAsyncAction loginAction = new DelegatedAsyncAction(connection,
                                                                            Messages.AUTHORIZING_USER,
                                                                            Messages.CREDENTIALS_CHECKING,
                                                                            Messages.CREDENTIALS_CHECK_COMPLETE,
                                                                            delegate
                {
                    try
                    {
                        elevatedSession = connection.ElevatedSession(TextBoxUsername.Text.Trim(), TextBoxPassword.Text);
                    }
                    catch (Exception ex)
                    {
                        delegateException = ex;
                    }
                });

                using (var dlg = new ActionProgressDialog(loginAction, ProgressBarStyle.Marquee, false))
                    dlg.ShowDialog(this);

                // The exception would have been handled by the action progress dialog, just return the user to the sudo dialog
                if (loginAction.Exception != null)
                {
                    return;
                }

                if (HandledAnyDelegateException(delegateException))
                {
                    return;
                }

                if (elevatedSession.IsLocalSuperuser || SessionAuthorized(elevatedSession))
                {
                    elevatedUsername = TextBoxUsername.Text.Trim();
                    elevatedPassword = TextBoxPassword.Text;
                    DialogResult     = DialogResult.OK;
                    Close();
                    return;
                }

                ShowNotAuthorisedDialog();
            }
            catch (Exception ex)
            {
                log.DebugFormat("Exception when attempting to sudo action: {0} ", ex);
                using (var dlg = new ThreeButtonDialog(
                           new ThreeButtonDialog.Details(
                               SystemIcons.Error,
                               String.Format(Messages.USER_AUTHORIZATION_FAILED, TextBoxUsername.Text),
                               Messages.XENCENTER)))
                {
                    dlg.ShowDialog(Parent);
                }

                TextBoxPassword.Focus();
                TextBoxPassword.SelectAll();
            }
            finally
            {
                // Check whether we have a successful elevated session and whether we have been asked to log it out
                // If non successful (most likely the new subject is not authorized) then log it out anyway.
                if (elevatedSession != null && DialogResult != DialogResult.OK)
                {
                    elevatedSession.Connection.Logout(elevatedSession);
                    elevatedSession = null;
                }
            }
        }
예제 #14
0
        private void toolStripButtonExportAll_Click(object sender, EventArgs e)
        {
            bool exportAll = true;

            if (FilterIsOn)
            {
                using (var dlog = new ThreeButtonDialog(
                           new ThreeButtonDialog.Details(null, Messages.ALERT_EXPORT_ALL_OR_FILTERED),
                           new ThreeButtonDialog.TBDButton(Messages.ALERT_EXPORT_ALL_BUTTON, DialogResult.Yes),
                           new ThreeButtonDialog.TBDButton(Messages.ALERT_EXPORT_FILTERED_BUTTON, DialogResult.No, ThreeButtonDialog.ButtonType.NONE),
                           ThreeButtonDialog.ButtonCancel))
                {
                    var result = dlog.ShowDialog(this);
                    if (result == DialogResult.No)
                    {
                        exportAll = false;
                    }
                    else if (result == DialogResult.Cancel)
                    {
                        return;
                    }
                }
            }

            string fileName;

            using (SaveFileDialog dialog = new SaveFileDialog
            {
                AddExtension = true,
                Filter = string.Format("{0} (*.csv)|*.csv|{1} (*.*)|*.*",
                                       Messages.CSV_DESCRIPTION, Messages.ALL_FILES),
                FilterIndex = 0,
                Title = Messages.EXPORT_ALL,
                RestoreDirectory = true,
                DefaultExt = "csv",
                CheckPathExists = false,
                OverwritePrompt = true
            })
            {
                if (dialog.ShowDialog(this) != DialogResult.OK)
                {
                    return;
                }
                fileName = dialog.FileName;
            }

            new DelegatedAsyncAction(null,
                                     string.Format(Messages.EXPORT_SYSTEM_ALERTS, fileName),
                                     string.Format(Messages.EXPORTING_SYSTEM_ALERTS, fileName),
                                     string.Format(Messages.EXPORTED_SYSTEM_ALERTS, fileName),
                                     delegate
            {
                using (StreamWriter stream = new StreamWriter(fileName, false, UTF8Encoding.UTF8))
                {
                    stream.WriteLine("{0},{1},{2},{3},{4}", Messages.TITLE,
                                     Messages.SEVERITY, Messages.DESCRIPTION,
                                     Messages.APPLIES_TO, Messages.TIMESTAMP);

                    if (exportAll)
                    {
                        foreach (Alert a in Alert.Alerts)
                        {
                            stream.WriteLine(GetAlertDetailsCSVQuotes(a));
                        }
                    }
                    else
                    {
                        foreach (DataGridViewRow row in GridViewAlerts.Rows)
                        {
                            var a = row.Tag as Alert;
                            if (a != null)
                            {
                                stream.WriteLine(GetAlertDetailsCSVQuotes(a));
                            }
                        }
                    }
                }
            }).RunAsync();
        }
예제 #15
0
        /// <summary>
        /// Called with the results of an iSCSI SR.probe(), either immediately after the scan, or after the
        /// user has performed a scan, clicked 'cancel' on a dialog, and then clicked 'next' again (this
        /// avoids duplicate probing if none of the settings have changed).
        /// </summary>
        /// <returns>
        /// Whether to continue or not - wheter to format or not is stored in
        /// iScsiFormatLUN.
        /// </returns>
        private bool ExamineIscsiProbeResults(SrProbeAction action)
        {
            _srToIntroduce = null;

            if (!action.Succeeded)
            {
                Exception exn = action.Exception;
                log.Warn(exn, exn);
                Failure failure = exn as Failure;
                if (failure != null && failure.ErrorDescription[0] == "SR_BACKEND_FAILURE_140")
                {
                    errorIconAtHostOrIP.Visible  = true;
                    errorLabelAtHostname.Visible = true;
                    errorLabelAtHostname.Text    = Messages.INVALID_HOST;
                    textBoxIscsiHost.Focus();
                }
                else if (failure != null)
                {
                    errorIconAtHostOrIP.Visible  = true;
                    errorLabelAtHostname.Visible = true;
                    errorLabelAtHostname.Text    = failure.ErrorDescription.Count > 2 ? failure.ErrorDescription[2] : failure.ErrorDescription[0];
                    textBoxIscsiHost.Focus();
                }
                return(false);
            }

            try
            {
                List <SR.SRInfo> SRs = SR.ParseSRListXML(action.Result);

                if (!String.IsNullOrEmpty(SrWizardType.UUID))
                {
                    // Check LUN contains correct SR
                    if (SRs.Count == 1 && SRs[0].UUID == SrWizardType.UUID)
                    {
                        _srToIntroduce = SRs[0];
                        return(true);
                    }

                    errorIconAtTargetLUN.Visible  = true;
                    errorLabelAtTargetLUN.Visible = true;
                    errorLabelAtTargetLUN.Text    = String.Format(Messages.INCORRECT_LUN_FOR_SR, SrWizardType.SrName);

                    return(false);
                }
                else if (SRs.Count == 0)
                {
                    // No existing SRs were found on this LUN. If allowed to create new SR, ask the user if they want to proceed and format.
                    if (!SrWizardType.AllowToCreateNewSr)
                    {
                        using (var dlg = new ThreeButtonDialog(
                                   new ThreeButtonDialog.Details(SystemIcons.Error, Messages.NEWSR_LUN_HAS_NO_SRS, Messages.XENCENTER)))
                        {
                            dlg.ShowDialog(this);
                        }

                        return(false);
                    }
                    DialogResult result = DialogResult.Yes;
                    if (!Program.RunInAutomatedTestMode)
                    {
                        using (var dlg = new ThreeButtonDialog(
                                   new ThreeButtonDialog.Details(SystemIcons.Warning, Messages.NEWSR_ISCSI_FORMAT_WARNING, this.Text),
                                   ThreeButtonDialog.ButtonYes,
                                   new ThreeButtonDialog.TBDButton(Messages.NO_BUTTON_CAPTION, DialogResult.No, ThreeButtonDialog.ButtonType.CANCEL, true)))
                        {
                            result = dlg.ShowDialog(this);
                        }
                    }

                    return(result == DialogResult.Yes);
                }
                else
                {
                    // There should be 0 or 1 SRs on the LUN
                    System.Diagnostics.Trace.Assert(SRs.Count == 1);

                    // CA-17230
                    // Check this isn't a detached SR
                    SR.SRInfo info = SRs[0];
                    SR        sr   = SrWizardHelpers.SrInUse(info.UUID);
                    if (sr != null)
                    {
                        DialogResult res;
                        using (var d = new ThreeButtonDialog(
                                   new ThreeButtonDialog.Details(null, string.Format(Messages.DETACHED_ISCI_DETECTED, Helpers.GetName(sr.Connection))),
                                   new ThreeButtonDialog.TBDButton(Messages.ATTACH_SR, DialogResult.OK),
                                   ThreeButtonDialog.ButtonCancel))
                        {
                            res = d.ShowDialog(Program.MainWindow);
                        }

                        if (res == DialogResult.Cancel)
                        {
                            return(false);
                        }

                        _srToIntroduce = info;
                        return(true);
                    }

                    // An SR exists on this LUN. Ask the user if they want to attach it, format it and
                    // create a new SR, or cancel.
                    DialogResult result = Program.RunInAutomatedTestMode ? DialogResult.Yes :
                                          new IscsiChoicesDialog(Connection, info).ShowDialog(this);

                    switch (result)
                    {
                    case DialogResult.Yes:
                        // Reattach
                        _srToIntroduce = SRs[0];
                        return(true);

                    case DialogResult.No:
                        // Format - SrToIntroduce is already null
                        return(true);

                    default:
                        return(false);
                    }
                }
            }
            catch
            {
                // We really want to prevent the user getting to the next step if there is any kind of
                // exception here, since clicking 'finish' might destroy data: require another probe.
                return(false);
            }
        }
예제 #16
0
        /// <summary>
        /// If the answer of the user to the dialog is YES, then make a list with all the updates and call 
        /// DismissUpdates on that list.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dismissAllToolStripMenuItem_Click(object sender, EventArgs e)
        {

            DialogResult result;

            if (!FilterIsOn)
            {
                using (var dlog = new ThreeButtonDialog(
                    new ThreeButtonDialog.Details(null, Messages.UPDATE_DISMISS_ALL_NO_FILTER_CONTINUE),
                    new ThreeButtonDialog.TBDButton(Messages.DISMISS_ALL_YES_CONFIRM_BUTTON, DialogResult.Yes),
                    ThreeButtonDialog.ButtonCancel))
                {
                    result = dlog.ShowDialog(this);
                }
            }
            else
            {
                using (var dlog = new ThreeButtonDialog(
                    new ThreeButtonDialog.Details(null, Messages.UPDATE_DISMISS_ALL_CONTINUE),
                    new ThreeButtonDialog.TBDButton(Messages.DISMISS_ALL_CONFIRM_BUTTON, DialogResult.Yes),
                    new ThreeButtonDialog.TBDButton(Messages.DISMISS_FILTERED_CONFIRM_BUTTON, DialogResult.No, ThreeButtonDialog.ButtonType.NONE),
                    ThreeButtonDialog.ButtonCancel))
                {
                    result = dlog.ShowDialog(this);
                }
            }

            if (result == DialogResult.Cancel)
                return;

            var alerts = result == DialogResult.No
                         ? from DataGridViewRow row in dataGridViewUpdates.Rows select row.Tag as Alert
                         : Updates.UpdateAlerts;

            DismissUpdates(alerts);
        }
예제 #17
0
        private void ToolStripMenuItemDismiss_Click(object sender, EventArgs e)
        {
            if (dataGridViewUpdates.SelectedRows.Count != 1)
                log.DebugFormat("Only 1 update can be dismissed at a time (Attempted to dismiss {0}). Dismissing the clicked item.", dataGridViewUpdates.SelectedRows.Count);

            DataGridViewRow clickedRow = FindAlertRow(sender as ToolStripMenuItem);
            if (clickedRow == null)
            {
                log.Debug("Attempted to dismiss update with no update selected.");
                return;
            }

            Alert alert = (Alert)clickedRow.Tag;
            if (alert == null)
                return;

            using (var dlog = new ThreeButtonDialog(
                    new ThreeButtonDialog.Details(null, Messages.UPDATE_DISMISS_CONFIRM, Messages.XENCENTER),
                    ThreeButtonDialog.ButtonYes,
                    ThreeButtonDialog.ButtonNo))
            {
                if (dlog.ShowDialog(this) != DialogResult.Yes)
                    return;
            }

            DismissUpdates(new List<Alert> { (Alert)clickedRow.Tag });
        }
예제 #18
0
        private void CheckVersionCompatibility()
        {
            statusLabel.Text = Messages.CONVERSION_VERSION_CHECK;

            ThreadPool.QueueUserWorkItem(obj =>
            {
                const int sleep = 3000, timeout = 120000;
                var tries       = timeout / sleep;

                Exception ex   = null;
                string version = null;

                while (tries > 0)
                {
                    try
                    {
                        version = _conversionClient.GetVpxVersion();

                        if (!string.IsNullOrEmpty(version))
                        {
                            break;
                        }
                    }
                    catch (Exception e)
                    {
                        ex = e;
                    }

                    Thread.Sleep(sleep);
                    tries--;
                }

                if (string.IsNullOrEmpty(version))
                {
                    log.Error("Cannot retrieve XCM VPX version.", ex);

                    Program.Invoke(this, () =>
                    {
                        statusLabel.Image = Images.StaticImages._000_error_h32bit_16;
                        statusLabel.Text  = Messages.CONVERSION_VERSION_CHECK_FAILURE;
                        statusLinkLabel.Reset();
                    });

                    return;
                }

                Program.Invoke(this, () =>
                {
                    if (!Version.TryParse(version, out Version result) ||
                        result.CompareTo(new Version(Branding.ConversionVpxMinimumSupportedVersion)) < 0)
                    {
                        statusLabel.Image = Images.StaticImages._000_error_h32bit_16;
                        statusLabel.Text  = Messages.CONVERSION_VERSION_INCOMPATIBILITY;
                        statusLinkLabel.Reset(Messages.MORE_INFO, () =>
                        {
                            using (var dlog = new ThreeButtonDialog(
                                       new ThreeButtonDialog.Details(null, Messages.CONVERSION_VERSION_INCOMPATIBILITY_INFO)))
                            {
                                dlog.ShowDialog(this);
                            }
                        });
                        return;
                    }

                    statusLabel.Image = Images.StaticImages.ConversionManager;
                    statusLabel.Text  = Messages.CONVERSION_CONNECTING_VPX_SUCCESS;
                    statusLinkLabel.Reset();

                    timerVpx.Start();
                    FetchConversionHistory();
                });
            });
        }
예제 #19
0
        private void AddTask()
        {
            WlbEditScheduledTask addTask = new WlbEditScheduledTask(_newTaskId--, WlbScheduledTask.WlbTaskActionType.SetOptimizationMode);
            DialogResult dr = addTask.ShowDialog();
            if (DialogResult.OK == dr)
            {
                WlbScheduledTask newTask = addTask.Task;
                newTask.Owner = _pool.Connection.Username;
                newTask.LastTouchedBy = _pool.Connection.Username;
                newTask.AddTaskParameter("PoolUUID", _pool.uuid);

                WlbScheduledTask checkTask = CheckForDuplicateTask(newTask);
                if (null != checkTask)
                {
                    using (var dlg = new ThreeButtonDialog(
                       new ThreeButtonDialog.Details(
                           SystemIcons.Warning,
                           Messages.WLB_TASK_SCHEDULE_CONFLICT_BLURB,
                           Messages.WLB_TASK_SCHEDULE_CONFLICT_TITLE)))
                    {
                        dlg.ShowDialog(this);
                    }
                    SelectTask(checkTask.TaskId);
                }
                else
                {
                    _scheduledTasks.TaskList.Add(newTask.TaskId.ToString(), newTask);
                    PopulateListView();
                    _hasChanged = true;
                }
            }
        }
예제 #20
0
        private void toolStripButtonExport_Click(object sender, EventArgs e)
        {
            bool exportAll = true;

            if (FilterIsOn)
            {
                using (var dlog = new ThreeButtonDialog(
                           new ThreeButtonDialog.Details(null, Messages.CONVERSION_EXPORT_ALL_OR_FILTERED),
                           new ThreeButtonDialog.TBDButton(Messages.EXPORT_ALL_BUTTON, DialogResult.Yes),
                           new ThreeButtonDialog.TBDButton(Messages.EXPORT_FILTERED_BUTTON, DialogResult.No, ThreeButtonDialog.ButtonType.NONE),
                           ThreeButtonDialog.ButtonCancel))
                {
                    var result = dlog.ShowDialog(this);

                    if (result == DialogResult.No)
                    {
                        exportAll = false;
                    }
                    else if (result == DialogResult.Cancel)
                    {
                        return;
                    }
                }
            }

            string fileName;

            using (SaveFileDialog dialog = new SaveFileDialog
            {
                AddExtension = true,
                Filter = string.Format("{0} (*.csv)|*.csv|{1} (*.txt)|*.txt|{2} (*.*)|*.*",
                                       Messages.CSV_DESCRIPTION, Messages.TXT_DESCRIPTION, Messages.ALL_FILES),
                FilterIndex = 0,
                Title = Messages.EXPORT_ALL,
                RestoreDirectory = true,
                DefaultExt = "csv",
                CheckPathExists = false,
                OverwritePrompt = true
            })
            {
                if (dialog.ShowDialog(this) != DialogResult.OK)
                {
                    return;
                }
                fileName = dialog.FileName;
            }

            new DelegatedAsyncAction(null,
                                     string.Format(Messages.CONVERSION_EXPORT, fileName),
                                     string.Format(Messages.CONVERSION_EXPORTING, fileName),
                                     string.Format(Messages.CONVERSION_EXPORTED, fileName),
                                     s =>
            {
                using (StreamWriter stream = new StreamWriter(fileName, false, Encoding.UTF8))
                {
                    stream.WriteLine(string.Join(",", DetailHeaders.Select(v => $"\"{v}\"")));

                    if (exportAll)
                    {
                        var exportable = new List <Conversion>(CurrentConversionList);
                        foreach (var conv in exportable)
                        {
                            stream.WriteLine(string.Join(",", GetDetailValues(conv).Select(v => $"\"{v}\"")));
                        }
                    }
                    else
                    {
                        foreach (ConversionRow row in dataGridViewConversions.Rows)
                        {
                            if (row != null)
                            {
                                stream.WriteLine(string.Join(",", GetDetailValues(row.Conversion).Select(v => $"\"{v}\"")));
                            }
                        }
                    }
                }
            }).RunAsync();
        }
예제 #21
0
        private void OkButton_Click(object sender, EventArgs e)
        {
            if (SrListBox.SR == null || SelectionNull || NameTextBox.Text == "" || !connection.IsConnected)
            {
                return;
            }

            if (DontCreateVDI)
            {
                DialogResult = DialogResult.OK;
                Close();
                return;
            }
            XenAPI.SR sr = SrListBox.SR;
            if (!sr.shared && TheVM != null && TheVM.HaPriorityIsRestart())
            {
                DialogResult dialogResult;
                using (var dlg = new ThreeButtonDialog(
                           new ThreeButtonDialog.Details(SystemIcons.Warning, Messages.NEW_SR_DIALOG_ATTACH_NON_SHARED_DISK_HA, Messages.XENCENTER),
                           ThreeButtonDialog.ButtonYes,
                           ThreeButtonDialog.ButtonNo))
                {
                    dialogResult = dlg.ShowDialog(Program.MainWindow);
                }
                if (dialogResult != DialogResult.Yes)
                {
                    return;
                }
                new HAUnprotectVMAction(TheVM).RunExternal(TheVM.Connection.Session);
            }

            VDI vdi = NewDisk();

            if (TheVM != null)
            {
                if (sr.other_config.ContainsKey("scheduler"))
                {
                    if (sr.other_config.ContainsKey("scheduler") && sr.other_config["scheduler"] == "cfq")
                    {
                        //获取原class值(优先级)
                        List <XenRef <VBD> > origin_VBDs = TheVM.VBDs;
                        foreach (VBD v in connection.ResolveAll <VBD>(origin_VBDs))
                        {
                            if (v.type == vbd_type.CD)
                            {
                                continue;
                            }
                            if (XenAPI.VBD.get_qos_algorithm_params(TheVM.Connection.Session, v.opaque_ref).ContainsKey("class"))
                            {
                                if (XenAPI.VBD.get_qos_algorithm_params(sr.Connection.Session, v.opaque_ref)["class"] != "" && XenAPI.VBD.get_qos_algorithm_params(sr.Connection.Session, v.opaque_ref)["class"] != null)
                                {
                                    _class = XenAPI.VBD.get_qos_algorithm_params(sr.Connection.Session, v.opaque_ref)["class"];
                                }
                            }
                        }
                    }
                }
            }
            if (TheVM != null)
            {
                var alreadyHasBootableDisk = HasBootableDisk(TheVM);

                Actions.DelegatedAsyncAction action = new Actions.DelegatedAsyncAction(connection,
                                                                                       string.Format(Messages.ACTION_DISK_ADDING_TITLE, NameTextBox.Text, sr.NameWithoutHost),
                                                                                       Messages.ACTION_DISK_ADDING, Messages.ACTION_DISK_ADDED,
                                                                                       delegate(XenAPI.Session session)
                {
                    // Get legitimate unused userdevice numbers
                    string[] uds = XenAPI.VM.get_allowed_VBD_devices(session, TheVM.opaque_ref);
                    if (uds.Length == 0)
                    {
                        throw new Exception(FriendlyErrorNames.VBDS_MAX_ALLOWED);
                    }
                    string ud      = uds[0];
                    string vdiref  = VDI.create(session, vdi);
                    XenAPI.VBD vbd = NewDevice();
                    vbd.VDI        = new XenAPI.XenRef <XenAPI.VDI>(vdiref);
                    vbd.VM         = new XenAPI.XenRef <XenAPI.VM>(TheVM);

                    // CA-44959: only make bootable if there aren't other bootable VBDs.
                    vbd.bootable   = ud == "0" && !alreadyHasBootableDisk;
                    vbd.userdevice = ud;
                    // Now try to plug the VBD.
                    //new XenAdmin.Actions.VbdSaveAndPlugAction(TheVM, vbd, vdi.Name, session, false, ShowMustRebootBoxCD, ShowVBDWarningBox).RunAsync();
                    new XenAdmin.Actions.VbdSaveAndPlugAction(TheVM, vbd, vdi.Name, session, false, ShowMustRebootBoxCD, ShowVBDWarningBox).RunExternal(connection.Session);
                });
                action.VM = TheVM;
                using (var dialog = new Dialogs.ActionProgressDialog(action, ProgressBarStyle.Blocks))
                {
                    dialog.ShowDialog(this);
                }
                if (!action.Succeeded)
                {
                    return;
                }
            }
            else
            {
                CreateDiskAction action = new CreateDiskAction(vdi);
                new Dialogs.ActionProgressDialog(action, ProgressBarStyle.Marquee).ShowDialog();
                if (!action.Succeeded)
                {
                    return;
                }
            }
            DialogResult = DialogResult.OK;
            Close();
            //若VM为空则不设置优先级
            //若虚拟机启用了IO功能才进行下列操作
            if (TheVM != null)
            {
                if (TheVM.other_config.ContainsKey("io_limit") || sr.other_config.ContainsKey("scheduler"))
                {
                    foreach (VBD v in connection.ResolveAll <VBD>(TheVM.VBDs))
                    {
                        if (v.type == vbd_type.CD)
                        {
                            continue;
                        }
                        if (XenAPI.VBD.get_qos_algorithm_params(connection.Session, v.opaque_ref).ContainsKey("class"))
                        {
                            XenAPI.VBD.remove_from_qos_algorithm_params(connection.Session, v.opaque_ref, "class");
                        }
                        if (XenAPI.VBD.get_qos_algorithm_params(connection.Session, v.opaque_ref).ContainsKey("sched"))
                        {
                            XenAPI.VBD.remove_from_qos_algorithm_params(connection.Session, v.opaque_ref, "sched");
                        }
                        if (XenAPI.VBD.get_qos_algorithm_type(connection.Session, v.opaque_ref) != null)
                        {
                            XenAPI.VBD.set_qos_algorithm_type(connection.Session, v.opaque_ref, "");
                        }
                        XenAPI.VBD.set_qos_algorithm_type(connection.Session, v.opaque_ref, "ionice");
                        XenAPI.VBD.add_to_qos_algorithm_params(connection.Session, v.opaque_ref, "sched", "rt");
                        XenAPI.VBD.add_to_qos_algorithm_params(connection.Session, v.opaque_ref, "class", _class);
                    }
                    if (TheVM.power_state == vm_power_state.Running)
                    {
                        io_limit();
                    }
                }
            }
        }
예제 #22
0
        private void OkButton_Click(object sender, EventArgs e)
        {
            if (SrListBox.SR == null || SelectionNull || NameTextBox.Text == "" || !connection.IsConnected)
            {
                return;
            }

            if (DontCreateVDI)
            {
                DialogResult = DialogResult.OK;
                Close();
                return;
            }
            XenAPI.SR sr = SrListBox.SR;
            if (!sr.shared && TheVM != null && TheVM.HaPriorityIsRestart())
            {
                DialogResult dialogResult;
                using (var dlg = new ThreeButtonDialog(
                           new ThreeButtonDialog.Details(SystemIcons.Warning, Messages.NEW_SR_DIALOG_ATTACH_NON_SHARED_DISK_HA, Messages.XENCENTER),
                           ThreeButtonDialog.ButtonYes,
                           ThreeButtonDialog.ButtonNo))
                {
                    dialogResult = dlg.ShowDialog(Program.MainWindow);
                }
                if (dialogResult != DialogResult.Yes)
                {
                    return;
                }
                new HAUnprotectVMAction(TheVM).RunExternal(TheVM.Connection.Session);
            }

            VDI vdi = NewDisk();


            if (TheVM != null)
            {
                var alreadyHasBootableDisk = HasBootableDisk(TheVM);

                Actions.DelegatedAsyncAction action = new Actions.DelegatedAsyncAction(connection,
                                                                                       string.Format(Messages.ACTION_DISK_ADDING_TITLE, NameTextBox.Text, sr.NameWithoutHost()),
                                                                                       Messages.ACTION_DISK_ADDING, Messages.ACTION_DISK_ADDED,
                                                                                       delegate(XenAPI.Session session)
                {
                    // Get legitimate unused userdevice numbers
                    string[] uds = XenAPI.VM.get_allowed_VBD_devices(session, TheVM.opaque_ref);
                    if (uds.Length == 0)
                    {
                        throw new Exception(FriendlyErrorNames.VBDS_MAX_ALLOWED);
                    }
                    string ud      = uds[0];
                    string vdiref  = VDI.create(session, vdi);
                    XenAPI.VBD vbd = NewDevice();
                    vbd.VDI        = new XenAPI.XenRef <XenAPI.VDI>(vdiref);
                    vbd.VM         = new XenAPI.XenRef <XenAPI.VM>(TheVM);

                    // CA-44959: only make bootable if there aren't other bootable VBDs.
                    vbd.bootable   = ud == "0" && !alreadyHasBootableDisk;
                    vbd.userdevice = ud;

                    // Now try to plug the VBD.
                    new XenAdmin.Actions.VbdSaveAndPlugAction(TheVM, vbd, vdi.Name(), session, false, ShowMustRebootBoxCD, ShowVBDWarningBox).RunAsync();
                });
                action.VM = TheVM;
                new Dialogs.ActionProgressDialog(action, ProgressBarStyle.Blocks).ShowDialog();
                if (!action.Succeeded)
                {
                    return;
                }
            }
            else
            {
                CreateDiskAction action = new CreateDiskAction(vdi);
                new Dialogs.ActionProgressDialog(action, ProgressBarStyle.Marquee).ShowDialog();
                if (!action.Succeeded)
                {
                    return;
                }
            }
            DialogResult = DialogResult.OK;
            Close();
        }
예제 #23
0
        protected override void Execute(List<VM> vms)
        {
            Dictionary<VM, List<VBD>> brokenCDs = new Dictionary<VM, List<VBD>>();
            foreach (VM vm in vms)
            {
                foreach (VBD vbd in vm.Connection.ResolveAll<VBD>(vm.VBDs))
                {
                    if (vbd.type == vbd_type.CD && !vbd.empty)
                    {
                        VDI vdi = vm.Connection.Resolve<VDI>(vbd.VDI);
                        SR sr = null;
                        if (vdi != null)
                            sr = vm.Connection.Resolve<SR>(vdi.SR);
                        if (vdi == null || sr.IsBroken(true) || sr.IsDetached)
                        {
                            if (!brokenCDs.ContainsKey(vm))
                            {
                                brokenCDs.Add(vm, new List<VBD>());
                            }

                            brokenCDs[vm].Add(vbd);
                        }
                    }
                }
            }
            if (brokenCDs.Count > 0)
            {
                DialogResult d;
                using (var dlg = new ThreeButtonDialog(
                    new ThreeButtonDialog.Details(null, Messages.EJECT_BEFORE_VM_START_MESSAGE_BOX, vms.Count > 1 ? Messages.STARTING_VMS_MESSAGEBOX_TITLE : Messages.STARTING_VM_MESSAGEBOX_TITLE),
                    new ThreeButtonDialog.TBDButton(Messages.EJECT_BUTTON_LABEL, DialogResult.OK, ThreeButtonDialog.ButtonType.ACCEPT, true),
                    new ThreeButtonDialog.TBDButton(Messages.IGNORE_BUTTON_LABEL, DialogResult.Ignore),
                    ThreeButtonDialog.ButtonCancel))
                {
                    d = dlg.ShowDialog(MainWindowCommandInterface.Form);
                }
                if (d == DialogResult.Cancel)
                    return;
                if (d == DialogResult.Ignore)
                    brokenCDs = null;
            }
            RunAction(vms, Messages.ACTION_VM_STARTING, Messages.ACTION_VM_STARTING, Messages.ACTION_VM_STARTED, brokenCDs);
        }
예제 #24
0
        protected override void ExecuteCore(SelectedItemCollection selection)
        {
            Dictionary<SelectedItem, string> reasons = new Dictionary<SelectedItem, string>();
            foreach (Host host in _hosts)
            {
                PoolJoinRules.Reason reason = PoolJoinRules.CanJoinPool(host.Connection, _pool.Connection, true, true, true);
                if (reason != PoolJoinRules.Reason.Allowed)
                    reasons[new SelectedItem(host)] = PoolJoinRules.ReasonMessage(reason);
            }

            if (reasons.Count > 0)
            {
                string title = Messages.ERROR_DIALOG_ADD_TO_POOL_TITLE;
                string text = string.Format(Messages.ERROR_DIALOG_ADD_TO_POOL_TEXT, Helpers.GetName(_pool).Ellipsise(500));

                new CommandErrorDialog(title, text, reasons).ShowDialog(Parent);
                return;
            }

            if (_confirm && !ShowConfirmationDialog())
            {
                // Bail out if the user doesn't want to continue.
                return;
            }

            if (!Helpers.IsConnected(_pool))
            {
                string message = _hosts.Count == 1
                                     ? string.Format(Messages.ADD_HOST_TO_POOL_DISCONNECTED_POOL,
                                                     Helpers.GetName(_hosts[0]).Ellipsise(500), Helpers.GetName(_pool).Ellipsise(500))
                                     : string.Format(Messages.ADD_HOST_TO_POOL_DISCONNECTED_POOL_MULTIPLE,
                                                     Helpers.GetName(_pool).Ellipsise(500));

                using (var dlg = new ThreeButtonDialog(
                    new ThreeButtonDialog.Details(SystemIcons.Error, message, Messages.XENCENTER)))
                {
                    dlg.ShowDialog(Parent);
                }
                return;
            }

            // Check supp packs and warn
            List<string> badSuppPacks = PoolJoinRules.HomogeneousSuppPacksDiffering(_hosts, _pool);
            if (!HelpersGUI.GetPermissionFor(badSuppPacks, sp => true,
                Messages.ADD_HOST_TO_POOL_SUPP_PACK, Messages.ADD_HOST_TO_POOL_SUPP_PACKS, false, "PoolJoinSuppPacks"))
            {
                return;
            }

            // Are there any hosts which are forbidden from masking their CPUs for licensing reasons?
            // If so, we need to show upsell.
            Host master = Helpers.GetMaster(_pool);
            if (null != _hosts.Find(host =>
                !PoolJoinRules.CompatibleCPUs(host, master, false) &&
                Helpers.FeatureForbidden(host, Host.RestrictCpuMasking) &&
                !PoolJoinRules.FreeHostPaidMaster(host, master, false)))  // in this case we can upgrade the license and then mask the CPU
            {
                using (var  dlg = new UpsellDialog(HiddenFeatures.LinkLabelHidden ? Messages.UPSELL_BLURB_CPUMASKING : Messages.UPSELL_BLURB_CPUMASKING + Messages.UPSELL_BLURB_CPUMASKING_MORE,
                                                    InvisibleMessages.UPSELL_LEARNMOREURL_CPUMASKING))
                    dlg.ShowDialog(Parent);
                return;
            }

            // Get permission for any fix-ups: 1) Licensing free hosts; 2) CPU masking 3) Ad configuration 4) CPU feature levelling (Dundee or higher only)
            // (We already know that these things are fixable because we have been through CanJoinPool() above).
            if (!HelpersGUI.GetPermissionFor(_hosts, host => PoolJoinRules.FreeHostPaidMaster(host, master, false),
                Messages.ADD_HOST_TO_POOL_LICENSE_MESSAGE, Messages.ADD_HOST_TO_POOL_LICENSE_MESSAGE_MULTIPLE, true, "PoolJoinRelicensing")
                ||
                !HelpersGUI.GetPermissionFor(_hosts, host => !PoolJoinRules.CompatibleCPUs(host, master, false),
                Messages.ADD_HOST_TO_POOL_CPU_MASKING_MESSAGE, Messages.ADD_HOST_TO_POOL_CPU_MASKING_MESSAGE_MULTIPLE, true, "PoolJoinCpuMasking")
                ||
                !HelpersGUI.GetPermissionFor(_hosts, host => !PoolJoinRules.CompatibleAdConfig(host, master, false),
                Messages.ADD_HOST_TO_POOL_AD_MESSAGE, Messages.ADD_HOST_TO_POOL_AD_MESSAGE_MULTIPLE, true, "PoolJoinAdConfiguring")
                ||
                !HelpersGUI.GetPermissionForCpuFeatureLevelling(_hosts, _pool))
            {
                return;
            }

            MainWindowCommandInterface.SelectObjectInTree(_pool);

            List<AsyncAction> actions = new List<AsyncAction>();
            foreach (Host host in _hosts)
            {
                string opaque_ref = host.opaque_ref;
                AddHostToPoolAction action = new AddHostToPoolAction(_pool, host, GetAdPrompt, NtolDialog, ApplyLicenseEditionCommand.ShowLicensingFailureDialog);
                action.Completed += s => Program.ShowObject(opaque_ref);
                actions.Add(action);

                // hide connection. If the action fails, re-show it.
                Program.HideObject(opaque_ref);
            }

            RunMultipleActions(actions, string.Format(Messages.ADDING_SERVERS_TO_POOL, _pool.Name), Messages.POOLCREATE_ADDING, Messages.POOLCREATE_ADDED, true);
        }
예제 #25
0
 private void RestoreDefaultGraphs()
 {
     using (ThreeButtonDialog dlog = new ThreeButtonDialog(
             new ThreeButtonDialog.Details(SystemIcons.Warning,
                 Messages.GRAPHS_RESTORE_DEFAULT_MESSAGE,
                 Messages.XENCENTER),
             ThreeButtonDialog.ButtonYes,
             ThreeButtonDialog.ButtonNo))
     {
         if (dlog.ShowDialog(this) == DialogResult.Yes)
             if (GraphList.AuthorizedRole)
             {
                 GraphList.RestoreDefaultGraphs();
                 GraphList.LoadDataSources(SaveGraphs);
             }
     }
 }
예제 #26
0
        private static List <ChangeMemorySettingsAction> ConfirmAndCalcActions(IWin32Window parentWindow, List <VM> VMs, long dynamic_min, long dynamic_max, long static_max, long prev_static_max, bool advanced, bool suppressHistory)
        {
            if (prev_static_max / Util.BINARY_MEGA == static_max / Util.BINARY_MEGA)  // don't want to throw warning dialog just for rounding errors
            {
                if (dynamic_min == static_max)
                {
                    dynamic_min = prev_static_max;
                }
                if (dynamic_max == static_max)
                {
                    dynamic_max = prev_static_max;
                }
                static_max = prev_static_max;
            }
            else
            {
                // If not all VMs Halted, confirm static_max changes, and abort if necessary
                foreach (VM vm in VMs)
                {
                    if (vm.power_state != vm_power_state.Halted)
                    {
                        // Six(!) possible messages depending on the exact configuration.
                        // (Could have an additional message for VMs without ballooning but with tools, e.g. on a free host, for which we can do a
                        // clean shutdown: but having a false positive for the scarier message about force shutdown is not too bad).
                        // We assume that all VMs have the same has_ballooning.
                        string msg;
                        if (advanced)
                        {
                            msg = (VMs.Count == 1 ? Messages.CONFIRM_CHANGE_STATIC_MAX_SINGULAR : Messages.CONFIRM_CHANGE_STATIC_MAX_PLURAL);
                        }
                        else if (vm.has_ballooning && !Helpers.FeatureForbidden(vm, Host.RestrictDMC))
                        {
                            msg = (VMs.Count == 1 ? Messages.CONFIRM_CHANGE_MEMORY_MAX_SINGULAR : Messages.CONFIRM_CHANGE_MEMORY_MAX_PLURAL);
                        }
                        else
                        {
                            msg = (VMs.Count == 1 ? Messages.CONFIRM_CHANGE_MEMORY_SINGULAR : Messages.CONFIRM_CHANGE_MEMORY_PLURAL);
                        }

                        DialogResult dialogResult;
                        using (var dlg = new ThreeButtonDialog(
                                   new ThreeButtonDialog.Details(SystemIcons.Warning, msg, Messages.XENCENTER),
                                   ThreeButtonDialog.ButtonYes,
                                   ThreeButtonDialog.ButtonNo))
                        {
                            dialogResult = dlg.ShowDialog(parentWindow);
                        }
                        if (DialogResult.Yes != dialogResult)
                        {
                            return(null);
                        }
                        break;
                    }
                }
            }

            List <ChangeMemorySettingsAction> actions = new List <ChangeMemorySettingsAction>(VMs.Count);

            foreach (VM vm in VMs)
            {
                ChangeMemorySettingsAction action = new ChangeMemorySettingsAction(
                    vm,
                    string.Format(Messages.ACTION_CHANGE_MEMORY_SETTINGS, vm.Name),
                    (long)vm.memory_static_min, dynamic_min, dynamic_max, static_max, VMOperationCommand.WarningDialogHAInvalidConfig, VMOperationCommand.StartDiagnosisForm, suppressHistory);
                actions.Add(action);
            }

            return(actions);
        }
예제 #27
0
        public bool FiberChannelScan(IWin32Window owner, IXenConnection connection, out List<FibreChannelDevice> devices)
        {
            devices = new List<FibreChannelDevice>();

            Host master = Helpers.GetMaster(connection);
            if (master == null)
                return false;

            FibreChannelProbeAction action = new FibreChannelProbeAction(master, SrType);
            using (var  dialog = new ActionProgressDialog(action, ProgressBarStyle.Marquee))
                dialog.ShowDialog(owner); //Will block until dialog closes, action completed

            if (!action.Succeeded)
                return false;

            try
            {
                devices = FibreChannelProbeParsing.ProcessXML(action.Result);

                if (devices.Count == 0)
                {
                    using (var dlg = new ThreeButtonDialog(
                        new ThreeButtonDialog.Details(SystemIcons.Warning, Messages.FIBRECHANNEL_NO_RESULTS, Messages.XENCENTER)))
                    {
                        dlg.ShowDialog();
                    }

                    return false;
                }
                return true;
            }
            catch (Exception e)
            {
                log.Debug("Exception parsing result of fibre channel scan", e);
                log.Debug(e, e);
                using (var dlg = new ThreeButtonDialog(
                    new ThreeButtonDialog.Details(SystemIcons.Warning, Messages.FIBRECHANNEL_XML_ERROR, Messages.XENCENTER)))
                {
                    dlg.ShowDialog();
                }

                return false;
            }
        }
        private void ScanForSRs(SR.SRTypes type)
        {
            var srs = new List<SR.SRInfo>();

            switch (type)
            {
                case SR.SRTypes.lvmohba:
                    var devices = FiberChannelScan();
                    if (devices != null && devices.Count > 0)
                    {
                        foreach (FibreChannelDevice device in devices)
                        {
                            string deviceId = string.IsNullOrEmpty(device.SCSIid) ? device.Path : device.SCSIid;
                            var metadataSrs = ScanDeviceForSRs(SR.SRTypes.lvmohba, deviceId, GetFCDeviceConfig(device));
                            if (metadataSrs != null && metadataSrs.Count > 0)
                                srs.AddRange(metadataSrs);
                        }
                    }
                    AddScanResultsToDataGridView(srs, SR.SRTypes.lvmohba);
                    break;

                case SR.SRTypes.lvmoiscsi:
                    using (var dialog = new IscsiDeviceConfigDialog(Connection))
                    {
                        if (dialog.ShowDialog(this) == DialogResult.OK)
                        {
                            Dictionary<String, String> dconf = dialog.DeviceConfig;
                            string deviceId = string.IsNullOrEmpty(dconf[SCSIID]) ? dconf[LUNSERIAL] : dconf[SCSIID];

                            var metadataSrs = ScanDeviceForSRs(SR.SRTypes.lvmoiscsi, deviceId, dconf);
                            if (metadataSrs != null && metadataSrs.Count > 0)
                                srs.AddRange(metadataSrs);
                        }
                    }
                    AddScanResultsToDataGridView(srs, SR.SRTypes.lvmoiscsi);
                    break;
            }

            if (srs.Count == 0)
                using (var dlg = new ThreeButtonDialog(
                    new ThreeButtonDialog.Details(SystemIcons.Information,
                        Messages.DR_WIZARD_STORAGEPAGE_SCAN_RESULT_NONE,
                        Messages.XENCENTER)))
                {
                    dlg.ShowDialog(this);
                }
        }
예제 #29
0
        internal void EditWLB(Pool pool)
        {
            // Do nothing if there is a WLB action in progress
            if (HelpersGUI.FindActiveWLBAction(pool.Connection) != null)
            {
                log.Debug("Not opening WLB dialog: an WLB action is in progress");
                return;
            }

            if (!pool.Connection.IsConnected)
            {
                log.Debug("Not opening WLB dialog: the connection to the pool is now closed");
                return;
            }

            try
            {
                WlbConfigurationDialog wlbConfigDialog = new WlbConfigurationDialog(pool);
                DialogResult dr = wlbConfigDialog.ShowDialog();

                if (dr == DialogResult.OK)
                {
                    _wlbPoolConfiguration = wlbConfigDialog.WlbPoolConfiguration;

                    //check to see if the current opt mode matches the current schedule
                    if (_wlbPoolConfiguration.AutomateOptimizationMode)
                    {
                        WlbPoolPerformanceMode scheduledPerfMode = _wlbPoolConfiguration.ScheduledTasks.GetCurrentScheduledPerformanceMode();
                        if (scheduledPerfMode != _wlbPoolConfiguration.PerformanceMode)
                        {
                            string blurb = string.Format(Messages.WLB_PROMPT_FOR_MODE_CHANGE_BLURB, getOptModeText(scheduledPerfMode), getOptModeText(_wlbPoolConfiguration.PerformanceMode));
                            DialogResult drModeCheck = new ThreeButtonDialog(
                                new ThreeButtonDialog.Details(null, blurb, Messages.WLB_PROMPT_FOR_MODE_CHANGE_CAPTION),
                                ThreeButtonDialog.ButtonYes,
                                ThreeButtonDialog.ButtonNo).ShowDialog(this);

                            if (drModeCheck == DialogResult.Yes)
                            {
                                _wlbPoolConfiguration.PerformanceMode = scheduledPerfMode;
                            }
                        }
                    }
                    SaveWLBConfig(_wlbPoolConfiguration);
                }
            }
            catch (Exception ex)
            {
                log.Debug("Unable to open the WLB configuration dialog.", ex);
                return;
            }

            if (!(WlbServerState.GetState(_pool) == WlbServerState.ServerState.NotConfigured))
            {
                RetrieveConfiguration();
            }
        }
예제 #30
0
        private void deleteSavedSearch_Click(object sender, EventArgs e)
        {
            var item = sender as ToolStripItem;
            if (item == null)
                return;

            var search = item.Tag as Search;
            if (search == null)
                return;

            using (var dlog = new ThreeButtonDialog(
                    new ThreeButtonDialog.Details(SystemIcons.Warning,
                        String.Format(Messages.DELETE_SEARCH_PROMPT, search.Name),
                        String.Format(Messages.DELETE_SEARCH, search.Name)),
                    ThreeButtonDialog.ButtonYes,
                    ThreeButtonDialog.ButtonNo))
            {
                if (dlog.ShowDialog(this) == DialogResult.Yes)
                    new SearchAction(search, SearchAction.Operation.delete).RunAsync();
            }
        }
예제 #31
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="connection"></param>
        /// <param name="vm">The VM to export.</param>
        /// <param name="host">Used for filtering purposes. May be null.</param>
        private void Execute(IXenConnection connection, VM vm, Host host)
        {
            /*
             * These properties have not been copied over to the new save file dialog.
             *  
            dlg.AddExtension = true;
            dlg.CheckPathExists = true;
            dlg.CreatePrompt = false;
            dlg.CheckFileExists = false;
            dlg.OverwritePrompt = true;
            dlg.ValidateNames = true;*/

            string filename;
            bool verify;

            // Showing this dialog has the (undocumented) side effect of changing the working directory
            // to that of the file selected. This means a handle to the directory persists, making
            // it undeletable until the program exits, or the working dir moves on. So, save and
            // restore the working dir...
            String oldDir = "";
            try
            {
                oldDir = Directory.GetCurrentDirectory();
                while (true)
                {
                    ExportVMDialog dlg = new ExportVMDialog();
                    dlg.DefaultExt = "xva";
                    dlg.Filter = Messages.MAINWINDOW_XVA_BLURB;
                    dlg.Title = Messages.MAINWINDOW_XVA_TITLE;

                    if (dlg.ShowDialog(Parent) != DialogResult.OK)
                        return;

                    filename = dlg.FileName;
                    verify = dlg.Verify;

                    // CA-12975: Warn the user if the export operation does not have enough disk space to
                    // complete.  This is an approximation only.
                    Win32.DiskSpaceInfo diskSpaceInfo = Win32.GetDiskSpaceInfo(dlg.FileName);

                    if (diskSpaceInfo == null)
                    {
                        // Could not determine free disk space. Carry on regardless.
                        break;
                    }
                    else
                    {
                        ulong freeSpace = diskSpaceInfo.FreeBytesAvailable;
                        decimal neededSpace = vm.GetRecommendedExportSpace(Properties.Settings.Default.ShowHiddenVMs);
                        ulong spaceLeft = 100 * Util.BINARY_MEGA; // We want the user to be left with some disk space afterwards
                        if (neededSpace >= freeSpace - spaceLeft)
                        {
                            string msg = string.Format(Messages.CONFIRM_EXPORT_NOT_ENOUGH_MEMORY, Util.DiskSizeString((long)neededSpace),
                                Util.DiskSizeString((long)freeSpace), vm.Name);

                            DialogResult dr = new ThreeButtonDialog(
                                new ThreeButtonDialog.Details(SystemIcons.Warning, msg),
                                "ExportVmDialogInsufficientDiskSpace",
                                new ThreeButtonDialog.TBDButton(Messages.CONTINUE_WITH_EXPORT, DialogResult.OK),
                                new ThreeButtonDialog.TBDButton(Messages.CHOOSE_ANOTHER_DESTINATION, DialogResult.Retry),
                                ThreeButtonDialog.ButtonCancel).ShowDialog(Parent);

                            if (dr == DialogResult.Retry)
                            {
                                continue;
                            }
                            else if (dr == DialogResult.Cancel)
                            {
                                return;
                            }
                        }
                        if (diskSpaceInfo.IsFAT && neededSpace > (4 * Util.BINARY_GIGA) - 1)
                        {
                            string msg = string.Format(Messages.CONFIRM_EXPORT_FAT, Util.DiskSizeString((long)neededSpace),
                                Util.DiskSizeString(4 * Util.BINARY_GIGA), vm.Name);

                            DialogResult dr = new ThreeButtonDialog(
                                new ThreeButtonDialog.Details(SystemIcons.Warning, msg),
                                "ExportVmDialogFSLimitExceeded",
                                new ThreeButtonDialog.TBDButton(Messages.CONTINUE_WITH_EXPORT, DialogResult.OK),
                                new ThreeButtonDialog.TBDButton(Messages.CHOOSE_ANOTHER_DESTINATION, DialogResult.Retry),
                                ThreeButtonDialog.ButtonCancel).ShowDialog(Parent);
 
                            if (dr == DialogResult.Retry)
                            {
                                continue;
                            }
                            else if (dr == DialogResult.Cancel)
                            {
                                return;
                            }
                        }
                        break;
                    }
                }
            }
            finally
            {
                Directory.SetCurrentDirectory(oldDir);
            }

            new ExportVmAction(connection, host, vm, filename, verify).RunAsync();
        }
예제 #32
0
        /// <summary>
        /// Update report treeView and subscription treeView
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnChangeOK_Refresh(object sender, EventArgs e)
        {
            try
            {
                // set _subscriptionCollection
                SetSubscriptionCollection();

                // Start update treeViews
                if (_subscriptionCollection != null)
                {
                    // Update subscription treeView must be before updating report treeView
                    this.UpdateSubscriptionTreeView();

                    // Update report treeView
                    this.UpdateReportTreeView();

                    // Rebuild panel if ReportSubscriptionView is visible
                    if (sender is WlbReportSubscriptionView)
                    {
                        this.subscriptionView1.BuildPanel();
                    }
                }
            }
            catch (Exception ex)
            {
                log.Debug(ex, ex);
                using (var dlg = new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Error, Messages.WLBREPORT_REPORT_CONFIG_ERROR, Messages.XENCENTER)))
                {
                    dlg.ShowDialog(this);
                }
                this.Close();
            }
        }
예제 #33
0
        /// <summary>
        /// If the answer of the user to the dialog is YES, then make a list of all the selected rows
        /// and call DismissUpdates on that list.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dismissSelectedToolStripMenuItem_Click(object sender, EventArgs e)
        {
            using (var dlog = new ThreeButtonDialog(
                    new ThreeButtonDialog.Details(null, Messages.UPDATE_DISMISS_SELECTED_CONFIRM, Messages.XENCENTER),
                    ThreeButtonDialog.ButtonYes,
                    ThreeButtonDialog.ButtonNo))
            {
                if (dlog.ShowDialog(this) != DialogResult.Yes)
                    return;
            }

            if (dataGridViewUpdates.SelectedRows.Count > 0)
            {
                var selectedAlerts = from DataGridViewRow row in dataGridViewUpdates.SelectedRows select row.Tag as Alert;
                DismissUpdates(selectedAlerts);
            }
        }
예제 #34
0
        /// <summary>
        /// Populates the treeview with ReportInfo and SubscriptionInfo nodes
        /// </summary>
        private void SetTreeViewReportList()
        {
            bool errorLoading = false;

            // Prep treeview for population
            treeViewReportList.BeginUpdate();
            treeViewReportList.Nodes.Clear();

            // Set up the image list for the tree
            this.treeViewReportList.ImageList = CreateReportImageList();

            //_subscriptionCollection = null;

            try
            {
                // retrieve subscription
                SetSubscriptionCollection();

                if (_isMROrLater && _subscriptionCollection != null && !_isBostonOrLater)
                {
                    this.wlbReportView1.btnSubscribe.Visible = true;
                }
                else
                {
                    this.wlbReportView1.btnSubscribe.Visible = false;
                }

                this.wlbReportView1.btnLaterReport.Visible = false;
                this.wlbReportView1.IsCreedenceOrLater = _isCreedenceOrLater;
                PopulateTreeView();
            }
            catch (XenAdmin.CancelledException xc)
            {
                // User cancelled entering credentials when prompted by action
                log.Debug(xc);
                errorLoading = true;
            }
            catch (Exception ex)
            {
                log.Debug(ex, ex);
                using (var dlg = new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Error, Messages.WLBREPORT_REPORT_CONFIG_ERROR, Messages.XENCENTER)))
                {
                    dlg.ShowDialog(this);
                }
                errorLoading = true;
            }
            finally
            {
                if ((treeViewReportList != null) && (!errorLoading))
                    treeViewReportList.EndUpdate();
                else
                    this.Close();
            }
        }
예제 #35
0
        private void toolStripButtonExportAll_Click(object sender, EventArgs e)
        {
            bool exportAll = true;

            if (FilterIsOn)
            {
                using (var dlog = new ThreeButtonDialog(
                    new ThreeButtonDialog.Details(null, Messages.UPDATE_EXPORT_ALL_OR_FILTERED),
                    new ThreeButtonDialog.TBDButton(Messages.ALERT_EXPORT_ALL_BUTTON, DialogResult.Yes),
                    new ThreeButtonDialog.TBDButton(Messages.ALERT_EXPORT_FILTERED_BUTTON, DialogResult.No, ThreeButtonDialog.ButtonType.NONE),
                    ThreeButtonDialog.ButtonCancel))
                {
                    var result = dlog.ShowDialog(this);
                    if (result == DialogResult.No)
                        exportAll = false;
                    else if (result == DialogResult.Cancel)
                        return;
                }
            }

            string fileName;
            using (SaveFileDialog dialog = new SaveFileDialog
            {
                AddExtension = true,
                Filter = string.Format("{0} (*.csv)|*.csv|{1} (*.*)|*.*",
                                       Messages.CSV_DESCRIPTION, Messages.ALL_FILES),
                FilterIndex = 0,
                Title = Messages.EXPORT_ALL,
                RestoreDirectory = true,
                DefaultExt = "csv",
                CheckPathExists = false,
                OverwritePrompt = true
            })
            {
                if (dialog.ShowDialog(this) != DialogResult.OK)
                    return;
                fileName = dialog.FileName;
            }

            new DelegatedAsyncAction(null,
                string.Format(Messages.EXPORT_UPDATES, fileName),
                string.Format(Messages.EXPORTING_UPDATES, fileName),
                string.Format(Messages.EXPORTED_UPDATES, fileName),
                delegate
                {
                    using (StreamWriter stream = new StreamWriter(fileName, false, UTF8Encoding.UTF8))
                    {
                        stream.WriteLine("{0},{1},{2},{3},{4}", Messages.TITLE,
                                         Messages.DESCRIPTION, Messages.APPLIES_TO,
                                         Messages.TIMESTAMP, Messages.WEB_PAGE);

                        if (exportAll)
                        {
                            foreach (Alert a in Updates.UpdateAlerts)
                                stream.WriteLine(a.GetUpdateDetailsCSVQuotes());
                        }
                        else
                        {
                            foreach (DataGridViewRow row in dataGridViewUpdates.Rows)
                            {
                                var a = row.Tag as Alert;
                                if (a != null)
                                    stream.WriteLine(a.GetUpdateDetailsCSVQuotes());
                            }
                        }
                    }
                }).RunAsync();
        }
예제 #36
0
        /// <summary>
        /// Event handler for a lost pool connection
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void wlbReportView1_PoolConnectionLost(object sender, EventArgs e)
        {
            using (var dlg = new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Information, String.Format(Messages.WLB_REPORT_POOL_CONNECTION_LOST, _pool.Name), Messages.WLBREPORT_POOL_CONNECTION_LOST_CAPTION)))
            {
                dlg.ShowDialog(this);
            }

            this.Close();
            this.Dispose();
        }
예제 #37
0
        private void ProcessError(String vmRef, String[] ErrorDescription)
        {
            try
            {
                if (ErrorDescription.Length == 0)
                {
                    return;
                }

                switch (ErrorDescription[0])
                {
                case Failure.VM_REQUIRES_SR:
                    vmRef = ErrorDescription[1];
                    SR sr = connection.Resolve(new XenRef <SR>(ErrorDescription[2]));
                    if (sr == null)
                    {
                        return;
                    }

                    if (sr.content_type == SR.Content_Type_ISO)
                    {
                        UpdateVMWithError(vmRef, Messages.EVACUATE_HOST_LOCAL_CD, Solution.EjectCD);
                    }
                    else
                    {
                        UpdateVMWithError(vmRef, Messages.EVACUATE_HOST_LOCAL_STORAGE, CanSuspendVm(vmRef) ? Solution.Suspend : Solution.Shutdown);
                    }

                    break;

                case Failure.VM_MISSING_PV_DRIVERS:
                    vmRef = ErrorDescription[1];

                    VM vm = connection.Resolve(new XenRef <VM>(vmRef));
                    if (vm != null && InstallToolsCommand.CanExecute(vm))
                    {
                        UpdateVMWithError(vmRef, String.Empty, Solution.InstallPVDrivers);
                    }
                    else
                    {
                        UpdateVMWithError(vmRef, String.Empty, Solution.InstallPVDriversNoSolution);
                    }

                    break;

                case Failure.HOST_NOT_ENOUGH_FREE_MEMORY:
                    if (vmRef == null)
                    {
                        using (var dlg = new ThreeButtonDialog(
                                   new ThreeButtonDialog.Details(
                                       SystemIcons.Error,
                                       Messages.EVACUATE_HOST_NOT_ENOUGH_MEMORY,
                                       Messages.EVACUATE_HOST_NOT_ENOUGH_MEMORY_TITLE)))
                        {
                            dlg.ShowDialog(this);
                        }
                    }

                    vmRef = ErrorDescription[1];
                    UpdateVMWithError(vmRef, String.Empty, CanSuspendVm(vmRef) ? Solution.Suspend : Solution.Shutdown);

                    break;

                case Failure.HA_NO_PLAN:

                    foreach (string _vmRef in vms.Keys)
                    {
                        UpdateVMWithError(_vmRef, String.Empty, CanSuspendVm(_vmRef) ? Solution.Suspend : Solution.Shutdown);
                    }

                    if (vmRef == null)
                    {
                        using (var dlg = new ThreeButtonDialog(
                                   new ThreeButtonDialog.Details(
                                       SystemIcons.Error,
                                       Messages.EVACUATE_HOST_NO_OTHER_HOSTS,
                                       Messages.EVACUATE_HOST_NO_OTHER_HOSTS_TITLE)))
                        {
                            dlg.ShowDialog(this);
                        }
                    }

                    break;

                case Failure.VM_FAILED_SHUTDOWN_ACKNOWLEDGMENT:
                    if (ErrorDescription.Length > 1)
                    {
                        vmRef = ErrorDescription[1];
                    }
                    AddDefaultSuspendOperation(vmRef);
                    break;

                default:
                    AddDefaultSuspendOperation(vmRef);
                    break;
                }
            }
            catch (Exception e)
            {
                log.Debug("Exception processing exception", e);
                log.Debug(e, e);

                AddDefaultSuspendOperation(vmRef);
            }
        }
예제 #38
0
        private void ToolStripMenuItemDismiss_Click(object sender, EventArgs e)
        {
            if (GridViewAlerts.SelectedRows.Count != 1)
                log.DebugFormat("Only 1 alert can be dismissed at a time (Attempted to dismiss {0}). Dismissing the clicked item.", GridViewAlerts.SelectedRows.Count);

            DataGridViewRow clickedRow = FindAlertRow(sender as ToolStripMenuItem);
            if (clickedRow == null)
            {
                log.Debug("Attempted to dismiss alert with no alert selected.");
                return;
            }

            Alert alert = (Alert)clickedRow.Tag;
            if (alert == null)
                return;

            if (!Properties.Settings.Default.DoNotConfirmDismissAlerts)
            {
                using (var dlog = new ThreeButtonDialog(
                    new ThreeButtonDialog.Details(null, Messages.ALERT_DISMISS_CONFIRM, Messages.XENCENTER),
                    ThreeButtonDialog.ButtonYes,
                    ThreeButtonDialog.ButtonNo)
                {
                    ShowCheckbox = true,
                    CheckboxCaption = Messages.DO_NOT_SHOW_THIS_MESSAGE
                })
                {
                    var result = dlog.ShowDialog(this);
                    Properties.Settings.Default.DoNotConfirmDismissAlerts = dlog.IsCheckBoxChecked;
                    Settings.TrySaveSettings();

                    if (result != DialogResult.Yes)
                        return;
                }
            }

            DismissAlerts(new List<Alert> {(Alert) clickedRow.Tag});
        }
예제 #39
0
        private void buttonDelete_Click(object sender, EventArgs e)
        {
            if (lvTaskList.SelectedItems.Count > 0)
            {
                DialogResult confirmResult;
                using (var dlg = new ThreeButtonDialog(
                                                new ThreeButtonDialog.Details(SystemIcons.Warning,
                                                                                Messages.DELETE_WLB_OPTIMIZATION_SCHEDULE_WARNING,
                                                                                Messages.DELETE_WLB_OPTIMIZATION_SCHEDULE_CAPTION),
                                                ThreeButtonDialog.ButtonYes,
                                                ThreeButtonDialog.ButtonNo))
                {
                    confirmResult = dlg.ShowDialog(this);
                }

                if (confirmResult == DialogResult.Yes)
                {
                    WlbScheduledTask task = TaskFromItem(lvTaskList.SelectedItems[0]);
                    DeleteTask(task);
                    weekView1.Refresh();
                }
            }
        }
예제 #40
0
        private void tsmiDismissAll_Click(object sender, EventArgs e)
        {
            DialogResult result = DialogResult.Yes;

            if (FilterIsOn)
            {
                using (var dlog = new ThreeButtonDialog(
                    new ThreeButtonDialog.Details(null, Messages.ALERT_DISMISS_ALL_CONTINUE),
                    new ThreeButtonDialog.TBDButton(Messages.DISMISS_ALL_CONFIRM_BUTTON, DialogResult.Yes),
                    new ThreeButtonDialog.TBDButton(Messages.DISMISS_FILTERED_CONFIRM_BUTTON, DialogResult.No, ThreeButtonDialog.ButtonType.NONE),
                    ThreeButtonDialog.ButtonCancel))
                {
                    result = dlog.ShowDialog(this);
                }
            }
            else if (!Properties.Settings.Default.DoNotConfirmDismissAlerts)
            {
                using (var dlog = new ThreeButtonDialog(
                    new ThreeButtonDialog.Details(null, Messages.ALERT_DISMISS_ALL_NO_FILTER_CONTINUE),
                    new ThreeButtonDialog.TBDButton(Messages.DISMISS_ALL_YES_CONFIRM_BUTTON, DialogResult.Yes),
                    ThreeButtonDialog.ButtonCancel)
                {
                    ShowCheckbox = true,
                    CheckboxCaption = Messages.DO_NOT_SHOW_THIS_MESSAGE
                })
                {
                    result = dlog.ShowDialog(this);
                    Properties.Settings.Default.DoNotConfirmDismissAlerts = dlog.IsCheckBoxChecked;
                    Settings.TrySaveSettings();
                }
            }

            if (result == DialogResult.Cancel)
                return;

            var alerts = result == DialogResult.No
                ? (from DataGridViewRow row in GridViewAlerts.Rows select row.Tag as Alert)
                : Alert.Alerts;

            DismissAlerts(alerts);
        }
예제 #41
0
 private void EnableTask(WlbScheduledTask task)
 {
     //If we are trying to enable the task, check to see if it is a duplicate before allowing it
        if (!task.Enabled)
        {
        //We need to pretend the task is enabled to check for duplicates
        WlbScheduledTask enabledTask = task.Clone();
        enabledTask.Enabled = true;
        WlbScheduledTask checkTask = CheckForDuplicateTask(enabledTask);
        //if it's a duplicate task, display warning and return
        if (null != checkTask)
        {
            using (var dlg = new ThreeButtonDialog(
                new ThreeButtonDialog.Details(
                    SystemIcons.Warning,
                    Messages.WLB_TASK_SCHEDULE_CONFLICT_BLURB,
                    Messages.WLB_TASK_SCHEDULE_CONFLICT_TITLE)))
            {
                dlg.ShowDialog(this);
            }
            SelectTask(checkTask.TaskId);
            return;
        }
        }
        task.Enabled = !task.Enabled;
        PopulateListView();
        _hasChanged = true;
 }
예제 #42
0
        private void tsmiDismissSelected_Click(object sender, EventArgs e)
        {
            if (!Properties.Settings.Default.DoNotConfirmDismissAlerts)
            {
                using (var dlog = new ThreeButtonDialog(
                    new ThreeButtonDialog.Details(null, Messages.ALERT_DISMISS_SELECTED_CONFIRM, Messages.XENCENTER),
                    ThreeButtonDialog.ButtonYes, ThreeButtonDialog.ButtonNo)
                {
                    ShowCheckbox = true,
                    CheckboxCaption = Messages.DO_NOT_SHOW_THIS_MESSAGE
                })
                {
                    var result = dlog.ShowDialog(this);
                    Properties.Settings.Default.DoNotConfirmDismissAlerts = dlog.IsCheckBoxChecked;
                    Settings.TrySaveSettings();

                    if (result != DialogResult.Yes)
                        return;
                }
            }

            if (GridViewAlerts.SelectedRows.Count > 0)
            {
                var selectedAlerts = from DataGridViewRow row in GridViewAlerts.SelectedRows select row.Tag as Alert;
                DismissAlerts(selectedAlerts);
            }
        }