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; using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details(null, blurb, Messages.WLB_PROMPT_FOR_MODE_CHANGE_CAPTION), ThreeButtonDialog.ButtonYes, ThreeButtonDialog.ButtonNo)) { drModeCheck = dlg.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(); } }
private void RetrieveConfiguration() { // only get the config if there are no other pending wlb actions if (null == HelpersGUI.FindActiveWLBAction(_pool.Connection)) { RetrieveWlbConfigurationAction action = new RetrieveWlbConfigurationAction(_pool); action.Completed += this.action_Completed; action.RunAsync(); } }
private void SetButtonState() { string statusMessage = string.Empty; string rbacUser = string.Empty; bool passedRbacChecks = PassedRbacChecks(); if (!passedRbacChecks) { List <Role> roleList = _pool.Connection.Session.Roles; roleList.Sort(); rbacUser = roleList[0].FriendlyName; } AsyncAction thisAction = HelpersGUI.FindActiveWLBAction(_pool.Connection); if (thisAction is RetrieveWlbConfigurationAction) { DisableButtons(); return; } //if wlb is not configured, // disable the config button and change the text of the Enable button to Initialize WLB... //else if (!wlbConfigured) else if (WlbServerState.GetState(_pool) == WlbServerState.ServerState.NotConfigured) { buttonConnect.Visible = true; buttonConnect.Text = Messages.WLB_CONNECT; buttonConfigure.Visible = false; buttonEnableDisableWlb.Visible = false; buttonReports.Visible = false; pictureBoxWarningTriangle.Visible = false; if (passedRbacChecks) { statusMessage = string.Format(Messages.WLB_INITIALIZE_WLB_BLURB, _pool.Name); } else { statusMessage = string.Format(Messages.WLB_INITIALIZE_WLB_BLURB_NO_PRIV, _pool.Name, rbacUser); } labelStatus.Text = statusMessage; pictureBoxWarningTriangle.Visible = (WlbServerState.GetState(_pool) == WlbServerState.ServerState.ConnectionError); panelConfiguration.Visible = false; wlbOptimizePool.Visible = false; } //if there is an error contacting the WLB server, // disable the config button and change the text of the Enable button to Initialize WLB... //else if (!wlbConfigured) else if (WlbServerState.GetState(_pool) == WlbServerState.ServerState.ConnectionError) { buttonConnect.Visible = true; buttonConnect.Text = Messages.WLB_RECONNECT; buttonConfigure.Visible = false; buttonEnableDisableWlb.Visible = false; buttonReports.Visible = false; pictureBoxWarningTriangle.Visible = true; if (passedRbacChecks) { statusMessage = Messages.WLB_CONNECTION_ERROR_BLURB; } else { statusMessage = string.Format(Messages.WLB_CONNECTION_ERROR_BLURB_NO_PRIV, rbacUser); } labelStatus.Text = statusMessage; labelStatus.Visible = true; pictureBoxWarningTriangle.Visible = (WlbServerState.GetState(_pool) == WlbServerState.ServerState.ConnectionError); buttonReports.Enabled = false; panelConfiguration.Visible = false; wlbOptimizePool.Visible = false; } //if wlb is configured but not enabled, //enable the configure button and enble the enable button //else if (wlbConfigured && !wlbEnabled) else if (WlbServerState.GetState(_pool) == WlbServerState.ServerState.Disabled) { base.Text = Messages.WORKLOAD_BALANCING; buttonConnect.Visible = false; buttonConfigure.Visible = true; buttonEnableDisableWlb.Visible = true; buttonReports.Visible = true; pictureBoxWarningTriangle.Visible = true; buttonConfigure.Enabled = true; buttonEnableDisableWlb.Enabled = true; buttonEnableDisableWlb.Text = Messages.ENABLE_WLB_ELLIPSIS; buttonEnableDisableWlb.ImageIndex = 1; //Play arrow if (!passedRbacChecks) { statusMessage = string.Format(Messages.WLB_ENABLE_WLB_BLURB_NO_PRIV, _pool.Name, rbacUser); } else { statusMessage = string.Format(Messages.WLB_ENABLE_WLB_BLURB, _pool.Name); } labelStatus.Text = statusMessage; buttonReports.Enabled = true; panelConfiguration.Visible = true; wlbOptimizePool.Visible = true; } //otherwise, if wlb is configured and enabled, allow configuration, and show enable as Disable //else if (wlbEnabled) else if (WlbServerState.GetState(_pool) == WlbServerState.ServerState.Enabled) { buttonConnect.Visible = false; buttonConfigure.Visible = true; buttonEnableDisableWlb.Visible = true; buttonReports.Visible = true; pictureBoxWarningTriangle.Visible = false; buttonConfigure.Enabled = true; buttonEnableDisableWlb.Enabled = true; buttonEnableDisableWlb.Text = Messages.DISABLE_WLB_ELLIPSIS; buttonEnableDisableWlb.ImageIndex = 0; //Pause hashes if (!passedRbacChecks) { statusMessage = string.Format(Messages.WLB_NO_PERMISSION_BLURB, rbacUser); } else { statusMessage = string.Format(Messages.WLB_ENABLED_BLURB, _pool.Name); } labelStatus.Text = statusMessage; buttonReports.Enabled = true; panelConfiguration.Visible = true; wlbOptimizePool.Visible = true; } if (PassedRbacChecks()) { //Show the buttons flowLayoutPanelLeftButtons.Visible = true; //panelButtons.Visible = true; } else { //disable and hide the buttons DisableButtons(); flowLayoutPanelLeftButtons.Visible = false; //panelButtons.Visible = false; } }
/// <summary> /// Build optimize pool list view properly /// </summary> private void BuildRecList() { Program.AssertOnEventThread(); if (_xenObject == null) { return; } if (Helpers.WlbEnabled(_xenObject.Connection)) { try { if (_xenObject is Pool) { _pool = (Pool)_xenObject; // get any active WLB action action = HelpersGUI.FindActiveWLBAction(_xenObject.Connection); // make sure we are not initializing, starting or stopping WLB if (action is DisableWLBAction || action is EnableWLBAction || action is InitializeWLBAction) { return; } optimizePoolListView.BeginUpdate(); // check whether optimize pool is running before load optimize pool listview if ((action != null && action is WlbOptimizePoolAction) || (action == null && _pool.other_config.ContainsKey(WlbOptimizationRecommendation.OPTIMIZINGPOOL) && _pool.other_config[WlbOptimizationRecommendation.OPTIMIZINGPOOL] == Messages.IN_PROGRESS)) { //statusLabel.Text = Messages.WLB_OPT_OPTIMIZING; this.applyButton.Text = Messages.WLB_OPT_OPTIMIZING; EnableControls(false, false); } else if (action == null || (action != null && action.GetType() != typeof(WlbRetrieveRecommendationAction))) { this.applyButton.Text = Messages.WLB_OPT_APPLY_RECOMMENDATIONS; // retrieve recommendations, and load optimize pool listview properly WlbRetrieveRecommendationAction optAction = new WlbRetrieveRecommendationAction(_pool); optAction.Completed += this.OptRecRetrieveAction_Completed; optAction.RunAsync(); } } } catch (Failure f) { statusLabel.Text = Messages.WLB_OPT_LOADING_ERROR; log.Error(f, f); } catch (Exception e) { statusLabel.Text = Messages.WLB_OPT_LOADING_ERROR; log.ErrorFormat("There was an error calling retrieve_wlb_recommendations on pool {0}", _pool.name_label); log.Error(e, e); } finally { optimizePoolListView.EndUpdate(); } } else { this.WLBOptDisable(true); } }