mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2025-01-20 07:19:18 +01:00
Simplified class hierarchies for the SrDescriptors. Among others, we avoid the presence of irrelevant key-value pairs in the DeviceConfig .
Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
This commit is contained in:
parent
2943b048fa
commit
5d4a9270eb
@ -199,7 +199,7 @@ namespace XenAdmin.Wizards
|
||||
return success;
|
||||
}
|
||||
|
||||
private bool CanShowLVMoHBASummaryPage(List<LvmOhbaSrDescriptor> SrDescriptors)
|
||||
private bool CanShowLVMoHBASummaryPage(List<FibreChannelDescriptor> SrDescriptors)
|
||||
{
|
||||
string description = m_srWizardType.Description;
|
||||
string name = m_srWizardType.SrName;
|
||||
@ -207,14 +207,14 @@ namespace XenAdmin.Wizards
|
||||
List<string> names = xenConnection.Cache.SRs.Select(sr => sr.Name()).ToList();
|
||||
|
||||
m_srWizardType.SrDescriptors.Clear();
|
||||
foreach (var lvmOhbaSrDescriptor in SrDescriptors)
|
||||
foreach (var descriptor in SrDescriptors)
|
||||
{
|
||||
lvmOhbaSrDescriptor.Name = name;
|
||||
descriptor.Name = name;
|
||||
if (!string.IsNullOrEmpty(description))
|
||||
lvmOhbaSrDescriptor.Description = description;
|
||||
descriptor.Description = description;
|
||||
|
||||
m_srWizardType.SrDescriptors.Add(lvmOhbaSrDescriptor);
|
||||
m_srWizardType.IsGfs2 = lvmOhbaSrDescriptor is Gfs2HbaSrDescriptor || lvmOhbaSrDescriptor is Gfs2FcoeSrDescriptor;
|
||||
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
|
||||
@ -637,7 +637,7 @@ namespace XenAdmin.Wizards
|
||||
|
||||
foreach (var srDescriptor in m_srWizardType.SrDescriptors)
|
||||
{
|
||||
var srType = srDescriptor is LvmOhbaSrDescriptor ? (srDescriptor as LvmOhbaSrDescriptor).SrType : m_srWizardType.Type;
|
||||
var srType = srDescriptor is FibreChannelDescriptor ? (srDescriptor as FibreChannelDescriptor).SrType : m_srWizardType.Type;
|
||||
if (String.IsNullOrEmpty(srDescriptor.UUID))
|
||||
{
|
||||
// Don't need to show any warning, as the only destructive creates
|
||||
|
@ -48,12 +48,12 @@ namespace XenAdmin.Wizards.NewSRWizard_Pages.Frontends
|
||||
|
||||
public override string HelpID { get { return "Location_FCOE"; } }
|
||||
|
||||
protected override LvmOhbaSrDescriptor CreateLvmSrDescriptor(FibreChannelDevice device)
|
||||
protected override FibreChannelDescriptor CreateLvmSrDescriptor(FibreChannelDevice device)
|
||||
{
|
||||
return new FcoeSrDescriptor(device);
|
||||
}
|
||||
|
||||
protected override LvmOhbaSrDescriptor CreateGfs2Descriptor(FibreChannelDevice device)
|
||||
protected override FibreChannelDescriptor CreateGfs2Descriptor(FibreChannelDevice device)
|
||||
{
|
||||
return new Gfs2FcoeSrDescriptor(device);
|
||||
}
|
||||
|
@ -61,17 +61,17 @@ namespace XenAdmin.Wizards.NewSRWizard_Pages.Frontends
|
||||
|
||||
public virtual bool ShowNicColumn { get { return false; } }
|
||||
|
||||
protected LvmOhbaSrDescriptor CreateSrDescriptor(FibreChannelDevice device)
|
||||
private FibreChannelDescriptor CreateSrDescriptor(FibreChannelDevice device)
|
||||
{
|
||||
return SrType == SR.SRTypes.gfs2 ? CreateGfs2Descriptor(device) : CreateLvmSrDescriptor(device);
|
||||
}
|
||||
|
||||
protected virtual LvmOhbaSrDescriptor CreateLvmSrDescriptor(FibreChannelDevice device)
|
||||
protected virtual FibreChannelDescriptor CreateLvmSrDescriptor(FibreChannelDevice device)
|
||||
{
|
||||
return new LvmOhbaSrDescriptor(device, Connection);
|
||||
return new LvmOhbaSrDescriptor(device);
|
||||
}
|
||||
|
||||
protected virtual LvmOhbaSrDescriptor CreateGfs2Descriptor(FibreChannelDevice device)
|
||||
protected virtual FibreChannelDescriptor CreateGfs2Descriptor(FibreChannelDevice device)
|
||||
{
|
||||
return new Gfs2HbaSrDescriptor(device);
|
||||
}
|
||||
@ -95,11 +95,11 @@ namespace XenAdmin.Wizards.NewSRWizard_Pages.Frontends
|
||||
cancel = true;
|
||||
return;
|
||||
}
|
||||
|
||||
SrDescriptors = new List<LvmOhbaSrDescriptor>();
|
||||
|
||||
var existingSrDescriptors = new List<LvmOhbaSrDescriptor>();
|
||||
var formatDiskDescriptors = new List<LvmOhbaSrDescriptor>();
|
||||
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
|
||||
@ -225,7 +225,7 @@ namespace XenAdmin.Wizards.NewSRWizard_Pages.Frontends
|
||||
}
|
||||
}
|
||||
|
||||
private bool RunProbe(Host master, LvmOhbaSrDescriptor srDescriptor, out List<SR.SRInfo> srs)
|
||||
private bool RunProbe(Host master, FibreChannelDescriptor srDescriptor, out List<SR.SRInfo> srs)
|
||||
{
|
||||
srs = null;
|
||||
var action = new SrProbeAction(Connection, master, srDescriptor.SrType, srDescriptor.DeviceConfig);
|
||||
@ -446,7 +446,7 @@ namespace XenAdmin.Wizards.NewSRWizard_Pages.Frontends
|
||||
}
|
||||
}
|
||||
|
||||
public List<LvmOhbaSrDescriptor> SrDescriptors { get; private set; }
|
||||
public List<FibreChannelDescriptor> SrDescriptors { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// min size
|
||||
@ -521,29 +521,29 @@ namespace XenAdmin.Wizards.NewSRWizard_Pages.Frontends
|
||||
|
||||
private class LVMoHBAWarningDialogLauncher
|
||||
{
|
||||
private readonly List<LvmOhbaSrDescriptor> inputSrDescriptors;
|
||||
private readonly List<FibreChannelDescriptor> inputSrDescriptors;
|
||||
private readonly bool foundExistingSRs;
|
||||
private readonly IWin32Window owner;
|
||||
private readonly SR.SRTypes requestedSrType;
|
||||
|
||||
public List<LvmOhbaSrDescriptor> SrDescriptors { get; private set; }
|
||||
public List<FibreChannelDescriptor> SrDescriptors { get; private set; }
|
||||
public bool Cancelled { get; private set; }
|
||||
|
||||
public LVMoHBAWarningDialogLauncher(IWin32Window owner, List<LvmOhbaSrDescriptor> srDescriptors,
|
||||
public LVMoHBAWarningDialogLauncher(IWin32Window owner, List<FibreChannelDescriptor> srDescriptors,
|
||||
bool foundExistingSRs, SR.SRTypes requestedSrType)
|
||||
{
|
||||
this.owner = owner;
|
||||
this.foundExistingSRs = foundExistingSRs;
|
||||
inputSrDescriptors = srDescriptors;
|
||||
this.requestedSrType = requestedSrType;
|
||||
SrDescriptors = new List<LvmOhbaSrDescriptor>();
|
||||
SrDescriptors = new List<FibreChannelDescriptor>();
|
||||
}
|
||||
|
||||
private UserSelectedOption GetSelectedOption(LvmOhbaSrDescriptor lvmOhbaSrDescriptor,
|
||||
private UserSelectedOption GetSelectedOption(FibreChannelDescriptor descriptor,
|
||||
out bool repeatForRemainingLUNs)
|
||||
{
|
||||
int remainingCount = inputSrDescriptors.Count - 1 - inputSrDescriptors.IndexOf(lvmOhbaSrDescriptor);
|
||||
using (var dialog = new LVMoHBAWarningDialog(lvmOhbaSrDescriptor.Device, remainingCount, foundExistingSRs, lvmOhbaSrDescriptor.SrType, requestedSrType))
|
||||
int remainingCount = inputSrDescriptors.Count - 1 - inputSrDescriptors.IndexOf(descriptor);
|
||||
using (var dialog = new LVMoHBAWarningDialog(descriptor.Device, remainingCount, foundExistingSRs, descriptor.SrType, requestedSrType))
|
||||
{
|
||||
dialog.ShowDialog(owner);
|
||||
repeatForRemainingLUNs = dialog.RepeatForRemainingLUNs;
|
||||
@ -556,21 +556,21 @@ namespace XenAdmin.Wizards.NewSRWizard_Pages.Frontends
|
||||
bool repeatForRemainingLUNs = false;
|
||||
UserSelectedOption selectedOption = UserSelectedOption.Cancel;
|
||||
|
||||
foreach (LvmOhbaSrDescriptor lvmOhbaSrDescriptor in inputSrDescriptors)
|
||||
foreach (var descriptor in inputSrDescriptors)
|
||||
{
|
||||
if (!repeatForRemainingLUNs)
|
||||
{
|
||||
selectedOption = GetSelectedOption(lvmOhbaSrDescriptor, out repeatForRemainingLUNs);
|
||||
selectedOption = GetSelectedOption(descriptor, out repeatForRemainingLUNs);
|
||||
}
|
||||
|
||||
switch (selectedOption)
|
||||
{
|
||||
case UserSelectedOption.Format:
|
||||
lvmOhbaSrDescriptor.UUID = null;
|
||||
SrDescriptors.Add(lvmOhbaSrDescriptor);
|
||||
descriptor.UUID = null;
|
||||
SrDescriptors.Add(descriptor);
|
||||
break;
|
||||
case UserSelectedOption.Reattach:
|
||||
SrDescriptors.Add(lvmOhbaSrDescriptor);
|
||||
SrDescriptors.Add(descriptor);
|
||||
break;
|
||||
case UserSelectedOption.Cancel:
|
||||
SrDescriptors.Clear();
|
||||
|
@ -104,9 +104,9 @@ namespace XenAdmin.Wizards.NewSRWizard_Pages.Frontends
|
||||
return;
|
||||
|
||||
dataGridViewSummary.Rows.Add(new LVMoHBASummaryHeaderGridViewRow(success, srDescriptors.Count));
|
||||
foreach (var lvmOhbaSrDescriptor in srDescriptors)
|
||||
{
|
||||
DataGridViewRow row = new LVMoHBASrDescriptorGridViewRow(lvmOhbaSrDescriptor) {Visible = false};
|
||||
foreach (var descriptor in srDescriptors)
|
||||
{
|
||||
DataGridViewRow row = new LVMoHBASrDescriptorGridViewRow(descriptor) { Visible = false };
|
||||
dataGridViewSummary.Rows.Add(row);
|
||||
}
|
||||
}
|
||||
@ -241,19 +241,19 @@ namespace XenAdmin.Wizards.NewSRWizard_Pages.Frontends
|
||||
|
||||
protected override DataGridViewTextBoxCell GetDetailsCell()
|
||||
{
|
||||
LvmOhbaSrDescriptor lvmOhbaSrDescriptor = srDescriptor as LvmOhbaSrDescriptor;
|
||||
string text = lvmOhbaSrDescriptor != null
|
||||
? string.Format(Messages.NEWSR_LVMOHBA_SUMMARY_DETAILS_CELL_TEXT,
|
||||
lvmOhbaSrDescriptor.Name,
|
||||
Util.DiskSizeString(lvmOhbaSrDescriptor.Device.Size),
|
||||
lvmOhbaSrDescriptor.Device.Serial)
|
||||
: srDescriptor.Name;
|
||||
|
||||
var descriptor = srDescriptor as FibreChannelDescriptor;
|
||||
string text = descriptor != null
|
||||
? string.Format(Messages.NEWSR_LVMOHBA_SUMMARY_DETAILS_CELL_TEXT,
|
||||
descriptor.Name,
|
||||
Util.DiskSizeString(descriptor.Device.Size),
|
||||
descriptor.Device.Serial)
|
||||
: srDescriptor.Name;
|
||||
|
||||
return new DataGridViewTextBoxCell
|
||||
{
|
||||
Value = text,
|
||||
Style = {Padding = new Padding(10, 0, 0, 0)}
|
||||
};
|
||||
{
|
||||
Value = text,
|
||||
Style = {Padding = new Padding(10, 0, 0, 0)}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -52,66 +52,76 @@ namespace XenAdmin.Wizards.NewSRWizard_Pages
|
||||
public string UUID { get; set; }
|
||||
}
|
||||
|
||||
public class LvmOhbaSrDescriptor : SrDescriptor
|
||||
public abstract class FibreChannelDescriptor : SrDescriptor
|
||||
{
|
||||
public LvmOhbaSrDescriptor(FibreChannelDevice device, IXenConnection connection)
|
||||
protected FibreChannelDescriptor(FibreChannelDevice device, string descrFormat)
|
||||
{
|
||||
Device = device;
|
||||
DeviceConfig["SCSIid"] = device.SCSIid;
|
||||
|
||||
Description = string.Format(Messages.NEWSR_LVMOHBA_DESCRIPTION, device.Vendor, device.Serial);
|
||||
Description = string.Format(descrFormat, device.Vendor, device.Serial);
|
||||
}
|
||||
|
||||
public LvmOhbaSrDescriptor(FibreChannelDevice device)
|
||||
{
|
||||
Device = device;
|
||||
|
||||
Description = string.Format(Messages.NEWSR_LVMOHBA_DESCRIPTION, device.Vendor, device.Serial);
|
||||
}
|
||||
public abstract SR.SRTypes SrType { get; }
|
||||
|
||||
public FibreChannelDevice Device { get; private set; }
|
||||
}
|
||||
|
||||
public SR.SRTypes SrType
|
||||
public class LvmOhbaSrDescriptor : FibreChannelDescriptor
|
||||
{
|
||||
public LvmOhbaSrDescriptor(FibreChannelDevice device)
|
||||
: base(device, Messages.NEWSR_LVMOHBA_DESCRIPTION)
|
||||
{
|
||||
get
|
||||
{
|
||||
return this is Gfs2HbaSrDescriptor || this is Gfs2FcoeSrDescriptor
|
||||
? SR.SRTypes.gfs2
|
||||
: this is FcoeSrDescriptor ? SR.SRTypes.lvmofcoe : SR.SRTypes.lvmohba;
|
||||
}
|
||||
DeviceConfig["SCSIid"] = device.SCSIid;
|
||||
}
|
||||
|
||||
public override SR.SRTypes SrType
|
||||
{
|
||||
get { return SR.SRTypes.lvmohba; }
|
||||
}
|
||||
}
|
||||
|
||||
public class FcoeSrDescriptor : LvmOhbaSrDescriptor
|
||||
public class FcoeSrDescriptor : FibreChannelDescriptor
|
||||
{
|
||||
public FcoeSrDescriptor(FibreChannelDevice device) : base(device)
|
||||
public FcoeSrDescriptor(FibreChannelDevice device)
|
||||
: base(device, Messages.NEWSR_LVMOFCOE_DESCRIPTION)
|
||||
{
|
||||
DeviceConfig["SCSIid"] = device.SCSIid;
|
||||
DeviceConfig["path"] = device.Path;
|
||||
}
|
||||
|
||||
Description = string.Format(Messages.NEWSR_LVMOFCOE_DESCRIPTION, device.Vendor, device.Serial);
|
||||
public override SR.SRTypes SrType
|
||||
{
|
||||
get { return SR.SRTypes.lvmofcoe; }
|
||||
}
|
||||
}
|
||||
|
||||
public class Gfs2HbaSrDescriptor : LvmOhbaSrDescriptor
|
||||
public class Gfs2HbaSrDescriptor : FibreChannelDescriptor
|
||||
{
|
||||
public Gfs2HbaSrDescriptor(FibreChannelDevice device)
|
||||
: base(device)
|
||||
: base(device, Messages.NEWSR_LVMOHBA_DESCRIPTION)
|
||||
{
|
||||
DeviceConfig["provider"] = "hba";
|
||||
DeviceConfig["ScsiId"] = device.SCSIid;
|
||||
Description = string.Format(Messages.NEWSR_LVMOHBA_DESCRIPTION, device.Vendor, device.Serial);
|
||||
}
|
||||
|
||||
public override SR.SRTypes SrType
|
||||
{
|
||||
get { return SR.SRTypes.gfs2; }
|
||||
}
|
||||
}
|
||||
|
||||
public class Gfs2FcoeSrDescriptor : FcoeSrDescriptor
|
||||
public class Gfs2FcoeSrDescriptor : FibreChannelDescriptor
|
||||
{
|
||||
public Gfs2FcoeSrDescriptor(FibreChannelDevice device)
|
||||
: base(device)
|
||||
: base(device, Messages.NEWSR_LVMOFCOE_DESCRIPTION)
|
||||
{
|
||||
DeviceConfig["provider"] = "fcoe";
|
||||
DeviceConfig["ScsiId"] = device.SCSIid;
|
||||
Description = string.Format(Messages.NEWSR_LVMOFCOE_DESCRIPTION, device.Vendor, device.Serial);
|
||||
DeviceConfig["path"] = device.Path;
|
||||
}
|
||||
|
||||
public override SR.SRTypes SrType
|
||||
{
|
||||
get { return SR.SRTypes.gfs2; }
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user