private void comboBoxIscsiIqns_SelectedIndexChanged(object sender, EventArgs e) { HideErrors(); ResetLuns(); if (comboBoxIscsiIqns.SelectedItem is ToStringWrapper <IScsiIqnInfo> wrapper) { toolTipTargetIqn.SetToolTip(comboBoxIscsiIqns, wrapper.ToString()); DisableAllInputControls(); spinnerIconAtTargetIqn.StartSpinning(); _populateLunsAction = SrType == SR.SRTypes.gfs2 ? new Gfs2PopulateLunsAction(Connection, getIscsiHost(), getIscsiPort(), getIscsiIQN(), ChapUser, ChapPassword) : new ISCSIPopulateLunsAction(Connection, getIscsiHost(), getIscsiPort(), getIscsiIQN(), ChapUser, ChapPassword); _populateLunsAction.Completed += PopulateLunsAction_Completed; _populateLunsAction.RunAsync(); } else { toolTipTargetIqn.SetToolTip(comboBoxIscsiIqns, Messages.SELECT_TARGET_IQN); } UpdateButtons(); }
private void IscsiPopulateLUNs() { spinnerIconAtTargetIqn.StartSpinning(); comboBoxIscsiLuns.Items.Clear(); LunMap.Clear(); if (IscsiUseChapCheckBox.Checked) { IscsiPopulateLunsAction = new Actions.ISCSIPopulateLunsAction(Connection, getIscsiHost(), getIscsiPort(), getIscsiIQN(), IScsiChapUserTextBox.Text, IScsiChapSecretTextBox.Text); } else { IscsiPopulateLunsAction = new Actions.ISCSIPopulateLunsAction(Connection, getIscsiHost(), getIscsiPort(), getIscsiIQN(), null, null); } IscsiPopulateLunsAction.Completed += IscsiPopulateLunsAction_Completed; controlDisabler.Reset(); controlDisabler.SaveOrUpdateEnabledStates(UserInputControls); controlDisabler.DisableAllControls(); IscsiPopulateLunsAction.RunAsync(); }
private void buttonIscsiPopulateLUNs_Click(object sender, EventArgs e) { buttonIscsiPopulateLUNs.Enabled = false; comboBoxIscsiLuns.Items.Clear(); LunMap.Clear(); if (IscsiUseChapCheckBox.Checked) { IscsiPopulateLunsAction = new Actions.ISCSIPopulateLunsAction(Connection, getIscsiHost(), getIscsiPort(), getIscsiIQN(), IScsiChapUserTextBox.Text, IScsiChapSecretTextBox.Text); } else { IscsiPopulateLunsAction = new Actions.ISCSIPopulateLunsAction(Connection, getIscsiHost(), getIscsiPort(), getIscsiIQN(), null, null); } ActionProgressDialog dialog = new ActionProgressDialog(IscsiPopulateLunsAction, ProgressBarStyle.Marquee); //CA-80178: need to register Completed after the action has been added to the dialog, otherwise //the handler will be called before the dialog is closed and the focus won't be set on the right control. IscsiPopulateLunsAction.Completed += IscsiPopulateLunsAction_Completed; dialog.ShowCancel = true; dialog.ShowDialog(this); }
private void IscsiPopulateLunsAction_Completed_(object o) { Program.AssertOnEventThread(); ISCSIPopulateLunsAction action = (ISCSIPopulateLunsAction)o; buttonIscsiPopulateLUNs.Enabled = true; if (!action.Succeeded) { Failure failure = action.Exception as Failure; if (failure != null && failure.ErrorDescription[0] == "SR_BACKEND_FAILURE_140") { labelIscsiInvalidHost.Visible = true; textBoxIscsiHost.Focus(); } return; } if (action.LUNs.Length == 0) { // Do nothing: ActionProgressDialog will show Messages.NEWSR_NO_LUNS_FOUND } else { int width = comboBoxIscsiLuns.Width; foreach (Actions.ISCSIInfo i in action.LUNs) { String label = "LUN"; if (i.LunID != -1) { label += String.Format(" {0}", i.LunID); } if (i.Serial != "") { label += String.Format(": {0}", i.Serial); } if (i.Size >= 0) { label += String.Format(": {0}", Util.DiskSizeString(i.Size)); } if (i.Vendor != "") { label += String.Format(" ({0})", i.Vendor); } comboBoxIscsiLuns.Items.Add(label); LunMap.Add(label, i); width = Math.Max(width, Drawing.MeasureText(label, comboBoxIscsiLuns.Font).Width); } comboBoxIscsiLuns.SelectedItem = comboBoxIscsiLuns.Items[0]; comboBoxIscsiLuns.Enabled = true; // Set the combo box dropdown width to accommodate the widest item (within reason) comboBoxIscsiLuns.DropDownWidth = Math.Min(width, Int16.MaxValue); } UpdateButtons(); }
private void IscsiPopulateLunsAction_Completed_(object o) { Program.AssertOnEventThread(); ISCSIPopulateLunsAction action = (ISCSIPopulateLunsAction)o; buttonIscsiPopulateLUNs.Enabled = true; if (!action.Succeeded) { Failure failure = action.Exception as Failure; if (failure != null && failure.ErrorDescription[0] == "SR_BACKEND_FAILURE_140") { labelIscsiInvalidHost.Visible = true; textBoxIscsiHost.Focus(); } return; } if (action.LUNs.Length == 0) { // Do nothing: ActionProgressDialog will show Messages.NEWSR_NO_LUNS_FOUND } else { foreach (Actions.ISCSIInfo i in action.LUNs) { String label = "LUN"; if (i.LunID != -1) { label += String.Format(" {0}", i.LunID); } if (i.Serial != "") { label += String.Format(": {0}", i.Serial); } if (i.Size >= 0) { label += String.Format(": {0}", Util.DiskSizeString(i.Size)); } if (i.Vendor != "") { label += String.Format(" ({0})", i.Vendor); } comboBoxIscsiLuns.Items.Add(label); LunMap.Add(label, i); } comboBoxIscsiLuns.SelectedItem = comboBoxIscsiLuns.Items[0]; comboBoxIscsiLuns.Enabled = true; comboBoxIscsiLuns.Focus(); } UpdateButtons(); }
private void IscsiPopulateLUNs() { spinnerIconAtTargetIqn.StartSpinning(); comboBoxIscsiLuns.Items.Clear(); LunMap.Clear(); var chapUser = IscsiUseChapCheckBox.Checked ? IScsiChapUserTextBox.Text : null; var chapPwd = IscsiUseChapCheckBox.Checked ? IScsiChapSecretTextBox.Text : null; IscsiPopulateLunsAction = SrType == SR.SRTypes.gfs2 ? new Gfs2PopulateLunsAction(Connection, getIscsiHost(), getIscsiPort(), getIscsiIQN(), chapUser, chapPwd) : new ISCSIPopulateLunsAction(Connection, getIscsiHost(), getIscsiPort(), getIscsiIQN(), chapUser, chapPwd); IscsiPopulateLunsAction.Completed += IscsiPopulateLunsAction_Completed; controlDisabler.Reset(); controlDisabler.SaveOrUpdateEnabledStates(UserInputControls); controlDisabler.DisableAllControls(); IscsiPopulateLunsAction.RunAsync(); }
private void buttonIscsiPopulateLUNs_Click(object sender, EventArgs e) { buttonIscsiPopulateLUNs.Enabled = false; comboBoxIscsiLuns.Items.Clear(); LunMap.Clear(); if (IscsiUseChapCheckBox.Checked) { IscsiPopulateLunsAction = new Actions.ISCSIPopulateLunsAction(connection, getIscsiHost(), getIscsiPort(), getIscsiIQN(), IScsiChapUserTextBox.Text, IScsiChapSecretTextBox.Text); } else { IscsiPopulateLunsAction = new Actions.ISCSIPopulateLunsAction(connection, getIscsiHost(), getIscsiPort(), getIscsiIQN(), null, null); } IscsiPopulateLunsAction.Completed += IscsiPopulateLunsAction_Completed; using (var dialog = new ActionProgressDialog(IscsiPopulateLunsAction, ProgressBarStyle.Marquee)) { dialog.ShowCancel = true; dialog.ShowDialog(this); } }
private void PopulateLunsAction_Completed_(ISCSIPopulateLunsAction action) { if (action == null) { return; } Program.AssertOnEventThread(); _populateLunsAction = null; EnableInputControls(); if (!action.Succeeded) { spinnerIconAtTargetIqn.StopSpinning(); HandleFailure(action); UpdateButtons(); return; } // If no IQNs are found do nothing; the ActionProgressDialog will have shown Messages.NEWSR_NO_LUNS_FOUND if (action.LUNs.Length == 0) { UpdateButtons(); return; } comboBoxIscsiLuns.Items.Add(Messages.SELECT_TARGET_LUN); foreach (ISCSIInfo i in action.LUNs) { string label = "LUN"; if (i.LunID != -1) { label += string.Format(" {0}", i.LunID); } if (i.Serial != "") { label += string.Format(": {0}", i.Serial); } if (i.Size >= 0) { label += string.Format(": {0}", Util.DiskSizeString(i.Size)); } if (i.Vendor != "") { label += string.Format(" ({0})", i.Vendor); } comboBoxIscsiLuns.Items.Add(label); LunMap.Add(label, i); } //if there is only one choice, select that one by default comboBoxIscsiLuns.SelectedItem = comboBoxIscsiLuns.Items.Count == 2 ? comboBoxIscsiLuns.Items[1] : Messages.SELECT_TARGET_LUN; labelTargetLun.Enabled = true; comboBoxIscsiLuns.Enabled = true; comboBoxIscsiLuns.Focus(); spinnerIconAtTargetIqn.ShowSuccessImage(); UpdateButtons(); }
private void IscsiPopulateLunsAction_Completed_(object o) { Program.AssertOnEventThread(); controlDisabler.RestoreEnabledOnAllControls(); ISCSIPopulateLunsAction action = (ISCSIPopulateLunsAction)o; if (!action.Succeeded) { spinnerIconAtTargetIqn.Visible = false; Failure failure = action.Exception as Failure; if (failure != null && failure.ErrorDescription != null && failure.ErrorDescription.Count > 0) { if (failure.ErrorDescription[0] == "SR_BACKEND_FAILURE_140") { errorIconAtHostOrIP.Visible = true; errorLabelAtHostname.Text = Messages.INVALID_HOST; errorLabelAtHostname.Visible = true; textBoxIscsiHost.Focus(); } else if (failure.ErrorDescription[0] == "SR_BACKEND_FAILURE_68") { errorIconAtCHAPPassword.Visible = true; errorLabelAtCHAPPassword.Text = Messages.LOGGING_IN_TO_THE_ISCSI_TARGET_FAILED; errorLabelAtCHAPPassword.Visible = true; IScsiChapUserTextBox.Focus(); } else { errorIconAtTargetLUN.Visible = true; errorIconAtTargetLUN.Text = failure.ErrorDescription.Count > 2 ? failure.ErrorDescription[2] : failure.ErrorDescription[0]; errorIconAtTargetLUN.Visible = true; textBoxIscsiHost.Focus(); } } return; } if (action.LUNs.Length == 0) { // Do nothing: ActionProgressDialog will show Messages.NEWSR_NO_LUNS_FOUND } else { comboBoxIscsiLuns.Items.Add(Messages.SELECT_TARGET_LUN); foreach (Actions.ISCSIInfo i in action.LUNs) { String label = "LUN"; if (i.LunID != -1) { label += String.Format(" {0}", i.LunID); } if (i.Serial != "") { label += String.Format(": {0}", i.Serial); } if (i.Size >= 0) { label += String.Format(": {0}", Util.DiskSizeString(i.Size)); } if (i.Vendor != "") { label += String.Format(" ({0})", i.Vendor); } comboBoxIscsiLuns.Items.Add(label); LunMap.Add(label, i); } comboBoxIscsiLuns.SelectedItem = comboBoxIscsiLuns.Items.Count == 2 ? comboBoxIscsiLuns.Items[1] : Messages.SELECT_TARGET_LUN; //if there is only one choice, select that one by default comboBoxIscsiLuns.Enabled = true; targetLunLabel.Enabled = true; comboBoxIscsiLuns.Focus(); spinnerIconAtTargetIqn.DisplaySucceededImage(); } comboBoxIscsiLuns.Enabled = true; comboBoxIscsiIqns.Enabled = true; UpdateButtons(); }