private UserSelectedOption GetSelectedOption(LVMoMirrorSrDescriptor lvmOmirrorSrDescriptor, out bool repeatForRemainingLUNs) { int remainingCount = inputSrDescriptors.Count - 1 - inputSrDescriptors.IndexOf(lvmOmirrorSrDescriptor); using (var dialog = new LVMoMirrorChooseLogWarningDialog(lvmOmirrorSrDescriptor.Device, remainingCount, foundExistingSRs)) { dialog.ShowDialog(owner); repeatForRemainingLUNs = dialog.RepeatForRemainingLUNs; return(dialog.SelectedOption); } }
public override void PageLeave(PageLoadedDirection direction, ref bool cancel) { if (direction == PageLoadedDirection.Back) { three_devices.Clear(); LVMoMirror.two_devices.Clear(); _selectedDevices.Clear(); IsFirstLoad = true; return; } Host master = Helpers.GetMaster(Connection); if (master == null) { cancel = true; return; } if (three_devices.Count == 2 && _selectedDevices.Count == 1) { three_devices.Add(_selectedDevices[0]); } var descr = new LVMoMirrorSrDescriptor(three_devices, Connection); SrDescriptors = new List <LVMoMirrorSrDescriptor>(); var existingSrDescriptors = new List <LVMoMirrorSrDescriptor>(); var formatDiskDescriptors = new List <LVMoMirrorSrDescriptor>(); var action = new SrProbeAction(Connection, master, SR.SRTypes.lvmomirror, 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); return; } 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); //return; formatDiskDescriptors.Add(descr); } else { // We found a SR on this LUN. Will ask user for choice later. existingSrDescriptors.Add(descr); } } if (!cancel && existingSrDescriptors.Count > 0) { var launcher = new LVMoMIRRORWarningDialogLauncher(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 LVMoMIRRORWarningDialogLauncher(this, formatDiskDescriptors, false); launcher.ShowWarnings(); cancel = launcher.Cancelled; if (!cancel && launcher.SrDescriptors.Count > 0) { SrDescriptors.AddRange(launcher.SrDescriptors); } } base.PageLeave(direction, ref cancel); }