Exemplo n.º 1
0
        private void UpdateButtons()
        {
            NfsScanButton.Enabled = SrWizardHelpers.ValidateNfsSharename(NfsServerPathTextBox.Text);
            nfsVersionSelectorTableLayoutPanel.Enabled = radioButtonNfsNew.Checked;

            OnPageUpdated();
        }
Exemplo n.º 2
0
        private bool CanShowLVMoHBASummaryPage(List <FibreChannelDescriptor> SrDescriptors)
        {
            string description = m_srWizardType.Description;
            string name        = m_srWizardType.SrName;

            List <string> names = xenConnection.Cache.SRs.Select(sr => sr.Name()).ToList();

            m_srWizardType.SrDescriptors.Clear();
            foreach (var descriptor in SrDescriptors)
            {
                descriptor.Name = name;
                if (!string.IsNullOrEmpty(description))
                {
                    descriptor.Description = description;
                }

                m_srWizardType.SrDescriptors.Add(descriptor);
                m_srWizardType.IsGfs2 = descriptor is Gfs2HbaSrDescriptor || descriptor is Gfs2FcoeSrDescriptor;
                names.Add(name);
                name = SrWizardHelpers.DefaultSRName(m_srWizardType is SrWizardType_Hba
                                                        ? Messages.NEWSR_HBA_DEFAULT_NAME
                                                        : Messages.NEWSR_FCOE_DEFAULT_NAME, names);
            }

            xenTabPageLvmoHbaSummary.SuccessfullyCreatedSRs.Clear();
            xenTabPageLvmoHbaSummary.FailedToCreateSRs.Clear();

            bool closeWizard;

            RunFinalAction(out closeWizard);
            return(closeWizard);
        }
Exemplo n.º 3
0
        private bool CanShowLVMoMirrorSummaryPage()
        {
            string description = m_srWizardType.Description;
            string name        = m_srWizardType.SrName;

            List <string> names = xenConnection.Cache.SRs.Select(sr => sr.Name).ToList();

            m_srWizardType.SrDescriptors.Clear();
            foreach (var lvmOmirrorSrDescriptor in xenTabPageLVMoMirrorChooseLog.SrDescriptors)
            {
                lvmOmirrorSrDescriptor.Name = name;
                if (!string.IsNullOrEmpty(description))
                {
                    lvmOmirrorSrDescriptor.Description = description;
                }

                m_srWizardType.SrDescriptors.Add(lvmOmirrorSrDescriptor);
                names.Add(name);
                name = SrWizardHelpers.DefaultSRName(Messages.NEWSR_LVMoMirror_DEFAULT_NAME, names);
            }

            xenTabPageLvmoMirrorSummary.SuccessfullyCreatedSRs.Clear();
            xenTabPageLvmoMirrorSummary.FailedToCreateSRs.Clear();

            bool closeWizard;

            RunFinalAction(out closeWizard);
            return(closeWizard);
        }
Exemplo n.º 4
0
 private vmpp_archive_target_type GetArchiveTargetType(string path)
 {
     if (SrWizardHelpers.ValidateNfsSharename(path))
     {
         return(vmpp_archive_target_type.nfs);
     }
     if (SrWizardHelpers.ValidateCifsSharename(path))
     {
         return(vmpp_archive_target_type.cifs);
     }
     return(vmpp_archive_target_type.none);
 }
Exemplo n.º 5
0
        private void AnyCifsParameters_TextChanged(object sender, EventArgs e)
        {
            CifsScanButton.Enabled = SrWizardHelpers.ValidateCifsSharename(CifsServerPathTextBox.Text);

            listBoxCifsSRs.Items.Clear();
            ToggleReattachControlsEnabledState(false);

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

            UpdateButtons();
        }
Exemplo n.º 6
0
        private void NfsServerPathTextBox_TextChanged(object sender, EventArgs e)
        {
            NfsScanButton.Enabled = SrWizardHelpers.ValidateNfsSharename(NfsServerPathTextBox.Text);

            listBoxNfsSRs.Items.Clear();
            panelNfsReattach.Enabled = false;

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

            UpdateButtons();
        }
Exemplo n.º 7
0
        private void NfsServerPathTextBox_TextChanged(object sender, EventArgs e)
        {
            NfsScanButton.Enabled = SrWizardHelpers.ValidateNfsSharename(NfsServerPathTextBox.Text);

            listBoxNfsSRs.Items.Clear();
            ToggleReattachControlsEnabledState(false);

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

            nfsVersion3RadioButton.Enabled = nfsVersion4RadioButton.Enabled = true;

            UpdateButtons();
        }
