mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2024-11-23 12:30:50 +01:00
Use consistent variable names.
Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
This commit is contained in:
parent
a35efa06aa
commit
038de3ca62
@ -339,21 +339,21 @@ namespace XenAdmin.Wizards.ImportWizard
|
||||
if (oldMapping.BootParams != m_pageBootOptions.BootParams ||
|
||||
oldMapping.PlatformSettings != m_pageBootOptions.PlatformSettings)
|
||||
{
|
||||
string systemId = null;
|
||||
string sysId = null;
|
||||
if (m_envelopeFromVhd.Item is VirtualSystem_Type vs)
|
||||
systemId = vs.id;
|
||||
sysId = vs.id;
|
||||
else if (m_envelopeFromVhd.Item is VirtualSystemCollection_Type vsc)
|
||||
systemId = vsc.Content.FirstOrDefault()?.id;
|
||||
sysId = vsc.Content.FirstOrDefault()?.id;
|
||||
|
||||
if (oldMapping.BootParams != m_pageBootOptions.BootParams)
|
||||
{
|
||||
m_envelopeFromVhd = OVF.UpdateBootParams(m_envelopeFromVhd, systemId, m_pageBootOptions.BootParams);
|
||||
m_envelopeFromVhd = OVF.UpdateBootParams(m_envelopeFromVhd, sysId, 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_envelopeFromVhd = OVF.UpdatePlatform(m_envelopeFromVhd, sysId, m_pageBootOptions.PlatformSettings);
|
||||
m_vmMappings.Values.First().PlatformSettings = m_pageBootOptions.PlatformSettings;
|
||||
}
|
||||
}
|
||||
@ -668,9 +668,9 @@ namespace XenAdmin.Wizards.ImportWizard
|
||||
|
||||
// Find a name to use of a VM within an envelope that could have come from any hypervisor.
|
||||
// TODO: Consider refactoring this method because it is very similar to OVF.FindSystemName().
|
||||
private string FindVMName(EnvelopeType ovfEnv, string systemid)
|
||||
private string FindVMName(EnvelopeType ovfEnv, string sysId)
|
||||
{
|
||||
VirtualSystem_Type vSystem = OVF.FindVirtualSystemById(ovfEnv, systemid);
|
||||
VirtualSystem_Type vSystem = OVF.FindVirtualSystemById(ovfEnv, sysId);
|
||||
|
||||
// Use the given name if present and valid.
|
||||
// The given name is Envelope.VirtualSystem.Name specified in the OVF Specification 1.1 clause 7.2.
|
||||
@ -688,7 +688,7 @@ namespace XenAdmin.Wizards.ImportWizard
|
||||
choices.Add(vSystem.id);
|
||||
|
||||
// VirtualHardwareSection_Type.VirtualSystemIdentifier is next preference because Virtual Box will also set this property to the VM name.
|
||||
VirtualHardwareSection_Type[] vhsList = OVF.FindVirtualHardwareSection(ovfEnv, systemid);
|
||||
VirtualHardwareSection_Type[] vhsList = OVF.FindVirtualHardwareSection(ovfEnv, sysId);
|
||||
|
||||
foreach (VirtualHardwareSection_Type vhs in vhsList)
|
||||
{
|
||||
|
@ -125,26 +125,26 @@ namespace XenAdmin.Actions.OvfActions
|
||||
{
|
||||
CheckForCancellation();
|
||||
|
||||
string systemid = vmMapping.Key;
|
||||
string sysId = vmMapping.Key;
|
||||
var mapping = vmMapping.Value;
|
||||
EnvelopeType[] envs = OVF.Split(m_package.OvfEnvelope, "system", new object[] {new[] {systemid}});
|
||||
EnvelopeType[] envs = OVF.Split(m_package.OvfEnvelope, "system", new object[] {new[] {sysId}});
|
||||
|
||||
//storage
|
||||
foreach (var kvp in mapping.Storage)
|
||||
OVF.SetTargetSRInRASD(envs[0], systemid, kvp.Key, kvp.Value.uuid);
|
||||
OVF.SetTargetSRInRASD(envs[0], sysId, kvp.Key, kvp.Value.uuid);
|
||||
|
||||
foreach (var kvp in mapping.StorageToAttach)
|
||||
OVF.SetTargetVDIInRASD(envs[0], systemid, kvp.Key, kvp.Value.uuid);
|
||||
OVF.SetTargetVDIInRASD(envs[0], sysId, kvp.Key, kvp.Value.uuid);
|
||||
|
||||
//network
|
||||
foreach (var kvp in mapping.Networks)
|
||||
OVF.SetTargetNetworkInRASD(envs[0], systemid, kvp.Key, kvp.Value.uuid);
|
||||
OVF.SetTargetNetworkInRASD(envs[0], sysId, kvp.Key, kvp.Value.uuid);
|
||||
|
||||
if (m_runfixups)
|
||||
{
|
||||
string cdId = OVF.SetRunOnceBootCDROMOSFixup(envs[0], systemid,
|
||||
string cdId = OVF.SetRunOnceBootCDROMOSFixup(envs[0], sysId,
|
||||
Path.GetDirectoryName(m_package.PackageSourceFile), BrandManager.ProductBrand);
|
||||
OVF.SetTargetISOSRInRASD(envs[0], systemid, cdId, m_selectedIsoSr.uuid);
|
||||
OVF.SetTargetISOSRInRASD(envs[0], sysId, cdId, m_selectedIsoSr.uuid);
|
||||
}
|
||||
|
||||
envelopes.Add(envs[0]);
|
||||
|
@ -71,27 +71,27 @@ namespace XenAdmin.Actions.OvfActions
|
||||
{
|
||||
Debug.Assert(m_vmMappings.Count == 1, "There must be only one VM mapping");
|
||||
|
||||
string systemid = m_vmMappings.Keys.ElementAt(0);
|
||||
string sysId = m_vmMappings.Keys.ElementAt(0);
|
||||
var mapping = m_vmMappings.Values.ElementAt(0);
|
||||
|
||||
Tick(20, Messages.IMPORTING_DISK_IMAGE);
|
||||
|
||||
//create a copy of the ovf envelope
|
||||
EnvelopeType[] envs = OVF.Split(m_ovfEnvelope, "system", new object[] {new[] {systemid}});
|
||||
EnvelopeType[] envs = OVF.Split(m_ovfEnvelope, "system", new object[] {new[] {sysId}});
|
||||
EnvelopeType curEnv = envs[0];
|
||||
|
||||
//storage
|
||||
foreach (var kvp in mapping.Storage)
|
||||
OVF.SetTargetSRInRASD(curEnv, systemid, kvp.Key, kvp.Value.uuid);
|
||||
OVF.SetTargetSRInRASD(curEnv, sysId, kvp.Key, kvp.Value.uuid);
|
||||
|
||||
//network
|
||||
foreach (var kvp in mapping.Networks)
|
||||
OVF.SetTargetNetworkInRASD(curEnv, systemid, kvp.Key, kvp.Value.uuid);
|
||||
OVF.SetTargetNetworkInRASD(curEnv, sysId, kvp.Key, kvp.Value.uuid);
|
||||
|
||||
if (m_runfixups)
|
||||
{
|
||||
string cdId = OVF.SetRunOnceBootCDROMOSFixup(curEnv, systemid, m_directory, BrandManager.ProductBrand);
|
||||
OVF.SetTargetISOSRInRASD(curEnv, systemid, cdId, m_selectedIsoSr.uuid);
|
||||
string cdId = OVF.SetRunOnceBootCDROMOSFixup(curEnv, sysId, m_directory, BrandManager.ProductBrand);
|
||||
OVF.SetTargetISOSRInRASD(curEnv, sysId, cdId, m_selectedIsoSr.uuid);
|
||||
}
|
||||
|
||||
object importedObject;
|
||||
|
@ -1385,54 +1385,54 @@ namespace XenOvf
|
||||
|
||||
#region CREATEs
|
||||
|
||||
public static EnvelopeType CreateOvfEnvelope(string systemID, string vmName, ulong cpuCount, ulong memory,
|
||||
public static EnvelopeType CreateOvfEnvelope(string sysId, string vmName, ulong cpuCount, ulong memory,
|
||||
string bootParams, string platformSettings, ulong capacity,
|
||||
string diskPath, ulong imageLength, string productBrand)
|
||||
{
|
||||
EnvelopeType env = CreateEnvelope(vmName);
|
||||
AddVirtualSystem(env, vmName, systemID);
|
||||
AddVirtualSystem(env, vmName, sysId);
|
||||
|
||||
string hdwareSectionId = AddVirtualHardwareSection(env, systemID);
|
||||
string hdwareSectionId = AddVirtualHardwareSection(env, sysId);
|
||||
string guid = Guid.NewGuid().ToString();
|
||||
AddVirtualSystemSettingData(env, systemID, hdwareSectionId, env.Name, Messages.VIRTUAL_MACHINE, Messages.OVF_CREATED, guid, "hvm-3.0-unknown");
|
||||
AddVirtualSystemSettingData(env, sysId, hdwareSectionId, env.Name, Messages.VIRTUAL_MACHINE, Messages.OVF_CREATED, guid, "hvm-3.0-unknown");
|
||||
|
||||
AddOtherSystemSettingData(env, systemID, "HVM_boot_policy", "BIOS order", GetContentMessage("OTHER_SYSTEM_SETTING_DESCRIPTION_2"));
|
||||
AddOtherSystemSettingData(env, sysId, "HVM_boot_policy", "BIOS order", GetContentMessage("OTHER_SYSTEM_SETTING_DESCRIPTION_2"));
|
||||
|
||||
AddOtherSystemSettingData(env, systemID, "HVM_boot_params",
|
||||
AddOtherSystemSettingData(env, sysId, "HVM_boot_params",
|
||||
"order=dc;" + bootParams,
|
||||
GetContentMessage("OTHER_SYSTEM_SETTING_DESCRIPTION_6"));
|
||||
|
||||
AddOtherSystemSettingData(env, systemID, "platform",
|
||||
AddOtherSystemSettingData(env, sysId, "platform",
|
||||
"nx=true;acpi=true;apic=true;pae=true;stdvga=0;" + platformSettings,
|
||||
string.Format(GetContentMessage("OTHER_SYSTEM_SETTING_DESCRIPTION_3"), productBrand));
|
||||
|
||||
SetCPUs(env, systemID, cpuCount);
|
||||
SetMemory(env, systemID, memory, "MB");
|
||||
SetCPUs(env, sysId, cpuCount);
|
||||
SetMemory(env, sysId, memory, "MB");
|
||||
|
||||
string netId = Guid.NewGuid().ToString();
|
||||
AddNetwork(env, systemID, netId, string.Format(Messages.NETWORK_NAME, 0), Messages.OVF_NET_DESCRIPTION, null);
|
||||
AddNetwork(env, sysId, netId, string.Format(Messages.NETWORK_NAME, 0), Messages.OVF_NET_DESCRIPTION, null);
|
||||
|
||||
string diskId = Guid.NewGuid().ToString();
|
||||
|
||||
AddDisk(env, systemID, diskId, diskPath, true, Messages.OVF_DISK_CAPTION, Messages.OVF_CREATED, imageLength, capacity);
|
||||
AddDisk(env, sysId, diskId, diskPath, true, Messages.OVF_DISK_CAPTION, Messages.OVF_CREATED, imageLength, capacity);
|
||||
|
||||
FinalizeEnvelope(env);
|
||||
return env;
|
||||
}
|
||||
|
||||
public static EnvelopeType UpdateBootParams(EnvelopeType env, string systemID, string bootParams)
|
||||
public static EnvelopeType UpdateBootParams(EnvelopeType env, string sysId, string bootParams)
|
||||
{
|
||||
return UpdateOtherSystemSettingsData(env, systemID, "HVM_boot_params", "order=dc;" + bootParams);
|
||||
return UpdateOtherSystemSettingsData(env, sysId, "HVM_boot_params", "order=dc;" + bootParams);
|
||||
}
|
||||
|
||||
public static EnvelopeType UpdatePlatform(EnvelopeType env, string systemID, string platformSettings)
|
||||
public static EnvelopeType UpdatePlatform(EnvelopeType env, string sysId, string platformSettings)
|
||||
{
|
||||
return UpdateOtherSystemSettingsData(env, systemID, "platform", "nx=true;acpi=true;apic=true;pae=true;stdvga=0;" + platformSettings);
|
||||
return UpdateOtherSystemSettingsData(env, sysId, "platform", "nx=true;acpi=true;apic=true;pae=true;stdvga=0;" + platformSettings);
|
||||
}
|
||||
|
||||
private static EnvelopeType UpdateOtherSystemSettingsData(EnvelopeType env, string systemID, string setting, string value)
|
||||
private static EnvelopeType UpdateOtherSystemSettingsData(EnvelopeType env, string sysId, string setting, string value)
|
||||
{
|
||||
VirtualHardwareSection_Type[] vhsArray = FindVirtualHardwareSection(env, systemID);
|
||||
VirtualHardwareSection_Type[] vhsArray = FindVirtualHardwareSection(env, sysId);
|
||||
VirtualHardwareSection_Type foundVhs = null;
|
||||
|
||||
foreach (VirtualHardwareSection_Type vhs in vhsArray)
|
||||
@ -3628,8 +3628,8 @@ namespace XenOvf
|
||||
return systemIds.ToArray();
|
||||
}
|
||||
/// <summary>
|
||||
// Find a name to use of a VM within an envelope that could have come from any hypervisor.
|
||||
// TODO: Consider refactoring this method because it is very similar to XenAdmin.Wizards.ImportWizard().
|
||||
/// Find a name to use of a VM within an envelope that could have come from any hypervisor.
|
||||
/// TODO: Consider refactoring this method because it is very similar to XenAdmin.Wizards.ImportWizard().
|
||||
/// </summary>
|
||||
/// <param name="ovfObj"></param>
|
||||
/// <param name="sysId"></param>
|
||||
|
Loading…
Reference in New Issue
Block a user