mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2024-11-27 02:56:01 +01:00
Removed XenOvfTransportEvent.
Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
This commit is contained in:
parent
74aa727f15
commit
4e95b25572
@ -75,10 +75,10 @@ namespace XenAdmin.Actions.OVFActions
|
||||
InitialiseTicker();
|
||||
}
|
||||
|
||||
protected void UpdateHandler(XenOvfTransportEventArgs e)
|
||||
protected void UpdateHandler(string message)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(e.Message))
|
||||
Description = e.Message;
|
||||
if (!string.IsNullOrEmpty(message))
|
||||
Description = message;
|
||||
}
|
||||
|
||||
public override void RecomputeCanCancel()
|
||||
@ -105,7 +105,5 @@ namespace XenAdmin.Actions.OVFActions
|
||||
Thread.Sleep(SLEEP_TIME);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -48,14 +48,14 @@ namespace XenOvfTransport
|
||||
{
|
||||
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
public static EnvelopeType _export(IXenConnection connection, string targetPath, string ovfname, VM vm, Action<XenOvfTransportEventArgs> OnUpdate, HTTP.FuncBool onCancel, bool verifyDisks, bool metaDataOnly = false)
|
||||
public static EnvelopeType _export(IXenConnection connection, string targetPath, string ovfname, VM vm, Action<string> OnUpdate, HTTP.FuncBool onCancel, bool verifyDisks, bool metaDataOnly = false)
|
||||
{
|
||||
log.DebugFormat("Export: {0}, {1}", ovfname, targetPath);
|
||||
|
||||
if (vm.power_state != vm_power_state.Halted && vm.power_state != vm_power_state.Suspended)
|
||||
{
|
||||
var message = string.Format(Messages.ERROR_VM_NOT_HALTED, vm.Name());
|
||||
OnUpdate(new XenOvfTransportEventArgs(TransportStep.Export, message));
|
||||
OnUpdate(message);
|
||||
log.Info($"VM {vm.Name()} ({vm.opaque_ref}) is neither halted nor suspended.");
|
||||
throw new Exception(message);
|
||||
}
|
||||
@ -164,12 +164,11 @@ namespace XenOvfTransport
|
||||
|
||||
if (!metaDataOnly)
|
||||
{
|
||||
OnUpdate(new XenOvfTransportEventArgs(TransportStep.Export, string.Format(Messages.FILES_TRANSPORT_SETUP, diskFilename)));
|
||||
OnUpdate(string.Format(Messages.FILES_TRANSPORT_SETUP, diskFilename));
|
||||
|
||||
var taskRef = Task.create(connection.Session, "export_raw_vdi_task", "export_raw_vdi_task");
|
||||
HTTP_actions.get_export_raw_vdi(
|
||||
b => OnUpdate(new XenOvfTransportEventArgs(TransportStep.Export,
|
||||
$"Exporting {diskFilename} ({Util.DiskSizeString(b)} done")),
|
||||
b => OnUpdate($"Exporting {diskFilename} ({Util.DiskSizeString(b)} done)"),
|
||||
onCancel, XenAdminConfigManager.Provider.GetProxyTimeout(true),
|
||||
connection.Hostname, XenAdminConfigManager.Provider.GetProxyFromSettings(connection),
|
||||
diskPath, taskRef, connection.Session.opaque_ref, vdi.uuid, "vhd");
|
||||
|
@ -58,7 +58,7 @@ namespace XenOvfTransport
|
||||
|
||||
#region PUBLIC
|
||||
|
||||
public static void Process(IXenConnection connection, EnvelopeType ovfObj, string pathToOvf, Action<XenOvfTransportEventArgs> OnUpdate, string passCode = null, string applianceName = null, bool metaDataOnly = false)
|
||||
public static void Process(IXenConnection connection, EnvelopeType ovfObj, string pathToOvf, Action<string> OnUpdate, string passCode = null, string applianceName = null, bool metaDataOnly = false)
|
||||
{
|
||||
var xenSession = connection.Session;
|
||||
if (xenSession == null)
|
||||
@ -223,7 +223,7 @@ namespace XenOvfTransport
|
||||
|
||||
if (installSection != null && installSection.Length == 1)
|
||||
{
|
||||
OnUpdate(new XenOvfTransportEventArgs(TransportStep.Import, Messages.START_POST_INSTALL_INSTRUCTIONS));
|
||||
OnUpdate(Messages.START_POST_INSTALL_INSTRUCTIONS);
|
||||
HandleInstallSection(xenSession, vmRef, installSection[0]);
|
||||
}
|
||||
ShowSystem(xenSession, vmRef);
|
||||
@ -261,7 +261,7 @@ namespace XenOvfTransport
|
||||
}
|
||||
}
|
||||
|
||||
OnUpdate(new XenOvfTransportEventArgs(TransportStep.Import, Messages.COMPLETED_IMPORT));
|
||||
OnUpdate(Messages.COMPLETED_IMPORT);
|
||||
}
|
||||
|
||||
#endregion
|
||||
@ -365,7 +365,7 @@ namespace XenOvfTransport
|
||||
}
|
||||
}
|
||||
|
||||
private static XenRef<VDI> ImportFile(Session xenSession, Action<XenOvfTransportEventArgs> OnUpdate, string vmname, string pathToOvf, string filename, string compression, string version, string passcode, string sruuid, string description, string vdiuuid, string encryptionClass)
|
||||
private static XenRef<VDI> ImportFile(Session xenSession, Action<string> OnUpdate, string vmname, string pathToOvf, string filename, string compression, string version, string passcode, string sruuid, string description, string vdiuuid, string encryptionClass)
|
||||
{
|
||||
string sourcefile = filename;
|
||||
string encryptfilename = null;
|
||||
@ -392,12 +392,12 @@ namespace XenOvfTransport
|
||||
if (passcode != null)
|
||||
{
|
||||
var statusMessage = string.Format(Messages.START_FILE_DECRYPTION, filename);
|
||||
OnUpdate(new XenOvfTransportEventArgs(TransportStep.Security, statusMessage));
|
||||
OnUpdate(statusMessage);
|
||||
log.Debug($"Decrypting {filename}");
|
||||
OVF.DecryptToTempFile(encryptionClass, filename, version, passcode, encryptfilename);
|
||||
sourcefile = encryptfilename;
|
||||
statusMessage += Messages.COMPLETE;
|
||||
OnUpdate(new XenOvfTransportEventArgs(TransportStep.Security, statusMessage));
|
||||
OnUpdate(statusMessage);
|
||||
}
|
||||
#endregion
|
||||
|
||||
@ -417,13 +417,13 @@ namespace XenOvfTransport
|
||||
ext = Path.GetExtension(uncompressedfilename);
|
||||
}
|
||||
var statusMessage = string.Format(Messages.START_FILE_EXPANSION, filename);
|
||||
OnUpdate(new XenOvfTransportEventArgs(TransportStep.Compression, statusMessage));
|
||||
OnUpdate(statusMessage);
|
||||
var ovfCompressor = new OvfCompressor();
|
||||
ovfCompressor.UncompressFile(sourcefile, uncompressedfilename, compression);
|
||||
if (File.Exists(encryptfilename)) { File.Delete(encryptfilename); }
|
||||
sourcefile = uncompressedfilename;
|
||||
statusMessage += Messages.COMPLETE;
|
||||
OnUpdate(new XenOvfTransportEventArgs(TransportStep.Compression, statusMessage));
|
||||
OnUpdate(statusMessage);
|
||||
}
|
||||
#endregion
|
||||
|
||||
@ -536,8 +536,7 @@ namespace XenOvfTransport
|
||||
|
||||
using (Stream outStream = HTTPHelper.PUT(uriBuilder.Uri, dataStream.Length, true))
|
||||
HTTP.CopyStream(dataStream, outStream,
|
||||
b => OnUpdate(new XenOvfTransportEventArgs(TransportStep.Import,
|
||||
$"Importing disk {filename} ({Util.DiskSizeString(b)} of {Util.DiskSizeString(dataCapacity)} done)")),
|
||||
b => OnUpdate($"Importing disk {filename} ({Util.DiskSizeString(b)} of {Util.DiskSizeString(dataCapacity)} done)"),
|
||||
() => XenAdminConfigManager.Provider.ForcedExiting);
|
||||
#endregion
|
||||
|
||||
@ -884,7 +883,7 @@ namespace XenOvfTransport
|
||||
return hPlatform;
|
||||
}
|
||||
|
||||
private static void AddResourceSettingData(Session xenSession, Action<XenOvfTransportEventArgs> OnUpdate, XenRef<VM> vmRef, RASD_Type rasd, string pathToOvf, string filename, string compression, string version, string passcode, bool metaDataOnly, string encryptionClass, ref int vifDeviceIndex)
|
||||
private static void AddResourceSettingData(Session xenSession, Action<string> OnUpdate, XenRef<VM> vmRef, RASD_Type rasd, string pathToOvf, string filename, string compression, string version, string passcode, bool metaDataOnly, string encryptionClass, ref int vifDeviceIndex)
|
||||
{
|
||||
switch (rasd.ResourceType.Value)
|
||||
{
|
||||
@ -1234,15 +1233,14 @@ namespace XenOvfTransport
|
||||
"Import: Then attach disks with labels ending with \"+\" to the device number defined before the +." +
|
||||
"Import: ===========================================================", vmRef);
|
||||
|
||||
OnUpdate(new XenOvfTransportEventArgs(TransportStep.Import, Messages.WARNING_ADMIN_REQUIRED));
|
||||
OnUpdate(Messages.WARNING_ADMIN_REQUIRED);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
#endregion
|
||||
OnUpdate(new XenOvfTransportEventArgs(TransportStep.CdDvdDrive,
|
||||
string.Format(Messages.DEVICE_ATTACHED, Messages.CD_DVD_DEVICE)));
|
||||
OnUpdate(string.Format(Messages.DEVICE_ATTACHED, Messages.CD_DVD_DEVICE));
|
||||
log.Debug("Import.AddResourceSettingData: CD/DVD ROM Added");
|
||||
|
||||
break;
|
||||
@ -1474,7 +1472,7 @@ namespace XenOvfTransport
|
||||
"Import: Then manually attach disks with labels with {0}_# that are not attached to {0}" +
|
||||
"Import: ===========================================================",
|
||||
vmName);
|
||||
OnUpdate(new XenOvfTransportEventArgs(TransportStep.Import, Messages.WARNING_ADMIN_REQUIRED));
|
||||
OnUpdate(Messages.WARNING_ADMIN_REQUIRED);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,6 @@
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="XenOvfTransportEvent.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\CommandLib\CommandLib.csproj">
|
||||
|
@ -1,70 +0,0 @@
|
||||
/* Copyright (c) Citrix Systems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms,
|
||||
* with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above
|
||||
* copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the
|
||||
* following disclaimer in the documentation and/or other
|
||||
* materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
|
||||
namespace XenOvfTransport
|
||||
{
|
||||
public class XenOvfTransportEventArgs : EventArgs
|
||||
{
|
||||
public XenOvfTransportEventArgs(TransportStep step, string message)
|
||||
{
|
||||
Step = step;
|
||||
Message = message;
|
||||
}
|
||||
|
||||
public XenOvfTransportEventArgs(TransportStep step, string message, ulong transferred, ulong total)
|
||||
: this(step, message)
|
||||
{
|
||||
Total = total;
|
||||
Transferred = transferred;
|
||||
}
|
||||
|
||||
public TransportStep Step { get; }
|
||||
|
||||
public string Message { get; }
|
||||
|
||||
public ulong Total { get; }
|
||||
|
||||
public ulong Transferred { get; }
|
||||
}
|
||||
|
||||
public enum TransportStep
|
||||
{
|
||||
Export,
|
||||
Import,
|
||||
Security,
|
||||
Compression,
|
||||
CdDvdDrive,
|
||||
SendData,
|
||||
Download
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user