mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2024-11-27 02:56:01 +01:00
CA-350411 part 2: Add conditional page control refresh in Import Wizard
Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
This commit is contained in:
parent
355321faea
commit
051c205899
@ -55,17 +55,17 @@ namespace XenAdmin.Wizards.ImportWizard
|
||||
/// <summary>
|
||||
/// Gets the page's title (headline)
|
||||
/// </summary>
|
||||
public override string PageTitle { get { return Messages.IMAGE_DEFINITION_PAGE_TITLE; } }
|
||||
public override string PageTitle => Messages.IMAGE_DEFINITION_PAGE_TITLE;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the page's label in the (left hand side) wizard progress panel
|
||||
/// </summary>
|
||||
public override string Text { get { return Messages.IMAGE_DEFINITION_PAGE_TEXT; } }
|
||||
public override string Text => Messages.IMAGE_DEFINITION_PAGE_TEXT;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the value by which the help files section for this page is identified
|
||||
/// </summary>
|
||||
public override string HelpID { get { return "VMConfig"; } }
|
||||
public override string HelpID => "VMConfig";
|
||||
|
||||
protected override bool ImplementsIsDirty()
|
||||
{
|
||||
@ -99,14 +99,14 @@ namespace XenAdmin.Wizards.ImportWizard
|
||||
|
||||
public bool IsWim { internal get; set; }
|
||||
|
||||
public string VmName { get { return m_textBoxVMName.Text; } }
|
||||
public string VmName => m_textBoxVMName.Text;
|
||||
|
||||
public ulong CpuCount { get { return (ulong)m_upDownCpuCount.Value; } }
|
||||
public ulong CpuCount => (ulong)m_upDownCpuCount.Value;
|
||||
|
||||
public ulong Memory { get { return (ulong)m_upDownMemory.Value; } }
|
||||
public ulong Memory => (ulong)m_upDownMemory.Value;
|
||||
|
||||
public ulong AdditionalSpace => m_groupBoxAddSpace.Visible && m_groupBoxAddSpace.Enabled ? (ulong)m_upDownAddSpace.Value * GB : 0;
|
||||
|
||||
public ulong AdditionalSpace { get { return m_groupBoxAddSpace.Enabled ? (ulong)m_upDownAddSpace.Value * GB : 0; } }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
@ -141,7 +141,7 @@ namespace XenAdmin.Wizards.ImportWizard
|
||||
|
||||
#region Accessors
|
||||
|
||||
public EnvelopeType SelectedOvfEnvelope { internal get; set; }
|
||||
public EnvelopeType SelectedOvfEnvelope { private get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -137,7 +137,7 @@ namespace XenAdmin.Wizards.ImportWizard
|
||||
/// <summary>
|
||||
/// Package containing the selected OVF appliance.
|
||||
/// </summary>
|
||||
public Package SelectedOvfPackage { internal get; set; }
|
||||
public Package SelectedOvfPackage { private get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -80,7 +80,7 @@ namespace XenAdmin.Wizards.ImportWizard
|
||||
|
||||
public EnvelopeType SelectedOvfEnvelope
|
||||
{
|
||||
internal get
|
||||
private get
|
||||
{
|
||||
return _selectedOvfEnvelope;
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ namespace XenAdmin.Wizards.ImportWizard
|
||||
return false;
|
||||
}
|
||||
|
||||
public EnvelopeType SelectedOvfEnvelope { get; set; }
|
||||
public EnvelopeType SelectedOvfEnvelope { private get; set; }
|
||||
|
||||
protected override string IntroductionText => Messages.IMPORT_WIZARD_NETWORKING_INTRO;
|
||||
|
||||
|
@ -56,7 +56,7 @@ namespace XenAdmin.Wizards.ImportWizard
|
||||
return true;
|
||||
}
|
||||
|
||||
public EnvelopeType SelectedOvfEnvelope { get; set; }
|
||||
public EnvelopeType SelectedOvfEnvelope { private get; set; }
|
||||
|
||||
public override StorageResourceContainer ResourceData(string sysId)
|
||||
{
|
||||
|
@ -32,18 +32,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using XenAdmin.Actions;
|
||||
using XenAdmin.Actions.OvfActions;
|
||||
using XenAdmin.Actions.VMActions;
|
||||
using XenAdmin.Commands;
|
||||
using XenAdmin.Controls;
|
||||
using XenAdmin.Core;
|
||||
using XenAdmin.Mappings;
|
||||
using XenAdmin.Network;
|
||||
using XenAdmin.Wizards.GenericPages;
|
||||
using XenAPI;
|
||||
using System.Linq;
|
||||
using XenAdmin.Actions.VMActions;
|
||||
using XenAdmin.Commands;
|
||||
using XenOvf;
|
||||
using XenOvf.Definitions;
|
||||
using XenOvf.Utilities;
|
||||
@ -78,7 +78,10 @@ namespace XenAdmin.Wizards.ImportWizard
|
||||
private ImportType? m_typeOfImport;
|
||||
private bool m_ignoreAffinitySet;
|
||||
private EnvelopeType m_envelopeFromVhd;
|
||||
private IXenConnection TargetConnection { get; set; }
|
||||
private Package _selectedOvfPackage;
|
||||
private string _selectedImagePath;
|
||||
private Host _selectedAffinity;
|
||||
private IXenConnection _targetConnection;
|
||||
#endregion
|
||||
|
||||
public ImportWizard(IXenConnection con, IXenObject xenObject, string filename, bool ovfModeOnly = false)
|
||||
@ -128,7 +131,7 @@ namespace XenAdmin.Wizards.ImportWizard
|
||||
m_pageXvaStorage.ImportXvaAction.EndWizard(m_pageFinish.StartVmsAutomatically, m_pageXvaNetwork.VIFs);
|
||||
break;
|
||||
case ImportType.Ovf:
|
||||
new ImportApplianceAction(TargetConnection,
|
||||
new ImportApplianceAction(_targetConnection,
|
||||
m_pageImportSource.SelectedOvfPackage,
|
||||
m_vmMappings,
|
||||
m_pageSecurity.VerifyManifest,
|
||||
@ -139,7 +142,7 @@ namespace XenAdmin.Wizards.ImportWizard
|
||||
m_pageFinish.StartVmsAutomatically).RunAsync();
|
||||
break;
|
||||
case ImportType.Vhd:
|
||||
new ImportImageAction(TargetConnection,
|
||||
new ImportImageAction(_targetConnection,
|
||||
m_envelopeFromVhd,
|
||||
Path.GetDirectoryName(m_pageImportSource.FilePath),
|
||||
m_vmMappings,
|
||||
@ -171,17 +174,15 @@ namespace XenAdmin.Wizards.ImportWizard
|
||||
protected override void UpdateWizardContent(XenTabPage page)
|
||||
{
|
||||
var type = page.GetType();
|
||||
var oldTypeOfImport = m_typeOfImport; //store previous type
|
||||
|
||||
if (type == typeof(ImportSourcePage))
|
||||
{
|
||||
#region ImportSourcePage
|
||||
|
||||
var oldTypeOfImport = m_typeOfImport; //store previous type
|
||||
m_typeOfImport = m_pageImportSource.TypeOfImport;
|
||||
|
||||
var appliancePages = new XenTabPage[] { m_pageEula, m_pageHost, m_pageStorage, m_pageNetwork, m_pageSecurity, m_pageOptions };
|
||||
var imagePages = new XenTabPage[] { m_pageVMconfig, m_pageHost, m_pageStorage, m_pageNetwork, m_pageOptions };
|
||||
var xvaPages = new XenTabPage[] { m_pageXvaHost, m_pageXvaStorage, m_pageXvaNetwork };
|
||||
var newVmMappings = m_vmMappings;
|
||||
|
||||
switch (m_typeOfImport)
|
||||
{
|
||||
@ -195,29 +196,27 @@ namespace XenAdmin.Wizards.ImportWizard
|
||||
RemovePages(xvaPages);
|
||||
AddAfterPage(m_pageImportSource, appliancePages);
|
||||
}
|
||||
var newSelectedOvfPackage = m_pageImportSource.SelectedOvfPackage;
|
||||
var newSelectedOvfEnvelope = newSelectedOvfPackage.OvfEnvelope;
|
||||
|
||||
if (oldTypeOfImport != ImportType.Ovf
|
||||
|| m_pageSecurity.SelectedOvfPackage != newSelectedOvfPackage
|
||||
|| m_pageEula.SelectedOvfEnvelope != newSelectedOvfEnvelope
|
||||
|| m_pageHost.SelectedOvfEnvelope != newSelectedOvfEnvelope
|
||||
|| m_pageHost.VmMappings != newVmMappings
|
||||
|| m_pageStorage.SelectedOvfEnvelope != newSelectedOvfEnvelope
|
||||
|| lunPerVdiMappingPage.SelectedOvfEnvelope != newSelectedOvfEnvelope
|
||||
|| m_pageHost.SelectedOvfEnvelope != newSelectedOvfEnvelope)
|
||||
var oldSelectedOvfPackage = _selectedOvfPackage;
|
||||
_selectedOvfPackage = m_pageImportSource.SelectedOvfPackage;
|
||||
|
||||
if (oldTypeOfImport != ImportType.Ovf || oldSelectedOvfPackage != _selectedOvfPackage)
|
||||
{
|
||||
m_pageEula.SelectedOvfEnvelope = newSelectedOvfEnvelope;
|
||||
m_pageSecurity.SelectedOvfPackage = newSelectedOvfPackage;
|
||||
|
||||
m_pageEula.SelectedOvfEnvelope = _selectedOvfPackage.OvfEnvelope;
|
||||
m_pageSecurity.SelectedOvfPackage = _selectedOvfPackage;
|
||||
CheckDisabledPages(m_pageEula, m_pageSecurity); //decide whether to disable these progress steps
|
||||
ResetVmMappings(newSelectedOvfEnvelope);
|
||||
m_pageHost.SelectedOvfEnvelope = newSelectedOvfEnvelope;
|
||||
|
||||
m_vmMappings.Clear();
|
||||
string[] sysIds = OVF.FindSystemIds(_selectedOvfPackage.OvfEnvelope);
|
||||
foreach (string sysId in sysIds)
|
||||
m_vmMappings.Add(sysId, new VmMapping {VmNameLabel = FindVMName(_selectedOvfPackage.OvfEnvelope, sysId)});
|
||||
|
||||
m_pageHost.SelectedOvfEnvelope = _selectedOvfPackage.OvfEnvelope;
|
||||
m_pageHost.SetDefaultTarget(m_pageHost.ChosenItem ?? m_selectedObject);
|
||||
m_pageHost.VmMappings = newVmMappings;
|
||||
m_pageStorage.SelectedOvfEnvelope = newSelectedOvfEnvelope;
|
||||
lunPerVdiMappingPage.SelectedOvfEnvelope = newSelectedOvfEnvelope;
|
||||
m_pageNetwork.SelectedOvfEnvelope = newSelectedOvfEnvelope;
|
||||
m_pageHost.VmMappings = m_vmMappings;
|
||||
m_pageStorage.SelectedOvfEnvelope = _selectedOvfPackage.OvfEnvelope;
|
||||
lunPerVdiMappingPage.SelectedOvfEnvelope = _selectedOvfPackage.OvfEnvelope;
|
||||
m_pageNetwork.SelectedOvfEnvelope = _selectedOvfPackage.OvfEnvelope;
|
||||
|
||||
NotifyNextPagesOfChange(m_pageEula, m_pageHost, m_pageStorage, m_pageNetwork, m_pageSecurity, m_pageOptions);
|
||||
}
|
||||
@ -230,19 +229,19 @@ namespace XenAdmin.Wizards.ImportWizard
|
||||
RemovePages(appliancePages);
|
||||
RemovePages(xvaPages);
|
||||
AddAfterPage(m_pageImportSource, imagePages);
|
||||
|
||||
//if _targetConnection=null, i.e. we haven't selected a connection yet, do not add the page
|
||||
if (_targetConnection != null && BootModesControl.ShowBootModeOptions(_targetConnection))
|
||||
AddAfterPage(m_pageNetwork, m_pageBootOptions);
|
||||
}
|
||||
|
||||
var newIsWim = m_pageImportSource.IsWIM;
|
||||
var oldSelectedImagePath = _selectedImagePath;
|
||||
_selectedImagePath = m_pageImportSource.FilePath;
|
||||
|
||||
if (oldTypeOfImport != ImportType.Vhd
|
||||
|| m_pageVMconfig.IsWim != newIsWim
|
||||
|| m_pageHost.VmMappings != newVmMappings
|
||||
|| m_pageHost.SelectedOvfEnvelope != null)
|
||||
if (oldTypeOfImport != ImportType.Vhd || oldSelectedImagePath != _selectedImagePath)
|
||||
{
|
||||
m_pageVMconfig.IsWim = newIsWim;
|
||||
m_pageHost.SetDefaultTarget(m_pageHost.ChosenItem ?? m_selectedObject);
|
||||
m_pageHost.SelectedOvfEnvelope = null;
|
||||
m_pageHost.VmMappings = newVmMappings;
|
||||
m_vmMappings.Clear();
|
||||
m_pageVMconfig.IsWim = m_pageImportSource.IsWIM;
|
||||
NotifyNextPagesOfChange(m_pageVMconfig, m_pageHost, m_pageStorage, m_pageNetwork, m_pageOptions);
|
||||
}
|
||||
break;
|
||||
@ -260,60 +259,107 @@ namespace XenAdmin.Wizards.ImportWizard
|
||||
m_pageXvaStorage.FilePath = m_pageImportSource.FilePath;
|
||||
break;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
else if (type == typeof(ImageVMConfigPage))
|
||||
{
|
||||
//then use it to create an ovf for the import
|
||||
|
||||
var newEnvelope = OVF.CreateOvfEnvelope(m_pageVMconfig.VmName,
|
||||
m_pageVMconfig.CpuCount, m_pageVMconfig.Memory,
|
||||
m_pageBootOptions.BootParams, m_pageBootOptions.PlatformSettings,
|
||||
m_pageImportSource.DiskCapacity, m_pageImportSource.IsWIM, m_pageVMconfig.AdditionalSpace,
|
||||
m_pageImportSource.FilePath, m_pageImportSource.ImageLength, BrandManager.ProductBrand);
|
||||
|
||||
if (newEnvelope != m_envelopeFromVhd)
|
||||
var newMapping = new VmMapping
|
||||
{
|
||||
ResetVmMappings(m_envelopeFromVhd);
|
||||
NotifyNextPagesOfChange(m_pageHost, m_pageStorage, m_pageNetwork);
|
||||
VmNameLabel = m_pageVMconfig.VmName,
|
||||
CpuCount = m_pageVMconfig.CpuCount,
|
||||
Capacity = m_pageImportSource.DiskCapacity + m_pageVMconfig.AdditionalSpace,
|
||||
Memory = m_pageVMconfig.Memory,
|
||||
BootParams = m_pageBootOptions.BootParams,
|
||||
PlatformSettings = m_pageBootOptions.PlatformSettings
|
||||
};
|
||||
|
||||
var oldMapping = m_vmMappings.Values.FirstOrDefault();
|
||||
if (oldMapping != null)
|
||||
{
|
||||
newMapping.XenRef = oldMapping.XenRef;
|
||||
newMapping.TargetName = oldMapping.TargetName;
|
||||
newMapping.Storage = oldMapping.Storage;
|
||||
newMapping.StorageToAttach = oldMapping.StorageToAttach;
|
||||
newMapping.Networks = oldMapping.Networks;
|
||||
}
|
||||
|
||||
m_envelopeFromVhd = newEnvelope;
|
||||
m_pageStorage.SelectedOvfEnvelope = m_envelopeFromVhd;
|
||||
lunPerVdiMappingPage.SelectedOvfEnvelope = m_envelopeFromVhd;
|
||||
m_pageNetwork.SelectedOvfEnvelope = m_envelopeFromVhd;
|
||||
if (!newMapping.Equals(oldMapping))
|
||||
{
|
||||
m_envelopeFromVhd = OVF.CreateOvfEnvelope(newMapping.VmNameLabel,
|
||||
newMapping.CpuCount, newMapping.Memory,
|
||||
newMapping.BootParams, newMapping.PlatformSettings,
|
||||
newMapping.Capacity,
|
||||
m_pageImportSource.FilePath, m_pageImportSource.ImageLength, BrandManager.ProductBrand);
|
||||
|
||||
m_vmMappings.Clear();
|
||||
var sysId = OVF.FindSystemIds(m_envelopeFromVhd).First();
|
||||
m_vmMappings.Add(sysId, newMapping);
|
||||
|
||||
m_pageHost.VmMappings = m_vmMappings;
|
||||
m_pageHost.SetDefaultTarget(m_pageHost.ChosenItem ?? m_selectedObject);
|
||||
|
||||
m_pageHost.SelectedOvfEnvelope = m_envelopeFromVhd;
|
||||
m_pageStorage.SelectedOvfEnvelope = m_envelopeFromVhd;
|
||||
lunPerVdiMappingPage.SelectedOvfEnvelope = m_envelopeFromVhd;
|
||||
m_pageNetwork.SelectedOvfEnvelope = m_envelopeFromVhd;
|
||||
|
||||
NotifyNextPagesOfChange(m_pageHost, lunPerVdiMappingPage, m_pageStorage, m_pageNetwork);
|
||||
}
|
||||
}
|
||||
else if (type == typeof(ImportSelectHostPage))
|
||||
{
|
||||
var newConnection = m_pageHost.ChosenItem?.Connection;
|
||||
var newMappings = m_pageHost.VmMappings;
|
||||
var oldTargetConnection = _targetConnection;
|
||||
_targetConnection = m_pageHost.ChosenItem?.Connection;
|
||||
var oldVmMappings = m_vmMappings;
|
||||
m_vmMappings = m_pageHost.VmMappings;
|
||||
|
||||
RemovePage(m_pageRbac);
|
||||
ConfigureRbacPage(TargetConnection);
|
||||
if (oldTargetConnection != _targetConnection)
|
||||
{
|
||||
RemovePage(m_pageRbac);
|
||||
ConfigureRbacPage(_targetConnection);
|
||||
|
||||
if (m_pageStorage.VmMappings != newMappings
|
||||
|| m_pageNetwork.Connection != newConnection
|
||||
|| m_pageOptions.Connection != newConnection)
|
||||
RemovePage(m_pageBootOptions);
|
||||
if (m_typeOfImport == ImportType.Vhd && BootModesControl.ShowBootModeOptions(_targetConnection))
|
||||
AddAfterPage(m_pageNetwork, m_pageBootOptions);
|
||||
}
|
||||
|
||||
m_pageStorage.VmMappings = m_vmMappings;
|
||||
m_pageStorage.Connection = _targetConnection;
|
||||
m_pageNetwork.Connection = _targetConnection;
|
||||
m_pageOptions.Connection = _targetConnection;
|
||||
m_pageBootOptions.Connection = _targetConnection;
|
||||
|
||||
if (oldTargetConnection != _targetConnection || oldVmMappings != m_vmMappings)
|
||||
NotifyNextPagesOfChange(m_pageStorage, m_pageNetwork, m_pageOptions);
|
||||
}
|
||||
else if (type == typeof(ImportBootOptionPage))
|
||||
{
|
||||
var oldMapping = m_vmMappings.Values.First();
|
||||
|
||||
if (m_pageBootOptions.Connection != newConnection && m_typeOfImport != oldTypeOfImport)
|
||||
if (oldMapping.BootParams != m_pageBootOptions.BootParams ||
|
||||
oldMapping.PlatformSettings != m_pageBootOptions.PlatformSettings)
|
||||
{
|
||||
RemovePage(m_pageBootOptions);
|
||||
if (m_typeOfImport == ImportType.Vhd && BootModesControl.ShowBootModeOptions(TargetConnection))
|
||||
{
|
||||
AddAfterPage(m_pageNetwork, m_pageBootOptions);
|
||||
}
|
||||
string systemId = null;
|
||||
if (m_envelopeFromVhd.Item is VirtualSystem_Type vs)
|
||||
systemId = vs.id;
|
||||
else if (m_envelopeFromVhd.Item is VirtualSystemCollection_Type vsc)
|
||||
systemId = vsc.Content.FirstOrDefault()?.id;
|
||||
|
||||
if (oldMapping.BootParams != m_pageBootOptions.BootParams)
|
||||
{
|
||||
m_envelopeFromVhd = OVF.UpdateBootParams(m_envelopeFromVhd, systemId, m_pageBootOptions.BootParams);
|
||||
m_vmMappings.Values.First().BootParams = m_pageBootOptions.BootParams;
|
||||
}
|
||||
|
||||
if (oldMapping.PlatformSettings != m_pageBootOptions.PlatformSettings)
|
||||
{
|
||||
m_envelopeFromVhd = OVF.UpdatePlatform(m_envelopeFromVhd, systemId, m_pageBootOptions.PlatformSettings);
|
||||
m_vmMappings.Values.First().PlatformSettings = m_pageBootOptions.PlatformSettings;
|
||||
}
|
||||
}
|
||||
|
||||
m_vmMappings = newMappings;
|
||||
TargetConnection = newConnection;
|
||||
|
||||
m_pageStorage.VmMappings = m_vmMappings;
|
||||
m_pageStorage.Connection = TargetConnection;
|
||||
m_pageNetwork.Connection = TargetConnection;
|
||||
m_pageOptions.Connection = TargetConnection;
|
||||
m_pageBootOptions.Connection = TargetConnection;
|
||||
m_pageStorage.SelectedOvfEnvelope = m_envelopeFromVhd;
|
||||
lunPerVdiMappingPage.SelectedOvfEnvelope = m_envelopeFromVhd;
|
||||
m_pageNetwork.SelectedOvfEnvelope = m_envelopeFromVhd;
|
||||
}
|
||||
else if (type == typeof(ImportSelectStoragePage))
|
||||
{
|
||||
@ -339,31 +385,31 @@ namespace XenAdmin.Wizards.ImportWizard
|
||||
}
|
||||
else if (type == typeof(GlobalSelectHost))
|
||||
{
|
||||
var newConnection = m_pageXvaHost.SelectedHost == null ? m_pageXvaHost.SelectedConnection : m_pageXvaHost.SelectedHost.Connection;
|
||||
var newStorageTargetHost = m_ignoreAffinitySet ? null : m_pageXvaHost.SelectedHost;
|
||||
var newNetworkSelectedHost = m_pageXvaHost.SelectedHost;
|
||||
var oldSelectedAffinity = _selectedAffinity;
|
||||
_selectedAffinity = m_pageXvaHost.SelectedHost;
|
||||
var oldTargetConnection = _targetConnection;
|
||||
_targetConnection = _selectedAffinity == null ? m_pageXvaHost.SelectedConnection : _selectedAffinity.Connection;
|
||||
|
||||
RemovePage(m_pageRbac);
|
||||
ConfigureRbacPage(newConnection);
|
||||
if (oldTargetConnection != _targetConnection)
|
||||
{
|
||||
RemovePage(m_pageRbac);
|
||||
ConfigureRbacPage(_targetConnection);
|
||||
}
|
||||
|
||||
if (m_pageXvaStorage.MTargetConnection != newConnection
|
||||
|| m_pageXvaNetwork.MSelectedConnection != newConnection
|
||||
|| !m_pageXvaNetwork.MSelectedAffinity.Equals(newNetworkSelectedHost)
|
||||
|| !m_pageXvaStorage.MTargetHost.Equals(newStorageTargetHost)
|
||||
)
|
||||
m_pageXvaStorage.TargetConnection = _targetConnection;
|
||||
m_pageXvaStorage.TargetHost = m_ignoreAffinitySet ? null : _selectedAffinity;
|
||||
|
||||
m_pageXvaNetwork.SelectedConnection = _targetConnection;
|
||||
m_pageXvaNetwork.SelectedAffinity = _selectedAffinity;
|
||||
|
||||
if (oldTargetConnection != _targetConnection ||
|
||||
oldSelectedAffinity != null && _selectedAffinity != null && oldSelectedAffinity.opaque_ref != _selectedAffinity.opaque_ref)
|
||||
NotifyNextPagesOfChange(m_pageXvaStorage, m_pageXvaNetwork);
|
||||
|
||||
m_pageXvaStorage.MTargetConnection = newConnection;
|
||||
m_pageXvaStorage.MTargetHost = newStorageTargetHost;
|
||||
|
||||
m_pageXvaNetwork.MSelectedConnection = newConnection;
|
||||
m_pageXvaNetwork.MSelectedAffinity = m_pageXvaHost.SelectedHost;
|
||||
|
||||
}
|
||||
else if (type == typeof(StoragePickerPage))
|
||||
{
|
||||
m_pageFinish.ShowStartVmsGroupBox = m_pageXvaStorage.ImportedVm != null && !m_pageXvaStorage.ImportedVm.is_a_template;
|
||||
m_pageXvaNetwork.SetVm(m_pageXvaStorage.ImportedVm);
|
||||
m_pageXvaNetwork.VM = m_pageXvaStorage.ImportedVm;
|
||||
NotifyNextPagesOfChange(m_pageXvaNetwork);
|
||||
}
|
||||
|
||||
@ -567,7 +613,7 @@ namespace XenAdmin.Wizards.ImportWizard
|
||||
temp.Add(new Tuple(Messages.FINISH_PAGE_VMNAME, m_pageVMconfig.VmName));
|
||||
temp.Add(new Tuple(Messages.FINISH_PAGE_CPUCOUNT, m_pageVMconfig.CpuCount.ToString()));
|
||||
temp.Add(new Tuple(Messages.FINISH_PAGE_MEMORY, string.Format(Messages.VAL_MB, m_pageVMconfig.Memory)));
|
||||
if (Helpers.NaplesOrGreater(TargetConnection))
|
||||
if (Helpers.NaplesOrGreater(_targetConnection))
|
||||
temp.Add(new Tuple(Messages.BOOT_MODE, m_pageBootOptions.SelectedBootMode.StringOf()));
|
||||
|
||||
if (m_pageImportSource.IsWIM)
|
||||
@ -609,23 +655,6 @@ namespace XenAdmin.Wizards.ImportWizard
|
||||
return temp;
|
||||
}
|
||||
|
||||
private void ResetVmMappings(EnvelopeType ovfEnvelope)
|
||||
{
|
||||
string[] sysIds = OVF.FindSystemIds(ovfEnvelope);
|
||||
m_vmMappings.Clear();
|
||||
|
||||
foreach (string sysId in sysIds)
|
||||
{
|
||||
var vmMap = new VmMapping
|
||||
{
|
||||
VmNameLabel = (m_typeOfImport == ImportType.Ovf)
|
||||
? FindVMName(ovfEnvelope, sysId)
|
||||
: m_pageVMconfig.VmName //it should only iterate once
|
||||
};
|
||||
m_vmMappings.Add(sysId, vmMap);
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsGUID(string expression)
|
||||
{
|
||||
if (expression != null)
|
||||
@ -709,15 +738,15 @@ namespace XenAdmin.Wizards.ImportWizard
|
||||
private void m_pageXvaStorage_ImportVmCompleted()
|
||||
{
|
||||
Program.Invoke(this, () =>
|
||||
{
|
||||
if (CurrentStepTabPage.GetType() == typeof(StoragePickerPage))
|
||||
{
|
||||
m_pageFinish.ShowStartVmsGroupBox = m_pageXvaStorage.ImportedVm != null && !m_pageXvaStorage.ImportedVm.is_a_template;
|
||||
m_pageXvaNetwork.SetVm(m_pageXvaStorage.ImportedVm);
|
||||
NotifyNextPagesOfChange(m_pageXvaNetwork);
|
||||
NextStep();
|
||||
}
|
||||
});
|
||||
{
|
||||
if (CurrentStepTabPage.GetType() == typeof(StoragePickerPage))
|
||||
{
|
||||
m_pageFinish.ShowStartVmsGroupBox = m_pageXvaStorage.ImportedVm != null && !m_pageXvaStorage.ImportedVm.is_a_template;
|
||||
m_pageXvaNetwork.VM = m_pageXvaStorage.ImportedVm;
|
||||
NotifyNextPagesOfChange(m_pageXvaNetwork);
|
||||
NextStep();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void ShowXenAppXenDesktopWarning(IXenConnection connection)
|
||||
|
@ -99,7 +99,7 @@ namespace XenAdmin.Wizards.ImportWizard
|
||||
}
|
||||
}
|
||||
|
||||
public EnvelopeType SelectedOvfEnvelope { get; set; }
|
||||
public EnvelopeType SelectedOvfEnvelope { private get; set; }
|
||||
|
||||
private StorageResourceContainer ResourceData(string sysId)
|
||||
{
|
||||
|
@ -49,9 +49,6 @@ namespace XenAdmin.Wizards.ImportWizard
|
||||
#region Private fields
|
||||
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
internal IXenConnection MSelectedConnection { get; set; }
|
||||
internal Host MSelectedAffinity { get; set; }
|
||||
private VM m_vm;
|
||||
private bool m_buttonNextEnabled;
|
||||
#endregion
|
||||
|
||||
@ -108,6 +105,15 @@ namespace XenAdmin.Wizards.ImportWizard
|
||||
|
||||
#region Accessors
|
||||
|
||||
/// <summary>
|
||||
/// Should be set before the Affinity is set.
|
||||
/// </summary>
|
||||
internal IXenConnection SelectedConnection { get; set; }
|
||||
|
||||
internal Host SelectedAffinity { get; set; }
|
||||
|
||||
internal VM VM { get; set; }
|
||||
|
||||
public List<VIF> VIFs
|
||||
{
|
||||
get
|
||||
@ -136,12 +142,6 @@ namespace XenAdmin.Wizards.ImportWizard
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
public void SetVm(VM vm)
|
||||
{
|
||||
m_vm = vm;
|
||||
}
|
||||
|
||||
#region Private methods
|
||||
|
||||
private void UpdateControlsEnabledState(bool enabled)
|
||||
@ -155,7 +155,7 @@ namespace XenAdmin.Wizards.ImportWizard
|
||||
{
|
||||
NetworkNetworkColumn.Items.Clear();
|
||||
|
||||
var networks = MSelectedConnection.Cache.Networks.Where(ShowNetwork);
|
||||
var networks = SelectedConnection.Cache.Networks.Where(ShowNetwork);
|
||||
|
||||
foreach (XenAPI.Network network in networks)
|
||||
{
|
||||
@ -174,18 +174,18 @@ namespace XenAdmin.Wizards.ImportWizard
|
||||
m_networkGridView.SuspendLayout();
|
||||
m_networkGridView.Rows.Clear();
|
||||
|
||||
if (m_vm.is_a_template && m_vm.VIFs.Count < 1)
|
||||
if (VM.is_a_template && VM.VIFs.Count < 1)
|
||||
{
|
||||
// We need to automatically generate VIFs for Networks marked AutoPlug=true
|
||||
|
||||
var networks = MSelectedConnection.Cache.Networks;
|
||||
var networks = SelectedConnection.Cache.Networks;
|
||||
foreach (XenAPI.Network network in networks)
|
||||
{
|
||||
if (m_networkGridView.Rows.Count < m_vm.MaxVIFsAllowed() && ShowNetwork(network) && network.GetAutoPlug())
|
||||
if (m_networkGridView.Rows.Count < VM.MaxVIFsAllowed() && ShowNetwork(network) && network.GetAutoPlug())
|
||||
{
|
||||
AddVIFRow(new VIF
|
||||
{
|
||||
Connection = MSelectedConnection,
|
||||
Connection = SelectedConnection,
|
||||
device = m_networkGridView.Rows.Count.ToString(),
|
||||
network = new XenRef<XenAPI.Network>(network.opaque_ref),
|
||||
MAC = Messages.MAC_AUTOGENERATE
|
||||
@ -193,16 +193,16 @@ namespace XenAdmin.Wizards.ImportWizard
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (m_vm.is_a_template)
|
||||
else if (VM.is_a_template)
|
||||
{
|
||||
// We need to create off the _vmTemplate
|
||||
|
||||
var vifs = MSelectedConnection.ResolveAll(m_vm.VIFs);
|
||||
var vifs = SelectedConnection.ResolveAll(VM.VIFs);
|
||||
foreach (VIF vif in vifs)
|
||||
{
|
||||
AddVIFRow(new VIF
|
||||
{
|
||||
Connection = MSelectedConnection,
|
||||
Connection = SelectedConnection,
|
||||
device = vif.device,
|
||||
network = vif.network,
|
||||
MAC = Messages.MAC_AUTOGENERATE
|
||||
@ -212,7 +212,7 @@ namespace XenAdmin.Wizards.ImportWizard
|
||||
else
|
||||
{
|
||||
//We need to recreate off vm
|
||||
var vifs = MSelectedConnection.ResolveAll(m_vm.VIFs);
|
||||
var vifs = SelectedConnection.ResolveAll(VM.VIFs);
|
||||
foreach (VIF vif in vifs)
|
||||
AddVIFRow(vif);
|
||||
}
|
||||
@ -228,7 +228,7 @@ namespace XenAdmin.Wizards.ImportWizard
|
||||
|
||||
private XenAPI.Network GetDefaultNetwork()
|
||||
{
|
||||
foreach (XenAPI.Network network in MSelectedConnection.Cache.Networks)
|
||||
foreach (XenAPI.Network network in SelectedConnection.Cache.Networks)
|
||||
if (ShowNetwork(network))
|
||||
return network;
|
||||
|
||||
@ -249,13 +249,13 @@ namespace XenAdmin.Wizards.ImportWizard
|
||||
if (network.IsMember())
|
||||
return false;
|
||||
|
||||
if (MSelectedAffinity != null && !MSelectedAffinity.CanSeeNetwork(network))
|
||||
if (SelectedAffinity != null && !SelectedAffinity.CanSeeNetwork(network))
|
||||
return false;
|
||||
|
||||
if (MSelectedAffinity == null && !network.AllHostsCanSeeNetwork())
|
||||
if (SelectedAffinity == null && !network.AllHostsCanSeeNetwork())
|
||||
return false;
|
||||
|
||||
if (network.IsSriov() && !m_vm.HasSriovRecommendation())
|
||||
if (network.IsSriov() && !VM.HasSriovRecommendation())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
@ -264,7 +264,7 @@ namespace XenAdmin.Wizards.ImportWizard
|
||||
private void AddVIFRow(VIF vif)
|
||||
{
|
||||
var row = new VifRow(vif);
|
||||
XenAPI.Network network = MSelectedConnection.Resolve(vif.network);
|
||||
XenAPI.Network network = SelectedConnection.Resolve(vif.network);
|
||||
bool isGuestInstallerNetwork = network != null && network.IsGuestInstallerNetwork();
|
||||
|
||||
ToStringWrapper<XenAPI.Network> comboBoxEntry = FindComboBoxEntryForNetwork(network);
|
||||
@ -332,7 +332,7 @@ namespace XenAdmin.Wizards.ImportWizard
|
||||
|
||||
private void m_buttonAddNetwork_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (m_networkGridView.Rows.Count >= m_vm.MaxVIFsAllowed())
|
||||
if (m_networkGridView.Rows.Count >= VM.MaxVIFsAllowed())
|
||||
{
|
||||
using (var dlg = new ErrorDialog(FriendlyErrorNames.VIFS_MAX_ALLOWED)
|
||||
{WindowTitle = FriendlyErrorNames.VIFS_MAX_ALLOWED_TITLE})
|
||||
@ -342,7 +342,7 @@ namespace XenAdmin.Wizards.ImportWizard
|
||||
return;
|
||||
}
|
||||
|
||||
VIF vif = new VIF {Connection = MSelectedConnection};
|
||||
VIF vif = new VIF {Connection = SelectedConnection};
|
||||
|
||||
int i = 0;
|
||||
while (true)
|
||||
|
@ -45,9 +45,6 @@ namespace XenAdmin.Wizards.ImportWizard
|
||||
public partial class StoragePickerPage : XenTabPage
|
||||
{
|
||||
#region Private fields
|
||||
|
||||
internal Host MTargetHost { set; get; }
|
||||
internal IXenConnection MTargetConnection { get; set; }
|
||||
private volatile Task m_importTask;
|
||||
private bool m_alreadyFoundVM;
|
||||
private ActionProgressDialog m_actionDialog;
|
||||
@ -99,8 +96,8 @@ namespace XenAdmin.Wizards.ImportWizard
|
||||
SetButtonNextEnabled(false);
|
||||
m_buttonPreviousEnabled = false;
|
||||
OnPageUpdated();
|
||||
ImportXvaAction = new ImportVmAction(MTargetHost == null ? MTargetConnection : MTargetHost.Connection,
|
||||
MTargetHost, FilePath, SR,
|
||||
ImportXvaAction = new ImportVmAction(TargetHost == null ? TargetConnection : TargetHost.Connection,
|
||||
TargetHost, FilePath, SR,
|
||||
VMOperationCommand.WarningDialogHAInvalidConfig, VMOperationCommand.StartDiagnosisForm);
|
||||
ImportXvaAction.Completed += m_importXvaAction_Completed;
|
||||
|
||||
@ -120,7 +117,7 @@ namespace XenAdmin.Wizards.ImportWizard
|
||||
public override void PopulatePage()
|
||||
{
|
||||
SetButtonNextEnabled(false);
|
||||
m_srPicker.PopulateAsync(SrPicker.SRPickerType.VM, MTargetConnection, MTargetHost, null, null);
|
||||
m_srPicker.PopulateAsync(SrPicker.SRPickerType.VM, TargetConnection, TargetHost, null, null);
|
||||
IsDirty = true;
|
||||
}
|
||||
|
||||
@ -138,6 +135,10 @@ namespace XenAdmin.Wizards.ImportWizard
|
||||
|
||||
#region Accessors
|
||||
|
||||
internal IXenConnection TargetConnection { get; set; }
|
||||
|
||||
internal Host TargetHost { get; set; }
|
||||
|
||||
public ImportVmAction ImportXvaAction { get; private set; }
|
||||
|
||||
public string FilePath { private get; set; }
|
||||
@ -184,12 +185,12 @@ namespace XenAdmin.Wizards.ImportWizard
|
||||
while (ImportXvaAction.RelatedTask == null)
|
||||
Thread.Sleep(100);
|
||||
|
||||
while ((m_importTask = MTargetConnection.Resolve(ImportXvaAction.RelatedTask)) == null)
|
||||
while ((m_importTask = TargetConnection.Resolve(ImportXvaAction.RelatedTask)) == null)
|
||||
Thread.Sleep(100);
|
||||
|
||||
// We register a XenObjectsUpdated event handler where we check that the import task has the object creation phase marked as "complete";
|
||||
// Once the object creation is complete, we look for the vm; When we found the vm we unregister this event handler;
|
||||
MTargetConnection.XenObjectsUpdated += targetConnection_XenObjectsUpdated;
|
||||
TargetConnection.XenObjectsUpdated += targetConnection_XenObjectsUpdated;
|
||||
|
||||
Program.Invoke(this, CheckTask);
|
||||
}
|
||||
@ -221,11 +222,11 @@ namespace XenAdmin.Wizards.ImportWizard
|
||||
{
|
||||
// Should never get here (as we unregister XenObjectsUpdated event handler after we find the vm) but just in case,
|
||||
// unregister XenObjectsUpdated event handler
|
||||
MTargetConnection.XenObjectsUpdated -= targetConnection_XenObjectsUpdated;
|
||||
TargetConnection.XenObjectsUpdated -= targetConnection_XenObjectsUpdated;
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (VM vm in MTargetConnection.Cache.VMs)
|
||||
foreach (VM vm in TargetConnection.Cache.VMs)
|
||||
{
|
||||
if (!vm.other_config.ContainsKey(ImportVmAction.IMPORT_TASK))
|
||||
continue;
|
||||
@ -238,7 +239,7 @@ namespace XenAdmin.Wizards.ImportWizard
|
||||
ImportedVm = vm;
|
||||
|
||||
// We found the VM, unregister XenObjectsUpdated event handler
|
||||
MTargetConnection.XenObjectsUpdated -= targetConnection_XenObjectsUpdated;
|
||||
TargetConnection.XenObjectsUpdated -= targetConnection_XenObjectsUpdated;
|
||||
|
||||
// And close the dialog, flick to next page.
|
||||
m_actionDialog.Close();
|
||||
@ -267,7 +268,7 @@ namespace XenAdmin.Wizards.ImportWizard
|
||||
if (!(ImportXvaAction.Succeeded) || ImportXvaAction.Cancelled)
|
||||
{
|
||||
// task failed or has been cancelled, unregister XenObjectsUpdated event handler
|
||||
MTargetConnection.XenObjectsUpdated -= targetConnection_XenObjectsUpdated;
|
||||
TargetConnection.XenObjectsUpdated -= targetConnection_XenObjectsUpdated;
|
||||
|
||||
// Give the user a chance to correct any errors
|
||||
m_actionDialog = null;
|
||||
|
@ -44,6 +44,11 @@ namespace XenAdmin.Mappings
|
||||
}
|
||||
|
||||
public string VmNameLabel { get; set; }
|
||||
public ulong Capacity { get; set; }
|
||||
public ulong CpuCount { get; set; }
|
||||
public ulong Memory { get; set; }
|
||||
public string BootParams { get; set; }
|
||||
public string PlatformSettings { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// OpaqueRef of the target pool or host
|
||||
@ -66,5 +71,26 @@ namespace XenAdmin.Mappings
|
||||
/// Keyed on the id in the ovf file
|
||||
/// </summary>
|
||||
public Dictionary<string, XenAPI.Network> Networks { get; set; }
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return obj is VmMapping other &&
|
||||
VmNameLabel == other.VmNameLabel &&
|
||||
Capacity == other.Capacity &&
|
||||
CpuCount == other.CpuCount &&
|
||||
Memory == other.Memory &&
|
||||
BootParams == other.BootParams &&
|
||||
PlatformSettings == other.PlatformSettings &&
|
||||
XenRef == other.XenRef &&
|
||||
TargetName == other.TargetName &&
|
||||
Storage == other.Storage &&
|
||||
StorageToAttach == other.StorageToAttach &&
|
||||
Networks == other.Networks;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.GetHashCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1388,7 +1388,7 @@ namespace XenOvf
|
||||
#region CREATEs
|
||||
|
||||
public static EnvelopeType CreateOvfEnvelope(string vmName, ulong cpuCount, ulong memory,
|
||||
string bootParams, string platformSettings, ulong diskCapacity, bool isWim, ulong additionalSpace,
|
||||
string bootParams, string platformSettings, ulong capacity,
|
||||
string diskPath, ulong imageLength, string productBrand)
|
||||
{
|
||||
EnvelopeType env = CreateEnvelope(vmName);
|
||||
@ -1415,10 +1415,6 @@ namespace XenOvf
|
||||
AddNetwork(env, systemID, netId, string.Format(Messages.NETWORK_NAME, 0), Messages.OVF_NET_DESCRIPTION, null);
|
||||
|
||||
string diskId = Guid.NewGuid().ToString();
|
||||
ulong capacity = diskCapacity;
|
||||
|
||||
if (isWim)
|
||||
capacity += additionalSpace;
|
||||
|
||||
AddDisk(env, systemID, diskId, diskPath, true, Messages.OVF_DISK_CAPTION, Messages.OVF_CREATED, imageLength, capacity);
|
||||
|
||||
@ -1426,6 +1422,45 @@ namespace XenOvf
|
||||
return env;
|
||||
}
|
||||
|
||||
public static EnvelopeType UpdateBootParams(EnvelopeType env, string systemID, string bootParams)
|
||||
{
|
||||
return UpdateOtherSystemSettingsData(env, systemID, "HVM_boot_params", "order=dc;" + bootParams);
|
||||
}
|
||||
|
||||
public static EnvelopeType UpdatePlatform(EnvelopeType env, string systemID, string platformSettings)
|
||||
{
|
||||
return UpdateOtherSystemSettingsData(env, systemID, "platform", "nx=true;acpi=true;apic=true;pae=true;stdvga=0;" + platformSettings);
|
||||
}
|
||||
|
||||
private static EnvelopeType UpdateOtherSystemSettingsData(EnvelopeType env, string systemID, string setting, string value)
|
||||
{
|
||||
VirtualHardwareSection_Type[] vhsArray = FindVirtualHardwareSection(env, systemID);
|
||||
VirtualHardwareSection_Type foundVhs = null;
|
||||
|
||||
foreach (VirtualHardwareSection_Type vhs in vhsArray)
|
||||
{
|
||||
if (vhs.System?.VirtualSystemType == null)
|
||||
continue;
|
||||
|
||||
var vst = vhs.System.VirtualSystemType.Value;
|
||||
if (string.IsNullOrEmpty(vst) || !vst.ToLower().StartsWith("xen") && !vst.ToLower().StartsWith("hvm"))
|
||||
continue;
|
||||
|
||||
foundVhs = vhs;
|
||||
break;
|
||||
}
|
||||
|
||||
if (foundVhs == null)
|
||||
return env;
|
||||
|
||||
var config = foundVhs.VirtualSystemOtherConfigurationData.FirstOrDefault(d => d.Name == setting);
|
||||
if (config == null)
|
||||
return env;
|
||||
|
||||
config.Value = new cimString(value);
|
||||
return env;
|
||||
}
|
||||
|
||||
public EnvelopeType Create(DiskInfo[] vhdExports, string pathToOvf, string ovfName)
|
||||
{
|
||||
return Create(vhdExports, pathToOvf, ovfName, LANGUAGE);
|
||||
|
Loading…
Reference in New Issue
Block a user