private UserSelectedOption GetSelectedOption(LvmObondSrDescriptor lvmOboundSrDescriptor, out bool repeatForRemainingLUNs) { int remainingCount = inputSrDescriptors.Count - 1 - inputSrDescriptors.IndexOf(lvmOboundSrDescriptor); using (var dialog = new LVMoBondWarningDialog(lvmOboundSrDescriptor.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) { return; } Host master = Helpers.GetMaster(Connection); if (master == null) { cancel = true; return; } var descr = new LvmObondSrDescriptor(_selectedDevices, Connection); if (this.checkBoxThin.Checked) { descr.SMConfig.Add(SrCreateAction.allocation, "thin"); } SrDescriptors = new List <LvmObondSrDescriptor>(); var existingSrDescriptors = new List <LvmObondSrDescriptor>(); var formatDiskDescriptors = new List <LvmObondSrDescriptor>(); var action = new SrProbeAction(Connection, master, SR.SRTypes.lvmobond, 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 LVMoBONDWarningDialogLauncher(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 LVMoBONDWarningDialogLauncher(this, formatDiskDescriptors, false); launcher.ShowWarnings(); cancel = launcher.Cancelled; if (!cancel && launcher.SrDescriptors.Count > 0) { SrDescriptors.AddRange(launcher.SrDescriptors); } } base.PageLeave(direction, ref cancel); }