mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2025-01-20 23:39:51 +01:00
Tidy up.
Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
This commit is contained in:
parent
ae7df535c2
commit
404ee1680a
@ -50,6 +50,13 @@ namespace XenAdmin.Wizards.DRWizards
|
||||
{
|
||||
private static readonly ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private static Bitmap animatedImage = Resources.ajax_loader;
|
||||
|
||||
private readonly Dictionary<VDI, List<AsyncAction>> _actions = new Dictionary<VDI, List<AsyncAction>>();
|
||||
private int objectsToBeRecovered;
|
||||
private MultipleAction multipleRecoverAction;
|
||||
private Session metadataSession;
|
||||
|
||||
public event Action ReportStarted;
|
||||
public event Action<AsyncAction> ReportActionResultGot;
|
||||
public event Action<string, int, bool> ReportLineGot;
|
||||
@ -93,8 +100,6 @@ namespace XenAdmin.Wizards.DRWizards
|
||||
}
|
||||
}
|
||||
|
||||
private static Bitmap animatedImage = Resources.ajax_loader;
|
||||
|
||||
private void onFrameChanged(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
@ -113,7 +118,7 @@ namespace XenAdmin.Wizards.DRWizards
|
||||
ImageAnimator.StopAnimate(animatedImage, onFrameChanged);
|
||||
if (direction == PageLoadedDirection.Back)
|
||||
{
|
||||
actions.Clear();
|
||||
_actions.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
@ -161,17 +166,17 @@ namespace XenAdmin.Wizards.DRWizards
|
||||
|
||||
public DRWizardType WizardType { private get; set; }
|
||||
|
||||
private Dictionary<VDI, List<AsyncAction>> actions = new Dictionary<VDI, List<AsyncAction>>();
|
||||
private int objectsToBeRecovered;
|
||||
internal List<string> RecoveredVmsUuids { get; } = new List<string>();
|
||||
|
||||
private StartActionAfterRecovery startActionAfterRecovery;
|
||||
public StartActionAfterRecovery StartActionAfterRecovery { set { startActionAfterRecovery = value; } }
|
||||
internal List<string> RecoveredVmAppliancesUuids { get; } = new List<string>();
|
||||
|
||||
public StartActionAfterRecovery StartActionAfterRecovery { private get; set; }
|
||||
|
||||
public Dictionary<XenRef<VDI>, PoolMetadata> SelectedPoolMetadata { private get; set; }
|
||||
|
||||
protected override void PageLoadedCore(PageLoadedDirection direction)
|
||||
{
|
||||
if (direction == PageLoadedDirection.Back || actions.Count > 0)
|
||||
if (direction == PageLoadedDirection.Back || _actions.Count > 0)
|
||||
return;
|
||||
|
||||
ImageAnimator.Animate(animatedImage, onFrameChanged);
|
||||
@ -183,18 +188,18 @@ namespace XenAdmin.Wizards.DRWizards
|
||||
OnPageUpdated();
|
||||
|
||||
dataGridView1.Rows.Clear();
|
||||
actions.Clear();
|
||||
_actions.Clear();
|
||||
objectsToBeRecovered = 0;
|
||||
|
||||
// add "recovery" tasks
|
||||
foreach (var poolMetadata in SelectedPoolMetadata.Values)
|
||||
{
|
||||
actions.Add(poolMetadata.Vdi, CreateSubActionsFor(poolMetadata));
|
||||
_actions.Add(poolMetadata.Vdi, CreateSubActionsFor(poolMetadata));
|
||||
}
|
||||
|
||||
// add a row for "Start VMs and Appliances" task, if required
|
||||
|
||||
if (startActionAfterRecovery != StartActionAfterRecovery.None)
|
||||
if (StartActionAfterRecovery != StartActionAfterRecovery.None)
|
||||
dataGridView1.Rows.Add(new DataGridViewRowRecover(Messages.ACTION_START_VMS_AND_APPLIANCES_TITLE));
|
||||
|
||||
labelOverallProgress.Text = string.Format(Messages.DR_WIZARD_RECOVERPAGE_OVERALL_PROGRESS, 0, dataGridView1.Rows.Count);
|
||||
@ -242,9 +247,6 @@ namespace XenAdmin.Wizards.DRWizards
|
||||
return subActions;
|
||||
}
|
||||
|
||||
internal List<string> RecoveredVmsUuids = new List<string>();
|
||||
internal List<string> RecoveredVmAppliancesUuids = new List<string>();
|
||||
|
||||
private void SingleRecoverActionCompleted(ActionBase sender)
|
||||
{
|
||||
DrRecoverAction senderAction = (DrRecoverAction)sender;
|
||||
@ -297,10 +299,6 @@ namespace XenAdmin.Wizards.DRWizards
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private MultipleAction multipleRecoverAction;
|
||||
private Session metadataSession;
|
||||
|
||||
private void OpenDatabaseActionCompleted(ActionBase sender)
|
||||
{
|
||||
VdiOpenDatabaseAction senderAction = (VdiOpenDatabaseAction)sender;
|
||||
@ -314,7 +312,7 @@ namespace XenAdmin.Wizards.DRWizards
|
||||
|
||||
// assign metadata session to all recover actions
|
||||
List<AsyncAction> recoverSubActions = new List<AsyncAction>();
|
||||
foreach (var action in actions[senderAction.Vdi])
|
||||
foreach (var action in _actions[senderAction.Vdi])
|
||||
{
|
||||
if (action is DrRecoverAction)
|
||||
{
|
||||
@ -345,7 +343,7 @@ namespace XenAdmin.Wizards.DRWizards
|
||||
{
|
||||
if (objectsToBeRecovered == 0) // finished recovering, now start VMs, if required
|
||||
{
|
||||
switch (startActionAfterRecovery)
|
||||
switch (StartActionAfterRecovery)
|
||||
{
|
||||
case StartActionAfterRecovery.Start :
|
||||
StartRecoveredVMs(false);
|
||||
@ -369,7 +367,7 @@ namespace XenAdmin.Wizards.DRWizards
|
||||
|
||||
private void RecoverNextPool()
|
||||
{
|
||||
foreach (var actionList in actions.Values)
|
||||
foreach (var actionList in _actions.Values)
|
||||
{
|
||||
bool startRecovery = false;
|
||||
foreach (var action in actionList)
|
||||
@ -421,12 +419,9 @@ namespace XenAdmin.Wizards.DRWizards
|
||||
}
|
||||
|
||||
var action = new StartVMsAndAppliancesAction(Connection, vmsToStart, vmAppliancesToStart, VMOperationCommand.WarningDialogHAInvalidConfig, VMOperationCommand.StartDiagnosisForm, paused);
|
||||
if (action != null)
|
||||
{
|
||||
action.Completed += StartVMsActionCompleted;
|
||||
action.Changed += StartVMsActionChanged;
|
||||
action.RunAsync();
|
||||
}
|
||||
action.Completed += StartVMsActionCompleted;
|
||||
action.Changed += StartVMsActionChanged;
|
||||
action.RunAsync();
|
||||
}
|
||||
|
||||
private void StartVMsActionChanged(ActionBase sender)
|
||||
@ -483,22 +478,20 @@ namespace XenAdmin.Wizards.DRWizards
|
||||
public class DataGridViewRowRecover : DataGridViewRow
|
||||
{
|
||||
public readonly IXenObject XenObject; // it can be VM or VM_appliance
|
||||
private DataGridViewImageCell imageCell = new DataGridViewImageCell();
|
||||
private DataGridViewTextBoxCell taskCell = new DataGridViewTextBoxCell();
|
||||
private DataGridViewTextBoxCell statusCell = new DataGridViewTextBoxCell();
|
||||
private readonly DataGridViewImageCell _imageCell = new DataGridViewImageCell();
|
||||
private readonly DataGridViewTextBoxCell _taskCell = new DataGridViewTextBoxCell();
|
||||
private readonly DataGridViewTextBoxCell _statusCell = new DataGridViewTextBoxCell();
|
||||
|
||||
private DataGridViewRowRecover()
|
||||
{
|
||||
this.Cells.Add(taskCell);
|
||||
this.Cells.Add(imageCell);
|
||||
this.Cells.Add(statusCell);
|
||||
this.Cells.AddRange(_taskCell, _imageCell, _statusCell);
|
||||
}
|
||||
|
||||
public DataGridViewRowRecover(IXenObject xenObject)
|
||||
: this()
|
||||
{
|
||||
XenObject = xenObject;
|
||||
taskCell.Value = XenObject is VM
|
||||
_taskCell.Value = XenObject is VM
|
||||
? string.Format(Messages.ACTION_DR_RECOVER_VM_TITLE, XenObject.Name())
|
||||
: string.Format(Messages.ACTION_DR_RECOVER_APPLIANCE_TITLE, XenObject.Name());
|
||||
UpdateStatus(RecoverState.NotRecovered, Messages.DR_WIZARD_RECOVERPAGE_STATUS_PENDING);
|
||||
@ -507,34 +500,29 @@ namespace XenAdmin.Wizards.DRWizards
|
||||
public DataGridViewRowRecover(string title)
|
||||
: this()
|
||||
{
|
||||
taskCell.Value = title;
|
||||
_taskCell.Value = title;
|
||||
UpdateStatus(RecoverState.NotRecovered, Messages.DR_WIZARD_RECOVERPAGE_STATUS_PENDING);
|
||||
}
|
||||
|
||||
public void UpdateStatus(RecoverState state, string value)
|
||||
{
|
||||
UpdateStatus(state, value, "");
|
||||
}
|
||||
|
||||
public void UpdateStatus(RecoverState state, string value, string toolTipText)
|
||||
public void UpdateStatus(RecoverState state, string value, string toolTipText = "")
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
case RecoverState.Recovered:
|
||||
imageCell.Value = Images.StaticImages._000_Tick_h32bit_16;
|
||||
_imageCell.Value = Images.StaticImages._000_Tick_h32bit_16;
|
||||
break;
|
||||
case RecoverState.Recovering:
|
||||
imageCell.Value = animatedImage;
|
||||
_imageCell.Value = animatedImage;
|
||||
break;
|
||||
case RecoverState.Error:
|
||||
imageCell.Value = Images.StaticImages._000_Abort_h32bit_16;
|
||||
_imageCell.Value = Images.StaticImages._000_Abort_h32bit_16;
|
||||
break;
|
||||
case RecoverState.NotRecovered:
|
||||
imageCell.Value = new Bitmap(1, 1);
|
||||
_imageCell.Value = new Bitmap(1, 1);
|
||||
break;
|
||||
}
|
||||
statusCell.Value = value;
|
||||
statusCell.ToolTipText = toolTipText;
|
||||
_statusCell.Value = value;
|
||||
_statusCell.ToolTipText = toolTipText;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user