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);
using (var dlg = new ActionProgressDialog(action, ProgressBarStyle.Marquee))
dlg.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);
}