mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2024-11-23 20:36:33 +01:00
CA-340735: Re-write to fix workflow issues and simplify the code.
Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
This commit is contained in:
parent
bff0fcfc85
commit
d21f6dda5a
@ -43,6 +43,8 @@ namespace XenAdmin.Controls
|
||||
{
|
||||
public class ISODropDownBox : NonSelectableComboBox
|
||||
{
|
||||
public event Action SrsRefreshed;
|
||||
|
||||
protected VM vm;
|
||||
private bool refreshOnClose;
|
||||
protected bool changing = false;
|
||||
@ -80,8 +82,8 @@ namespace XenAdmin.Controls
|
||||
{
|
||||
Program.AssertOnEventThread();
|
||||
|
||||
if (Empty)
|
||||
Items.Add(new ToStringWrapper<VDI>(null, Messages.EMPTY)); //Create a special VDIWrapper for the empty dropdown item
|
||||
//Create a special VDIWrapper for the empty dropdown item
|
||||
Items.Add(new ToStringWrapper<VDI>(null, Messages.EMPTY));
|
||||
|
||||
if (connection == null)
|
||||
return;
|
||||
@ -137,34 +139,28 @@ namespace XenAdmin.Controls
|
||||
|
||||
protected void SelectCD()
|
||||
{
|
||||
if (selectedCD == null)
|
||||
if (selectedCD != null)
|
||||
{
|
||||
if (Items.Count > 0)
|
||||
SelectedIndex = 0;
|
||||
else
|
||||
SelectedIndex = -1;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (object o in Items)
|
||||
{
|
||||
VDI iso = (o as ToStringWrapper<VDI>)?.item;
|
||||
|
||||
if (iso == null || !iso.Show(Properties.Settings.Default.ShowHiddenVMs))
|
||||
continue;
|
||||
|
||||
if (iso == selectedCD)
|
||||
foreach (object o in Items)
|
||||
{
|
||||
SelectedItem = o;
|
||||
break;
|
||||
VDI iso = (o as ToStringWrapper<VDI>)?.item;
|
||||
|
||||
if (iso == null || !iso.Show(Properties.Settings.Default.ShowHiddenVMs))
|
||||
continue;
|
||||
|
||||
if (iso == selectedCD)
|
||||
{
|
||||
SelectedItem = o;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public bool Empty { get; set; } = true;
|
||||
if (Items.Count > 0)
|
||||
SelectedIndex = 0;
|
||||
else
|
||||
SelectedIndex = -1;
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
@ -346,6 +342,7 @@ namespace XenAdmin.Controls
|
||||
|
||||
SelectCD();
|
||||
refreshOnClose = false;
|
||||
SrsRefreshed?.Invoke();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -239,14 +239,6 @@ namespace XenAdmin.Wizards.NewVMWizard
|
||||
page_4_HomeServer.DisableStep = false;
|
||||
}
|
||||
|
||||
// if custom template has no cd drive (must have been removed via cli) don't add one
|
||||
var noInstallMedia = Helpers.CustomWithNoDVD(selectedTemplate);
|
||||
|
||||
if (selectedTemplate != null && selectedTemplate.DefaultTemplate() && string.IsNullOrEmpty(selectedTemplate.InstallMethods()))
|
||||
noInstallMedia = true;
|
||||
|
||||
page_3_InstallationMedia.ShowInstallationMedia = !noInstallMedia;
|
||||
|
||||
// The user cannot set their own affinity, use the one off the template
|
||||
if (BlockAffinitySelection)
|
||||
m_affinity = xenConnection.Resolve(selectedTemplate.affinity);
|
||||
|
@ -60,7 +60,7 @@ namespace XenAdmin.Wizards.NewVMWizard
|
||||
this.CdRadioButton.Name = "CdRadioButton";
|
||||
this.CdRadioButton.TabStop = true;
|
||||
this.CdRadioButton.UseVisualStyleBackColor = true;
|
||||
this.CdRadioButton.CheckedChanged += new System.EventHandler(this.PhysicalRadioButton_CheckedChanged);
|
||||
this.CdRadioButton.CheckedChanged += new System.EventHandler(this.CdRadioButton_CheckedChanged);
|
||||
//
|
||||
// UrlRadioButton
|
||||
//
|
||||
@ -104,12 +104,16 @@ namespace XenAdmin.Wizards.NewVMWizard
|
||||
this.CdDropDownBox.FormattingEnabled = true;
|
||||
this.CdDropDownBox.Name = "CdDropDownBox";
|
||||
this.CdDropDownBox.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.CdDropDownBox_DrawItem);
|
||||
this.CdDropDownBox.SelectedIndexChanged += new System.EventHandler(this.CdDropDownBox_SelectedIndexChanged);
|
||||
this.CdDropDownBox.DropDownClosed += new System.EventHandler(this.CdDropDownBox_DropDownClosed);
|
||||
this.CdDropDownBox.Enter += new System.EventHandler(this.CdDropDownBox_Enter);
|
||||
//
|
||||
// UrlTextBox
|
||||
//
|
||||
resources.ApplyResources(this.UrlTextBox, "UrlTextBox");
|
||||
this.UrlTextBox.Name = "UrlTextBox";
|
||||
this.UrlTextBox.TextChanged += new System.EventHandler(this.UrlTextBox_TextChanged);
|
||||
this.UrlTextBox.Enter += new System.EventHandler(this.UrlTextBox_Enter);
|
||||
//
|
||||
// panelInstallationMethod
|
||||
//
|
||||
|
@ -36,9 +36,6 @@ using XenAdmin.Actions.VMActions;
|
||||
using XenAPI;
|
||||
using XenAdmin.Controls;
|
||||
using XenAdmin.Core;
|
||||
using System.Diagnostics;
|
||||
using XenAdmin.Actions;
|
||||
using XenAdmin.Dialogs;
|
||||
using XenCenterLib;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
@ -48,148 +45,73 @@ namespace XenAdmin.Wizards.NewVMWizard
|
||||
{
|
||||
public partial class Page_InstallationMedia : XenTabPage
|
||||
{
|
||||
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private VM m_template;
|
||||
|
||||
public Page_InstallationMedia()
|
||||
{
|
||||
InitializeComponent();
|
||||
CdDropDownBox.Empty = false;
|
||||
CdDropDownBox.SrsRefreshed += CdDropDownBox_SrsRefreshed;
|
||||
}
|
||||
|
||||
bool defaultTemplate, userTemplate, hvm, eli, installMethods, installCd, installUrl, cds, installed;
|
||||
|
||||
#region Accessors
|
||||
|
||||
public Host Affinity { private get; set; }
|
||||
|
||||
public bool ShowInstallationMedia { private get; set; }
|
||||
public BootMode SelectedBootMode => SelectedTemplate.IsHVM()
|
||||
? bootModesControl1.SelectedOption
|
||||
: BootMode.NOT_AVAILABLE;
|
||||
|
||||
public bool IsSelectedTemplateHVM { get { return SelectedTemplate.IsHVM(); } }
|
||||
|
||||
protected override void PageLoadedCore(PageLoadedDirection direction)
|
||||
public InstallMethod SelectedInstallMethod
|
||||
{
|
||||
VM oldTemplate = m_template;
|
||||
m_template = SelectedTemplate;
|
||||
|
||||
// We only want to do all these updates if the template has changed (or has gone from null -> selected)
|
||||
if (oldTemplate == m_template)
|
||||
return;
|
||||
|
||||
/* This method is supposed to do the following:
|
||||
*
|
||||
* PV -> Install from DVD drive (no empty)
|
||||
* Url
|
||||
*
|
||||
* HVM -> Install from DVD drive (no empty)
|
||||
* Boot from network
|
||||
*
|
||||
* Custom -> DVD drive (inc empty)
|
||||
*
|
||||
* Disable Installation method section if the custom template has no DVD drive (except debian etch template)
|
||||
*/
|
||||
|
||||
PvBootBox.Visible = !IsSelectedTemplateHVM;
|
||||
PvBootTextBox.Text = m_template.PV_args;
|
||||
|
||||
bootModesControl1.Visible = IsSelectedTemplateHVM &&
|
||||
BootModesControl.ShowBootModeOptions(SelectedTemplate.Connection);
|
||||
;
|
||||
bootModesControl1.TemplateVM = m_template;
|
||||
|
||||
if (!ShowInstallationMedia)
|
||||
get
|
||||
{
|
||||
CdRadioButton.Checked = UrlRadioButton.Checked = false;
|
||||
CdDropDownBox.Items.Clear();
|
||||
UrlTextBox.Text = string.Empty;
|
||||
panelInstallationMethod.Enabled = false;
|
||||
return;
|
||||
}
|
||||
panelInstallationMethod.Enabled = true;
|
||||
if (CdRadioButton.Enabled && CdRadioButton.Checked)
|
||||
return InstallMethod.CD;
|
||||
|
||||
defaultTemplate = m_template.DefaultTemplate();
|
||||
userTemplate = !defaultTemplate;
|
||||
if (UrlRadioButton.Enabled && UrlRadioButton.Checked)
|
||||
return InstallMethod.Network;
|
||||
|
||||
return InstallMethod.None;
|
||||
}
|
||||
}
|
||||
|
||||
public string SelectedPvArgs => SelectedTemplate.IsHVM() ? string.Empty : PvBootTextBox.Text;
|
||||
|
||||
public VDI SelectedCD => CdRadioButton.Enabled && CdRadioButton.Checked
|
||||
? CdDropDownBox.SelectedCD
|
||||
: null;
|
||||
|
||||
public string SelectedUrl => UrlRadioButton.Enabled && UrlRadioButton.Checked && UrlTextBox.Visible
|
||||
? UrlTextBox.Text
|
||||
: string.Empty;
|
||||
|
||||
public VM SelectedTemplate { private get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
private void AnalyseTemplate(out bool isUserTemplate, out bool hvm, out bool eli,
|
||||
out string installMethods, out bool installCd, out bool installUrl)
|
||||
{
|
||||
isUserTemplate = !m_template.DefaultTemplate();
|
||||
hvm = m_template.IsHVM();
|
||||
eli = !hvm && m_template.PV_bootloader == "eliloader";
|
||||
installMethods = m_template.InstallMethods();
|
||||
installCd = installMethods != null && installMethods.Contains("cdrom");
|
||||
installUrl = installMethods != null &&
|
||||
(installMethods.Contains("http") || installMethods.Contains("ftp") || installMethods.Contains("nfs"));
|
||||
}
|
||||
|
||||
var tmplMethods = m_template.InstallMethods();
|
||||
installMethods = !string.IsNullOrEmpty(tmplMethods);
|
||||
installCd = installMethods && tmplMethods.Contains("cdrom") && (hvm || eli);
|
||||
installUrl = installMethods &&
|
||||
(tmplMethods.Contains("http") || tmplMethods.Contains("ftp") || tmplMethods.Contains("nfs")) &&
|
||||
eli;
|
||||
cds = Helpers.CDsExist(Connection);
|
||||
installed = userTemplate || !installMethods;
|
||||
|
||||
CdRadioButton.Text = installed ? Messages.NEWVMWIZARD_INSTALLMEDIA_DVD : Messages.NEWVMWIZARD_INSTALLMEDIA_INSTALLDVD;
|
||||
CdRadioButton.Enabled = (installed || installCd) && cds;
|
||||
CdDropDownBox.Empty = installed;
|
||||
|
||||
UrlRadioButton.Text = hvm ? Messages.NEWVMWIZARD_INSTALLMEDIA_INSTALLPXE : Messages.NEWVMWIZARD_INSTALLMEDIA_INSTALLURL;
|
||||
UrlRadioButton.Enabled = (!installed && ((eli && installUrl) || hvm));
|
||||
|
||||
UrlTextBox.Visible = !hvm;
|
||||
UrlTextBox.Text = !installed ? m_template.InstallRepository() ?? "" : "";
|
||||
|
||||
if (installed || (installCd && cds)) // if installed we will always have the empty cd
|
||||
{
|
||||
CdRadioButton.Checked = true;
|
||||
CdDropDownBox.Select();
|
||||
}
|
||||
else if (eli && installUrl)
|
||||
{
|
||||
UrlRadioButton.Checked = true;
|
||||
UrlTextBox.Select();
|
||||
}
|
||||
else
|
||||
{
|
||||
// oh dear, select anything that is enabled
|
||||
if (CdRadioButton.Enabled)
|
||||
CdRadioButton.Checked = true;
|
||||
else if (UrlRadioButton.Enabled)
|
||||
UrlRadioButton.Checked = true;
|
||||
else
|
||||
Trace.Assert(false, string.Format("No install options were enabled, something is wrong with the template '{0}'", m_template.Name()));
|
||||
}
|
||||
if(IsBootFromNetworkCustomTemplate(userTemplate))
|
||||
{
|
||||
UrlRadioButton.Enabled = true;
|
||||
UrlRadioButton.Checked = true;
|
||||
private void EnableCdRadioButton(bool isUserTemplate, bool hvm, bool eli, string installMethods, bool installCd)
|
||||
{
|
||||
if (isUserTemplate && m_template.GetBootOrder().StartsWith("N"))
|
||||
CdRadioButton.Enabled = false;
|
||||
}
|
||||
|
||||
LoadCdBox();
|
||||
|
||||
UpdateEnablement();
|
||||
else
|
||||
CdRadioButton.Enabled = isUserTemplate || string.IsNullOrEmpty(installMethods) || installCd && (hvm || eli);
|
||||
}
|
||||
|
||||
public BootMode SelectedBootMode { get { return IsSelectedTemplateHVM ? bootModesControl1.SelectedOption : BootMode.NOT_AVAILABLE; } }
|
||||
|
||||
private bool IsBootFromNetworkCustomTemplate(bool userTemplate)
|
||||
{
|
||||
return (userTemplate && m_template.GetBootOrder().StartsWith("N"));
|
||||
}
|
||||
|
||||
private void LoadCdBox()
|
||||
{
|
||||
CdDropDownBox.VM = m_template;
|
||||
|
||||
VBD cddrive = m_template.FindVMCDROM();
|
||||
|
||||
VDI cd = cddrive != null && !cddrive.empty
|
||||
? Connection.Resolve<VDI>(cddrive.VDI)
|
||||
: (CdDropDownBox.Empty ? null : GetAffinityDvdDrive());
|
||||
|
||||
if (cd == null)
|
||||
return; // select default whatever that is
|
||||
|
||||
SR sr = Connection.Resolve<SR>(cd.SR);
|
||||
if (sr == null)
|
||||
return; // select default whatever that is
|
||||
|
||||
CdDropDownBox.SelectedCD = cd;
|
||||
}
|
||||
|
||||
public VDI GetAffinityDvdDrive()
|
||||
private VDI GetAffinityDvdDrive()
|
||||
{
|
||||
if (Affinity == null || Affinity.Connection == null)
|
||||
return null;
|
||||
@ -202,67 +124,114 @@ namespace XenAdmin.Wizards.NewVMWizard
|
||||
return null;
|
||||
}
|
||||
|
||||
public InstallMethod SelectedInstallMethod
|
||||
|
||||
#region XenTabPage overrides
|
||||
|
||||
protected override void PageLoadedCore(PageLoadedDirection direction)
|
||||
{
|
||||
get
|
||||
if (m_template == SelectedTemplate)
|
||||
return;
|
||||
|
||||
/* This method is supposed to do the following:
|
||||
*
|
||||
* PV -> Install from DVD drive (selecting <empty> disables Next)
|
||||
* -> Url
|
||||
*
|
||||
* HVM -> Install from DVD drive (selecting <empty> disables Next)
|
||||
* -> Boot from network
|
||||
*
|
||||
* Custom with DVD drive -> DVD drive (selecting <empty> does not disable Next)
|
||||
*
|
||||
* Custom without DVD drive -> Disable Installation method section
|
||||
*/
|
||||
|
||||
m_template = SelectedTemplate;
|
||||
AnalyseTemplate(out bool isUserTemplate, out bool hvm, out bool eli,
|
||||
out string installMethods, out bool installCd, out bool installUrl);
|
||||
|
||||
VBD cdDrive = m_template.FindVMCDROM();
|
||||
|
||||
PvBootBox.Visible = !hvm;
|
||||
PvBootTextBox.Text = hvm ? string.Empty : m_template.PV_args;
|
||||
|
||||
bootModesControl1.Visible = hvm && BootModesControl.ShowBootModeOptions(SelectedTemplate.Connection);
|
||||
bootModesControl1.TemplateVM = m_template;
|
||||
|
||||
if (isUserTemplate && cdDrive == null ||
|
||||
!isUserTemplate && string.IsNullOrEmpty(m_template.InstallMethods()))
|
||||
{
|
||||
if (!ShowInstallationMedia || m_template.DefaultTemplate() && String.IsNullOrEmpty(m_template.InstallMethods()))
|
||||
return InstallMethod.None;
|
||||
if (CdRadioButton.Checked)
|
||||
return InstallMethod.CD;
|
||||
|
||||
if (UrlRadioButton.Checked)
|
||||
return InstallMethod.Network;
|
||||
|
||||
return InstallMethod.None;
|
||||
CdRadioButton.Checked = UrlRadioButton.Checked = false;
|
||||
CdDropDownBox.Items.Clear();
|
||||
UrlTextBox.Text = string.Empty;
|
||||
panelInstallationMethod.Enabled = false;
|
||||
OnPageUpdated();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public string SelectedPvArgs
|
||||
{
|
||||
get
|
||||
panelInstallationMethod.Enabled = true;
|
||||
|
||||
CdRadioButton.Text = isUserTemplate || string.IsNullOrEmpty(installMethods)
|
||||
? Messages.NEWVMWIZARD_INSTALLMEDIA_DVD
|
||||
: Messages.NEWVMWIZARD_INSTALLMEDIA_INSTALLDVD;
|
||||
|
||||
EnableCdRadioButton(isUserTemplate, hvm, eli, installMethods, installCd);
|
||||
CdDropDownBox.Enabled = CdRadioButton.Enabled;
|
||||
|
||||
UrlRadioButton.Text = hvm ? Messages.NEWVMWIZARD_INSTALLMEDIA_INSTALLPXE : Messages.NEWVMWIZARD_INSTALLMEDIA_INSTALLURL;
|
||||
|
||||
UrlRadioButton.Enabled = isUserTemplate && m_template.GetBootOrder().StartsWith("N") ||
|
||||
!isUserTemplate && !string.IsNullOrEmpty(installMethods) && (hvm || eli && installUrl);
|
||||
|
||||
UrlTextBox.Enabled = UrlRadioButton.Enabled;
|
||||
UrlTextBox.Visible = !hvm;
|
||||
UrlTextBox.Text = isUserTemplate || string.IsNullOrEmpty(installMethods) ? "" : m_template.InstallRepository() ?? "";
|
||||
|
||||
if (CdRadioButton.Enabled)
|
||||
{
|
||||
return !IsSelectedTemplateHVM ? PvBootTextBox.Text : string.Empty;
|
||||
CdRadioButton.Checked = true;
|
||||
CdDropDownBox.Select();
|
||||
}
|
||||
}
|
||||
|
||||
public VDI SelectedCD
|
||||
{
|
||||
get
|
||||
else if (UrlRadioButton.Enabled)
|
||||
{
|
||||
return ShowInstallationMedia && CdRadioButton.Checked ? CdDropDownBox.SelectedCD : null;
|
||||
UrlRadioButton.Checked = true;
|
||||
UrlTextBox.Select();
|
||||
}
|
||||
}
|
||||
|
||||
public string SelectedUrl
|
||||
{
|
||||
get
|
||||
{
|
||||
return ShowInstallationMedia && UrlRadioButton.Checked ? UrlTextBox.Text : string.Empty;
|
||||
}
|
||||
}
|
||||
CdDropDownBox.VM = m_template;
|
||||
|
||||
public VM SelectedTemplate { private get; set; }
|
||||
VDI cd = null;
|
||||
|
||||
if (cdDrive != null && !cdDrive.empty)
|
||||
cd = Connection.Resolve(cdDrive.VDI);
|
||||
else if (!isUserTemplate && !string.IsNullOrEmpty(installMethods))
|
||||
cd = GetAffinityDvdDrive();
|
||||
|
||||
CdDropDownBox.SelectedCD = cd != null && Connection.Resolve(cd.SR) != null ? cd : null;
|
||||
|
||||
OnPageUpdated();
|
||||
}
|
||||
|
||||
public override bool EnableNext()
|
||||
{
|
||||
return ShowInstallationMedia ? CdRadioButton.Checked || UrlRadioButton.Checked : true;
|
||||
if (!panelInstallationMethod.Enabled)
|
||||
return true;
|
||||
|
||||
if (CdRadioButton.Enabled && CdRadioButton.Checked)
|
||||
return !m_template.DefaultTemplate() ||
|
||||
string.IsNullOrEmpty(m_template.InstallMethods()) ||
|
||||
CdDropDownBox.SelectedCD != null;
|
||||
|
||||
if (UrlRadioButton.Enabled && UrlRadioButton.Checked)
|
||||
return !UrlTextBox.Visible || !string.IsNullOrEmpty(UrlTextBox.Text);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override string Text
|
||||
{
|
||||
get { return Messages.NEWVMWIZARD_INSTALLATIONMEDIAPAGE_NAME; }
|
||||
}
|
||||
public override string Text => Messages.NEWVMWIZARD_INSTALLATIONMEDIAPAGE_NAME;
|
||||
|
||||
public override string PageTitle
|
||||
{
|
||||
get { return Messages.NEWVMWIZARD_INSTALLATIONMEDIAPAGE_TITLE; }
|
||||
}
|
||||
public override string PageTitle => Messages.NEWVMWIZARD_INSTALLATIONMEDIAPAGE_TITLE;
|
||||
|
||||
public override string HelpID
|
||||
{
|
||||
get { return "InstallationMedia"; }
|
||||
}
|
||||
public override string HelpID => "InstallationMedia";
|
||||
|
||||
public override List<KeyValuePair<string, string>> PageSummary
|
||||
{
|
||||
@ -280,63 +249,51 @@ namespace XenAdmin.Wizards.NewVMWizard
|
||||
sum.Add(new KeyValuePair<string, string>(Messages.NEWVMWIZARD_NETWORKMEDIAPAGE_INSTALLATIONURL, SelectedUrl));
|
||||
break;
|
||||
}
|
||||
if (Helpers.NaplesOrGreater(SelectedTemplate.Connection) && IsSelectedTemplateHVM)
|
||||
|
||||
if (Helpers.NaplesOrGreater(SelectedTemplate.Connection) && SelectedTemplate.IsHVM())
|
||||
sum.Add(new KeyValuePair<string, string>(Messages.BOOT_MODE, SelectedBootMode.StringOf()));
|
||||
return sum;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateEnablement()
|
||||
{
|
||||
CdDropDownBox.Enabled = CdRadioButton.Checked;
|
||||
UrlTextBox.Enabled = UrlRadioButton.Checked;
|
||||
#endregion
|
||||
|
||||
OnPageUpdated();
|
||||
}
|
||||
|
||||
private void PhysicalRadioButton_CheckedChanged(object sender, EventArgs e)
|
||||
#region Event Handlers
|
||||
|
||||
private void CdRadioButton_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
UpdateEnablement();
|
||||
if (CdRadioButton.Checked)
|
||||
OnPageUpdated();
|
||||
}
|
||||
|
||||
private void UrlRadioButton_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
UpdateEnablement();
|
||||
if (UrlRadioButton.Checked)
|
||||
OnPageUpdated();
|
||||
}
|
||||
|
||||
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
|
||||
{
|
||||
NewSRWizard wizard = new NewSRWizard(Connection);
|
||||
wizard.CheckNFSISORadioButton();
|
||||
CdRadioButton.Enabled = CdDropDownBox.Enabled = false; //disable until the SRs are refreshed
|
||||
|
||||
if (wizard.ShowDialog() == DialogResult.Cancel)
|
||||
return;
|
||||
|
||||
// Return if we lost connection
|
||||
if (Connection == null || Helpers.GetPoolOfOne(Connection) == null)
|
||||
using (var wizard = new NewSRWizard(Connection))
|
||||
{
|
||||
log.Error("Page_InstallationMedia: connection to the server was lost");
|
||||
return;
|
||||
wizard.CheckNFSISORadioButton();
|
||||
|
||||
if (wizard.ShowDialog() == DialogResult.Cancel)
|
||||
CdDropDownBox_SrsRefreshed();
|
||||
}
|
||||
}
|
||||
|
||||
// There's a chance the cd radio button was disabled because we didnt have any isos to select from, so refresh that bool
|
||||
// and the enablement of that button.
|
||||
cds = Helpers.CDsExist(Connection);
|
||||
CdRadioButton.Enabled = (installed || installCd) && cds;
|
||||
private void CdDropDownBox_SrsRefreshed()
|
||||
{
|
||||
AnalyseTemplate(out bool isUserTemplate, out bool hvm, out bool eli,
|
||||
out string installMethods, out bool installCd, out bool _);
|
||||
|
||||
// We can get a lot of refresh flickering in the ISO box as all the VDIs are discovered
|
||||
// Possibly slightly rude, but were going to have a pretend action here which gives it some breathing space before we look for VDIs
|
||||
DelegatedAsyncAction waitAction = new DelegatedAsyncAction(Connection, Messages.SR_REFRESH_ACTION_TITLE, Messages.SR_REFRESH_ACTION_DESC, Messages.COMPLETED,
|
||||
delegate
|
||||
{
|
||||
System.Threading.Thread.Sleep(10000);
|
||||
}, true);
|
||||
using (var dlg = new ActionProgressDialog(waitAction, System.Windows.Forms.ProgressBarStyle.Marquee))
|
||||
dlg.ShowDialog(this);
|
||||
|
||||
// Set the connection on the drop down iso box. This causes a complete refresh rather than a mini one - otherwise we miss out on
|
||||
// getting event handlers for the new SR
|
||||
CdDropDownBox.connection = Connection;
|
||||
EnableCdRadioButton(isUserTemplate, hvm, eli, installMethods, installCd);
|
||||
CdDropDownBox.Enabled = CdRadioButton.Enabled;
|
||||
OnPageUpdated();
|
||||
}
|
||||
|
||||
private void CdDropDownBox_DropDownClosed(object sender, EventArgs e)
|
||||
@ -368,5 +325,26 @@ namespace XenAdmin.Wizards.NewVMWizard
|
||||
}
|
||||
}
|
||||
|
||||
private void CdDropDownBox_Enter(object sender, EventArgs e)
|
||||
{
|
||||
CdRadioButton.Checked = true;
|
||||
}
|
||||
|
||||
private void CdDropDownBox_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
OnPageUpdated();
|
||||
}
|
||||
|
||||
private void UrlTextBox_Enter(object sender, EventArgs e)
|
||||
{
|
||||
UrlRadioButton.Checked = true;
|
||||
}
|
||||
|
||||
private void UrlTextBox_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
OnPageUpdated();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -142,7 +142,7 @@
|
||||
<value>3, 3, 3, 3</value>
|
||||
</data>
|
||||
<data name="bootModesControl1.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>542, 149</value>
|
||||
<value>542, 192</value>
|
||||
</data>
|
||||
<data name="bootModesControl1.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>7</value>
|
||||
@ -250,7 +250,7 @@
|
||||
<value>524, 70</value>
|
||||
</data>
|
||||
<data name="tableLayoutPanel2.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>2</value>
|
||||
<value>0</value>
|
||||
</data>
|
||||
<data name=">>tableLayoutPanel2.Name" xml:space="preserve">
|
||||
<value>tableLayoutPanel2</value>
|
||||
@ -307,7 +307,7 @@
|
||||
<value>149, 17</value>
|
||||
</data>
|
||||
<data name="CdRadioButton.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>0</value>
|
||||
<value>1</value>
|
||||
</data>
|
||||
<data name="CdRadioButton.Text" xml:space="preserve">
|
||||
<value>Install from this &DVD drive:</value>
|
||||
@ -340,7 +340,7 @@
|
||||
<value>122, 17</value>
|
||||
</data>
|
||||
<data name="UrlRadioButton.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>3</value>
|
||||
<value>4</value>
|
||||
</data>
|
||||
<data name="UrlRadioButton.Text" xml:space="preserve">
|
||||
<value>Install from this &URL:</value>
|
||||
@ -358,7 +358,7 @@
|
||||
<value>3</value>
|
||||
</data>
|
||||
<data name="CdDropDownBox.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>Top, Left, Right</value>
|
||||
<value>Left, Right</value>
|
||||
</data>
|
||||
<data name="CdDropDownBox.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>23, 69</value>
|
||||
@ -370,7 +370,7 @@
|
||||
<value>381, 21</value>
|
||||
</data>
|
||||
<data name="CdDropDownBox.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>1</value>
|
||||
<value>2</value>
|
||||
</data>
|
||||
<data name=">>CdDropDownBox.Name" xml:space="preserve">
|
||||
<value>CdDropDownBox</value>
|
||||
@ -385,7 +385,7 @@
|
||||
<value>5</value>
|
||||
</data>
|
||||
<data name="UrlTextBox.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>Top, Left, Right</value>
|
||||
<value>Left, Right</value>
|
||||
</data>
|
||||
<data name="UrlTextBox.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>23, 128</value>
|
||||
@ -397,7 +397,7 @@
|
||||
<value>381, 20</value>
|
||||
</data>
|
||||
<data name="UrlTextBox.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>4</value>
|
||||
<value>5</value>
|
||||
</data>
|
||||
<data name=">>UrlTextBox.Name" xml:space="preserve">
|
||||
<value>UrlTextBox</value>
|
||||
@ -411,33 +411,27 @@
|
||||
<data name=">>UrlTextBox.ZOrder" xml:space="preserve">
|
||||
<value>6</value>
|
||||
</data>
|
||||
<data name="linkLabelAttachNewIsoStore.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>Left</value>
|
||||
</data>
|
||||
<data name="linkLabelAttachNewIsoStore.AutoSize" type="System.Boolean, mscorlib">
|
||||
<value>True</value>
|
||||
</data>
|
||||
<data name="linkLabelAttachNewIsoStore.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
|
||||
<value>Fill</value>
|
||||
</data>
|
||||
<data name="linkLabelAttachNewIsoStore.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
|
||||
<value>NoControl</value>
|
||||
</data>
|
||||
<data name="linkLabelAttachNewIsoStore.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>419, 66</value>
|
||||
</data>
|
||||
<data name="linkLabelAttachNewIsoStore.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
|
||||
<value>12, 0, 3, 0</value>
|
||||
<value>410, 73</value>
|
||||
</data>
|
||||
<data name="linkLabelAttachNewIsoStore.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>123, 27</value>
|
||||
<value>89, 13</value>
|
||||
</data>
|
||||
<data name="linkLabelAttachNewIsoStore.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>2</value>
|
||||
<value>3</value>
|
||||
</data>
|
||||
<data name="linkLabelAttachNewIsoStore.Text" xml:space="preserve">
|
||||
<value>New ISO library...</value>
|
||||
</data>
|
||||
<data name="linkLabelAttachNewIsoStore.TextAlign" type="System.Drawing.ContentAlignment, System.Drawing">
|
||||
<value>MiddleLeft</value>
|
||||
</data>
|
||||
<data name=">>linkLabelAttachNewIsoStore.Name" xml:space="preserve">
|
||||
<value>linkLabelAttachNewIsoStore</value>
|
||||
</data>
|
||||
@ -463,10 +457,10 @@
|
||||
<value>8</value>
|
||||
</data>
|
||||
<data name="panelInstallationMethod.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>548, 418</value>
|
||||
<value>548, 464</value>
|
||||
</data>
|
||||
<data name="panelInstallationMethod.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>1</value>
|
||||
<value>0</value>
|
||||
</data>
|
||||
<data name=">>panelInstallationMethod.Name" xml:space="preserve">
|
||||
<value>panelInstallationMethod</value>
|
||||
@ -520,7 +514,7 @@
|
||||
<value>96, 96</value>
|
||||
</data>
|
||||
<data name="$this.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>548, 418</value>
|
||||
<value>548, 464</value>
|
||||
</data>
|
||||
<data name=">>comboBoxToolTip.Name" xml:space="preserve">
|
||||
<value>comboBoxToolTip</value>
|
||||
|
@ -1596,23 +1596,6 @@ namespace XenAdmin.Core
|
||||
} while (true);
|
||||
}
|
||||
|
||||
public static bool CDsExist(IXenConnection connection)
|
||||
{
|
||||
if (connection == null)
|
||||
return false;
|
||||
|
||||
foreach (SR sr in connection.Cache.SRs)
|
||||
{
|
||||
if (sr.content_type != SR.Content_Type_ISO)
|
||||
continue;
|
||||
|
||||
if (sr.VDIs.Count > 0)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool CompareLists<T>(List<T> l1, List<T> l2)
|
||||
{
|
||||
if (l1 == l2)
|
||||
|
Loading…
Reference in New Issue
Block a user