mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2024-11-23 20:36:33 +01:00
Small improvement to abstract class design.
Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
This commit is contained in:
parent
4162b19cfc
commit
4cacc422b8
@ -44,7 +44,8 @@ namespace XenAdmin.Actions.OVFActions
|
||||
protected string m_tvmIpAddress;
|
||||
protected string m_tvmSubnetMask;
|
||||
protected string m_tvmGateway;
|
||||
protected XenOvfTransportBase m_transportAction;
|
||||
|
||||
protected abstract XenOvfTransportBase TransportAction { get; }
|
||||
|
||||
private const int SLEEP_TIME = 900;
|
||||
private const int MAX_ITERATIONS = 60 * 60 * 24 / SLEEP_TIME * 1000; //iterations in 24h
|
||||
@ -104,8 +105,8 @@ namespace XenAdmin.Actions.OVFActions
|
||||
{
|
||||
Description = Messages.CANCELING;
|
||||
|
||||
if (m_transportAction != null)
|
||||
m_transportAction.Cancel = true;
|
||||
if (TransportAction != null)
|
||||
TransportAction.Cancel = true;
|
||||
}
|
||||
|
||||
private void InitialiseTicker()
|
||||
|
@ -40,6 +40,7 @@ using XenAPI;
|
||||
|
||||
using XenOvf;
|
||||
using XenOvf.Definitions;
|
||||
using XenOvfTransport;
|
||||
|
||||
namespace XenAdmin.Actions.OVFActions
|
||||
{
|
||||
@ -60,6 +61,7 @@ namespace XenAdmin.Actions.OVFActions
|
||||
private readonly bool m_compressOVFfiles;
|
||||
private readonly bool m_shouldVerify;
|
||||
private OvfCompressor m_compressor;
|
||||
private Export m_transportAction;
|
||||
|
||||
#endregion
|
||||
|
||||
@ -88,6 +90,8 @@ namespace XenAdmin.Actions.OVFActions
|
||||
VM = m_vmsToExport.First();
|
||||
}
|
||||
|
||||
protected override XenOvfTransportBase TransportAction => m_transportAction;
|
||||
|
||||
protected override void Run()
|
||||
{
|
||||
base.Run();
|
||||
@ -108,14 +112,14 @@ namespace XenAdmin.Actions.OVFActions
|
||||
EnvelopeType env;
|
||||
try
|
||||
{
|
||||
m_transportAction = new XenOvfTransport.Export(uri, session)
|
||||
m_transportAction = new Export(uri, session)
|
||||
{
|
||||
UpdateHandler = UpdateHandler,
|
||||
ShouldVerifyDisks = m_shouldVerify,
|
||||
Cancel = Cancelling //in case the Cancel button has already been pressed
|
||||
};
|
||||
m_transportAction.SetTvmNetwork(m_networkUuid, m_isTvmIpStatic, m_tvmIpAddress, m_tvmSubnetMask, m_tvmGateway);
|
||||
env = (m_transportAction as XenOvfTransport.Export).Process(appFolder, m_applianceFileName, (from VM vm in m_vmsToExport select vm.uuid).ToArray());
|
||||
env = m_transportAction.Process(appFolder, m_applianceFileName, (from VM vm in m_vmsToExport select vm.uuid).ToArray());
|
||||
PercentComplete = 60;
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
|
@ -55,6 +55,7 @@ namespace XenAdmin.Actions.OVFActions
|
||||
private readonly string m_password;
|
||||
private readonly bool m_runfixups;
|
||||
private readonly SR m_selectedIsoSr;
|
||||
private Import m_transportAction;
|
||||
|
||||
#endregion
|
||||
|
||||
@ -74,6 +75,8 @@ namespace XenAdmin.Actions.OVFActions
|
||||
m_selectedIsoSr = selectedIsoSr;
|
||||
}
|
||||
|
||||
protected override XenOvfTransportBase TransportAction => m_transportAction;
|
||||
|
||||
protected override void Run()
|
||||
{
|
||||
base.Run();
|
||||
@ -166,7 +169,7 @@ namespace XenAdmin.Actions.OVFActions
|
||||
Cancel = Cancelling //in case the Cancel button has already been pressed
|
||||
};
|
||||
m_transportAction.SetTvmNetwork(m_networkUuid, m_isTvmIpStatic, m_tvmIpAddress, m_tvmSubnetMask, m_tvmGateway);
|
||||
(m_transportAction as Import).Process(env, Path.GetDirectoryName(m_package.PackageSourceFile), m_password);
|
||||
m_transportAction.Process(env, Path.GetDirectoryName(m_package.PackageSourceFile), m_password);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
|
@ -53,6 +53,7 @@ namespace XenAdmin.Actions.OVFActions
|
||||
private readonly bool m_runfixups;
|
||||
private readonly SR m_selectedIsoSr;
|
||||
private readonly string m_directory;
|
||||
private Import m_transportAction;
|
||||
|
||||
#endregion
|
||||
|
||||
@ -68,6 +69,8 @@ namespace XenAdmin.Actions.OVFActions
|
||||
m_selectedIsoSr = selectedIsoSr;
|
||||
}
|
||||
|
||||
protected override XenOvfTransportBase TransportAction => m_transportAction;
|
||||
|
||||
protected override void Run()
|
||||
{
|
||||
base.Run();
|
||||
@ -110,7 +113,7 @@ namespace XenAdmin.Actions.OVFActions
|
||||
Cancel = Cancelling //in case the Cancel button has already been pressed
|
||||
};
|
||||
m_transportAction.SetTvmNetwork(m_networkUuid, m_isTvmIpStatic, m_tvmIpAddress, m_tvmSubnetMask, m_tvmGateway);
|
||||
(m_transportAction as Import).Process(curEnv, m_directory, null);
|
||||
m_transportAction.Process(curEnv, m_directory, null);
|
||||
|
||||
PercentComplete = 100;
|
||||
Description = Messages.COMPLETED;
|
||||
|
Loading…
Reference in New Issue
Block a user