Exemplo n.º 8
0
        private bool CanSelectSRInfo(SR.SRInfo info)
        {
            SR sr = SrWizardHelpers.SrInUse(info.UUID);

            if (sr != null && sr.HasPBDs())
            {
                return(false);
            }

            if (!String.IsNullOrEmpty(MustSelectUUID) && info.UUID != MustSelectUUID)
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 9
0
        public LVMoIsciWarningDialog(IXenConnection connection, SR.SRInfo srInfo, SR.SRTypes existingSrType, SR.SRTypes requestedSrType)
            : base(connection, "", 0, srInfo != null, existingSrType, requestedSrType)
        {
            labelLUNDetails.Visible = false;
            labelSrDetails.Visible  = srInfo != null;

            // CA-17230: if the found SR is used by other connected pools, offer only to attach it

            if (srInfo != null)
            {
                SR sr = SrWizardHelpers.SrInUse(srInfo.UUID);
                if (sr != null)
                {
                    panelFormat.Visible = false;
                    labelWarning.Text   = GetSrInUseMessage(sr);
                }

                labelSrDetails.Text = string.Format(Messages.ISCSI_DIALOG_SR_DETAILS, Util.DiskSizeString(srInfo.Size), srInfo.UUID);
            }
        }
Exemplo n.º 10
0
 public override bool EnableNext()
 {
     return(SrWizardHelpers.ValidateNfsSharename(NfsServerPathTextBox.Text) &&
            (radioButtonNfsNew.Checked || listBoxNfsSRs.SelectedIndex > -1));
 }
Exemplo n.º 11
0
        private void UpdateButtons()
        {
            NfsScanButton.Enabled = SrWizardHelpers.ValidateNfsSharename(NfsServerPathTextBox.Text);

            OnPageUpdated();
        }
Exemplo n.º 12
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);
                new ActionProgressDialog(action, ProgressBarStyle.Marquee).ShowDialog(this);

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

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

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

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

                    cancel = true;
                    return;
                }

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

                        cancel = true;
                        return;
                    }

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

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

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

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

            base.PageLeave(direction, ref cancel);
        }
Exemplo n.º 13
0
 public override bool EnableNext()
 {
     return(!passwordFailure1.Visible && SrWizardHelpers.ValidateNfsSharename(NfsServerPathComboBox.Text));
 }
