mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2025-01-20 07:19:18 +01:00
Merge pull request #746 from GaborApatiNagy/CA-178985
CA-178985: Removed ova.xml import from XenCenter
This commit is contained in:
commit
34612db6f8
@ -57,7 +57,7 @@ namespace XenAdmin.Wizards.ImportWizard
|
||||
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
private readonly string[] m_supportedImageTypes = new[] { ".vhd", ".vmdk" };//CA-61385: remove ".vdi", ".wim" support for Boston
|
||||
private readonly string[] m_supportedApplianceTypes = new[] { ".ovf", ".ova", ".ova.gz" };
|
||||
private readonly string[] m_supportedXvaTypes = new[] {".xva", "ova.xml"};
|
||||
private readonly string[] m_supportedXvaTypes = new[] { ".xva" };
|
||||
|
||||
/// <summary>
|
||||
/// Stores the last valid selected appliance
|
||||
@ -211,8 +211,6 @@ namespace XenAdmin.Wizards.ImportWizard
|
||||
|
||||
public bool IsWIM { get; private set; }
|
||||
|
||||
public bool IsXvaVersion1 { get; private set; }
|
||||
|
||||
public ulong DiskCapacity { get; private set; }
|
||||
|
||||
#endregion
|
||||
@ -244,9 +242,7 @@ namespace XenAdmin.Wizards.ImportWizard
|
||||
FileInfo info = new FileInfo(m_textBoxFile.Text);
|
||||
ImageLength = info.Length > 0 ? (ulong)info.Length : 0;
|
||||
|
||||
DiskCapacity = IsXvaVersion1
|
||||
? GetTotalSizeFromXmlGeneva() //Geneva style
|
||||
: GetTotalSizeFromXmlXva(GetXmlStringFromTarXVA()); //xva style
|
||||
DiskCapacity = GetTotalSizeFromXmlXva(GetXmlStringFromTarXVA()); //xva style
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
@ -255,20 +251,6 @@ namespace XenAdmin.Wizards.ImportWizard
|
||||
return true;
|
||||
}
|
||||
|
||||
private ulong GetTotalSizeFromXmlGeneva()
|
||||
{
|
||||
ulong totalSize = 0;
|
||||
XmlDocument xmlMetadata = new XmlDocument();
|
||||
xmlMetadata.Load(m_textBoxFile.Text);
|
||||
XPathNavigator nav = xmlMetadata.CreateNavigator();
|
||||
XPathNodeIterator nodeIterator = nav.Select(".//vdi");
|
||||
|
||||
while (nodeIterator.MoveNext())
|
||||
totalSize += UInt64.Parse(nodeIterator.Current.GetAttribute("size", ""));
|
||||
|
||||
return totalSize;
|
||||
}
|
||||
|
||||
private string GetXmlStringFromTarXVA()
|
||||
{
|
||||
using (Stream stream = new FileStream(m_textBoxFile.Text, FileMode.Open, FileAccess.Read))
|
||||
@ -475,7 +457,7 @@ namespace XenAdmin.Wizards.ImportWizard
|
||||
}
|
||||
|
||||
if (ext == "ova.xml")
|
||||
IsXvaVersion1 = true;
|
||||
return false; //not supported anymore
|
||||
|
||||
TypeOfImport = ImportWizard.ImportType.Xva;
|
||||
return true;
|
||||
|
@ -120,15 +120,7 @@ namespace XenAdmin.Actions
|
||||
|
||||
try
|
||||
{
|
||||
string vmRef;
|
||||
|
||||
if (m_filename.EndsWith("ova.xml"))//importing version 1 from of VM
|
||||
{
|
||||
m_filename = m_filename.Replace("ova.xml", "");
|
||||
vmRef = GetVmRef(applyVersionOneFiles());
|
||||
}
|
||||
else//importing current format of VM
|
||||
vmRef = GetVmRef(applyFile());
|
||||
string vmRef = GetVmRef(applyFile());
|
||||
|
||||
if (Cancelling)
|
||||
throw new CancelledException();
|
||||
@ -276,78 +268,6 @@ namespace XenAdmin.Actions
|
||||
return s;
|
||||
}
|
||||
|
||||
private string applyVersionOneFiles()
|
||||
{
|
||||
RelatedTask = Task.create(Session, "importTask", Messages.IMPORTING);
|
||||
|
||||
try
|
||||
{
|
||||
long totalSize = getSize(new DirectoryInfo(m_filename), 0);
|
||||
long bytesWritten = 0;
|
||||
|
||||
if (totalSize == 0)
|
||||
{
|
||||
// We didn't find any .gz files, just bail out here
|
||||
throw new Exception(Messages.IMPORT_INCOMPLETE_FILES);
|
||||
}
|
||||
|
||||
CommandLib.Config config = new CommandLib.Config
|
||||
{
|
||||
hostname = Connection.Hostname,
|
||||
username = Connection.Username,
|
||||
password = Connection.Password
|
||||
};
|
||||
|
||||
CommandLib.thinCLIProtocol tCLIprotocol = null;
|
||||
int exitCode = 0;
|
||||
tCLIprotocol = new CommandLib.thinCLIProtocol(delegate(string s) { throw new Exception(s); },
|
||||
delegate { throw new Exception(Messages.EXPORTVM_NOT_HAPPEN); },
|
||||
delegate(string s, CommandLib.thinCLIProtocol t) { log.Debug(s); },
|
||||
delegate(string s) { log.Debug(s); },
|
||||
delegate(string s) { log.Debug(s); },
|
||||
delegate { throw new Exception(Messages.EXPORTVM_NOT_HAPPEN); },
|
||||
delegate(int i)
|
||||
{
|
||||
exitCode = i;
|
||||
tCLIprotocol.dropOut = true;
|
||||
},
|
||||
delegate(int i)
|
||||
{
|
||||
bytesWritten += i;
|
||||
PercentComplete = (int)(100.0*bytesWritten/totalSize);
|
||||
},
|
||||
config);
|
||||
|
||||
string body = string.Format("vm-import\nsr-uuid={0}\nfilename={1}\ntask_id={2}\n",
|
||||
SR.uuid, m_filename, RelatedTask.opaque_ref);
|
||||
log.DebugFormat("Importing Geneva-style XVA from {0} to SR {1} using {2}", m_filename, SR.Name, body);
|
||||
CommandLib.Messages.performCommand(body, tCLIprotocol);
|
||||
|
||||
// Check the task status -- Geneva-style XVAs don't raise an error, so we need to check manually.
|
||||
List<string> excep = TaskErrorInfo();
|
||||
if (excep.Count > 0)
|
||||
throw new Failure(excep);
|
||||
|
||||
// CA-33665: We found a situation before were the task handling had been messed up, we should check the exit code as a failsafe
|
||||
if (exitCode != 0)
|
||||
throw new Failure(new[] {Messages.IMPORT_GENERIC_FAIL});
|
||||
|
||||
return Task.get_result(Session, RelatedTask);
|
||||
}
|
||||
catch (Exception exn)
|
||||
{
|
||||
List<string> excep = TaskErrorInfo();
|
||||
if (excep.Count > 0)
|
||||
throw new Failure(excep);
|
||||
else
|
||||
throw exn;
|
||||
}
|
||||
finally
|
||||
{
|
||||
Task.destroy(Session, RelatedTask);
|
||||
}
|
||||
}
|
||||
|
||||
private string applyFile()
|
||||
{
|
||||
log.DebugFormat("Importing Rio-style XVA from {0} to SR {1}", m_filename, SR.Name);
|
||||
|
4
XenModel/Messages.Designer.cs
generated
4
XenModel/Messages.Designer.cs
generated
@ -17502,7 +17502,7 @@ namespace XenAdmin {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to All import options (*.ovf;*.ova;*.ova.gz;*.vhd;*.vmdk;*.xva;ova.xml)|*.ovf;*.ova;*.ova.gz;*.vhd;*.vmdk;*.xva;ova.xml|OVF/OVA Package files (*.ovf;*.ova;*.ova.gz)|*.ovf;*.ova*;*.ova.gz|Virtual Hard Disk images (*.vhd;*.vmdk;)|*.vhd;*.vmdk;|XVA files (*.xva)|*.xva|XVA Version 1|ova.xml.
|
||||
/// Looks up a localized string similar to All import options (*.ovf;*.ova;*.ova.gz;*.vhd;*.vmdk;*.xva)|*.ovf;*.ova;*.ova.gz;*.vhd;*.vmdk;*.xva|OVF/OVA Package files (*.ovf;*.ova;*.ova.gz)|*.ovf;*.ova*;*.ova.gz|Virtual Hard Disk images (*.vhd;*.vmdk;)|*.vhd;*.vmdk;|XVA files (*.xva)|*.xva.
|
||||
/// </summary>
|
||||
public static string IMPORT_SOURCE_PAGE_FILETYPES {
|
||||
get {
|
||||
@ -25790,7 +25790,7 @@ namespace XenAdmin {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to XVA (*.xva)|*.xva|XVA Version 1 (ova.xml)|ova.xml.
|
||||
/// Looks up a localized string similar to XVA (*.xva)|*.xva.
|
||||
/// </summary>
|
||||
public static string PATHPICKER_FILETYPE {
|
||||
get {
|
||||
|
@ -6162,7 +6162,7 @@ Click Configure HA to alter the settings displayed below.</value>
|
||||
<value>Only OVF/OVA packages can be imported as vApps.</value>
|
||||
</data>
|
||||
<data name="IMPORT_SOURCE_PAGE_FILETYPES" xml:space="preserve">
|
||||
<value>All import options (*.ovf;*.ova;*.ova.gz;*.vhd;*.vmdk;*.xva;ova.xml)|*.ovf;*.ova;*.ova.gz;*.vhd;*.vmdk;*.xva;ova.xml|OVF/OVA Package files (*.ovf;*.ova;*.ova.gz)|*.ovf;*.ova*;*.ova.gz|Virtual Hard Disk images (*.vhd;*.vmdk;)|*.vhd;*.vmdk;|XVA files (*.xva)|*.xva|XVA Version 1|ova.xml</value>
|
||||
<value>All import options (*.ovf;*.ova;*.ova.gz;*.vhd;*.vmdk;*.xva)|*.ovf;*.ova;*.ova.gz;*.vhd;*.vmdk;*.xva|OVF/OVA Package files (*.ovf;*.ova;*.ova.gz)|*.ovf;*.ova*;*.ova.gz|Virtual Hard Disk images (*.vhd;*.vmdk;)|*.vhd;*.vmdk;|XVA files (*.xva)|*.xva</value>
|
||||
</data>
|
||||
<data name="IMPORT_SOURCE_PAGE_FILETYPES_OVF_ONLY" xml:space="preserve">
|
||||
<value>OVF/OVA Package files (*.ovf;*.ova;*.ova.gz)|*.ovf;*.ova*;*.ova.gz</value>
|
||||
@ -8991,7 +8991,7 @@ File not found</value>
|
||||
<value>Update uploaded to server '{0}' </value>
|
||||
</data>
|
||||
<data name="PATHPICKER_FILETYPE" xml:space="preserve">
|
||||
<value>XVA (*.xva)|*.xva|XVA Version 1 (ova.xml)|ova.xml</value>
|
||||
<value>XVA (*.xva)|*.xva</value>
|
||||
</data>
|
||||
<data name="PBDS_CHECK_DESCRIPTION" xml:space="preserve">
|
||||
<value>Storage connection check</value>
|
||||
|
Loading…
Reference in New Issue
Block a user