Exemplo n.º 14
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(SR.SRTypes currentSrType, List <SR.SRInfo> srs)
        {
            _srToIntroduce = null;

            if (srs == null)
            {
                return(false);
            }

            try
            {
                if (!String.IsNullOrEmpty(SrWizardType.UUID))
                {
                    // Check LUN contains correct SR
                    if (srs.Count == 1 && srs[0].UUID == SrWizardType.UUID)
                    {
                        _srToIntroduce = srs[0];
                        SrType         = currentSrType; // the type of the existing SR
                        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 ErrorDialog(Messages.NEWSR_LUN_HAS_NO_SRS))
                            dlg.ShowDialog(this);

                        return(false);
                    }
                    DialogResult result = DialogResult.Yes;
                    if (!Program.RunInAutomatedTestMode)
                    {
                        using (var dlg = new WarningDialog(Messages.NEWSR_ISCSI_FORMAT_WARNING,
                                                           ThreeButtonDialog.ButtonYes,
                                                           new ThreeButtonDialog.TBDButton(Messages.NO_BUTTON_CAPTION, DialogResult.No, selected: true))
                        {
                            WindowTitle = Text
                        })
                        {
                            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 NoIconDialog(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;
                        SrType         = currentSrType; // the type of the existing SR
                        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, currentSrType, SrType).ShowDialog(this);

                    switch (result)
                    {
                    case DialogResult.Yes:
                        // Reattach
                        _srToIntroduce = srs[0];
                        SrType         = currentSrType; // the type of the existing SR
                        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);
            }
        }
Exemplo n.º 15
0
        private void SRListBox_DrawItem(object sender, DrawItemEventArgs e)
        {
            if (e.Index == -1)
            {
                return;
            }

            SR.SRInfo info = Items[e.Index] as SR.SRInfo;
            if (info == null)
            {
                return;
            }

            SR sr = SrWizardHelpers.SrInUse(info.UUID);

            Color fore, back;

            if (!Enabled)
            {
                fore = SystemColors.GrayText;
                back = SystemColors.Control;
            }
            else if (!CanSelectSRInfo(info))
            {
                // Draw in-use SRs grayed out
                fore = SystemColors.GrayText;
                back = SystemColors.Window;
            }
            else if ((e.State & DrawItemState.Selected) > 0)
            {
                // When control enabled, draw the selected item blue
                fore = SystemColors.HighlightText;
                back = SystemColors.Highlight;
            }
            else
            {
                fore = SystemColors.ControlText;
                back = SystemColors.Window;
            }

            // Fill in background
            using (SolidBrush backBrush = new SolidBrush(back))
            {
                e.Graphics.FillRectangle(backBrush, e.Bounds);
            }

            if (sr == null)
            {
                // Draw SR UUID in monospace, but size in normal font

                Size s = Drawing.MeasureText(info.UUID + " ", MonospaceFont);
                Drawing.DrawText(e.Graphics, info.UUID + " ", MonospaceFont, e.Bounds.Location, fore);
                if (!String.IsNullOrEmpty(info.Aggr))
                {
                    Drawing.DrawText(e.Graphics, info.Aggr + " ", e.Font, new Point(e.Bounds.Left + s.Width, e.Bounds.Top), fore);
                }
            }
            else
            {
                String text = String.Format(Messages.SR_X_ON_Y, sr.Name(), Helpers.GetName(sr.Connection));

                if (!sr.HasPBDs())
                {
                    text = String.Format(Messages.DETACHED_BRACKETS, text);
                }

                Drawing.DrawText(e.Graphics, text, e.Font, e.Bounds.Location, fore);
            }
        }
Exemplo n.º 16
0
 public override bool EnableNext()
 {
     return(SrWizardHelpers.ValidateCifsSharename(comboBoxCifsSharename.Text) &&
            !(checkBoxUseDifferentUsername.Checked && String.IsNullOrEmpty(textBoxCifsUsername.Text)) &&
            !passwordFailure1.Visible);
 }
Exemplo n.º 17
0
        protected override void PageLeaveCore(PageLoadedDirection direction, ref bool cancel)
        {
            if (direction == PageLoadedDirection.Back)
            {
                return;
            }

            Host master = Helpers.GetMaster(Connection);

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

            SrDescriptors = new List <FibreChannelDescriptor>();

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

            var performSecondProbe = Helpers.KolkataOrGreater(Connection) && !Helpers.FeatureForbidden(Connection, Host.CorosyncDisabled) &&
                                     SrType != SR.SRTypes.lvmofcoe; // gfs2 over fcoe is not supported yet

            foreach (var device in _selectedDevices)
            {
                // Start probe
                var formatDiskDescriptor = CreateSrDescriptor(device);
                List <SR.SRInfo> srs;

                var currentSrDescriptor = formatDiskDescriptor;

                if (!RunProbe(master, currentSrDescriptor, out srs))
                {
                    cancel = true;
                    return;
                }

                if (performSecondProbe && srs.Count == 0)
                {
                    // Start second probe
                    currentSrDescriptor = SrType == SR.SRTypes.gfs2 ? CreateLvmSrDescriptor(device) : CreateGfs2Descriptor(device);

                    if (!RunProbe(master, currentSrDescriptor, out srs))
                    {
                        cancel = true;
                        return;
                    }
                }

                currentSrDescriptor.UUID = srs.Select(sr => sr.UUID).FirstOrDefault();
                if (srs.Count > 0)
                {
                    currentSrDescriptor.UpdateDeviceConfig(srs[0].Configuration);
                }

                if (!string.IsNullOrEmpty(SrWizardType.UUID))
                {
                    // Check LUN contains correct SR
                    if (currentSrDescriptor.UUID == SrWizardType.UUID)
                    {
                        SrDescriptors.Add(currentSrDescriptor);
                        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(currentSrDescriptor.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(formatDiskDescriptor);
                    }
                }
                else
                {
                    // Check this isn't an existing SR on the current pool
                    var existingSr = Connection.Cache.SRs.FirstOrDefault(sr => sr.uuid == currentSrDescriptor.UUID);
                    if (existingSr != null)
                    {
                        var pool      = Helpers.GetPool(existingSr.Connection);
                        var errorText = pool != null
                            ? string.Format(Messages.NEWSR_LUN_IN_USE_ON_SELECTED_POOL, device.SCSIid, existingSr.Name())
                            : string.Format(Messages.NEWSR_LUN_IN_USE_ON_SELECTED_SERVER, device.SCSIid, existingSr.Name());

                        using (var dlog = new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Error,
                                                                                              errorText, Messages.XENCENTER)))
                        {
                            dlog.ShowDialog(this);
                        }
                        cancel = true;
                        return;
                    }

                    // CA-17230: Check this isn't an existing SR on any of the known pools.
                    // If it is then just continue (i.e. do not ask the user if they want to format or reattach it, we will just reattach it)
                    existingSr = SrWizardHelpers.SrInUse(currentSrDescriptor.UUID);
                    if (existingSr != null)
                    {
                        SrDescriptors.Add(currentSrDescriptor);
                        continue;
                    }

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

            if (!cancel && existingSrDescriptors.Count > 0)
            {
                var launcher = new LVMoHBAWarningDialogLauncher(this, existingSrDescriptors, true, SrType);
                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, SrType);
                launcher.ShowWarnings();
                cancel = launcher.Cancelled;
                if (!cancel && launcher.SrDescriptors.Count > 0)
                {
                    SrDescriptors.AddRange(launcher.SrDescriptors);
                }
            }
        }
Exemplo n.º 18
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);
            }
        }