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 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 ReportStarted;
|
||||||
public event Action<AsyncAction> ReportActionResultGot;
|
public event Action<AsyncAction> ReportActionResultGot;
|
||||||
public event Action<string, int, bool> ReportLineGot;
|
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)
|
private void onFrameChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -113,7 +118,7 @@ namespace XenAdmin.Wizards.DRWizards
|
|||||||
ImageAnimator.StopAnimate(animatedImage, onFrameChanged);
|
ImageAnimator.StopAnimate(animatedImage, onFrameChanged);
|
||||||
if (direction == PageLoadedDirection.Back)
|
if (direction == PageLoadedDirection.Back)
|
||||||
{
|
{
|
||||||
actions.Clear();
|
_actions.Clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,17 +166,17 @@ namespace XenAdmin.Wizards.DRWizards
|
|||||||
|
|
||||||
public DRWizardType WizardType { private get; set; }
|
public DRWizardType WizardType { private get; set; }
|
||||||
|
|
||||||
private Dictionary<VDI, List<AsyncAction>> actions = new Dictionary<VDI, List<AsyncAction>>();
|
internal List<string> RecoveredVmsUuids { get; } = new List<string>();
|
||||||
private int objectsToBeRecovered;
|
|
||||||
|
|
||||||
private StartActionAfterRecovery startActionAfterRecovery;
|
internal List<string> RecoveredVmAppliancesUuids { get; } = new List<string>();
|
||||||
public StartActionAfterRecovery StartActionAfterRecovery { set { startActionAfterRecovery = value; } }
|
|
||||||
|
public StartActionAfterRecovery StartActionAfterRecovery { private get; set; }
|
||||||
|
|
||||||
public Dictionary<XenRef<VDI>, PoolMetadata> SelectedPoolMetadata { private get; set; }
|
public Dictionary<XenRef<VDI>, PoolMetadata> SelectedPoolMetadata { private get; set; }
|
||||||
|
|
||||||
protected override void PageLoadedCore(PageLoadedDirection direction)
|
protected override void PageLoadedCore(PageLoadedDirection direction)
|
||||||
{
|
{
|
||||||
if (direction == PageLoadedDirection.Back || actions.Count > 0)
|
if (direction == PageLoadedDirection.Back || _actions.Count > 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ImageAnimator.Animate(animatedImage, onFrameChanged);
|
ImageAnimator.Animate(animatedImage, onFrameChanged);
|
||||||
@ -183,18 +188,18 @@ namespace XenAdmin.Wizards.DRWizards
|
|||||||
OnPageUpdated();
|
OnPageUpdated();
|
||||||
|
|
||||||
dataGridView1.Rows.Clear();
|
dataGridView1.Rows.Clear();
|
||||||
actions.Clear();
|
_actions.Clear();
|
||||||
objectsToBeRecovered = 0;
|
objectsToBeRecovered = 0;
|
||||||
|
|
||||||
// add "recovery" tasks
|
// add "recovery" tasks
|
||||||
foreach (var poolMetadata in SelectedPoolMetadata.Values)
|
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
|
// 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));
|
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);
|
labelOverallProgress.Text = string.Format(Messages.DR_WIZARD_RECOVERPAGE_OVERALL_PROGRESS, 0, dataGridView1.Rows.Count);
|
||||||
@ -242,9 +247,6 @@ namespace XenAdmin.Wizards.DRWizards
|
|||||||
return subActions;
|
return subActions;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal List<string> RecoveredVmsUuids = new List<string>();
|
|
||||||
internal List<string> RecoveredVmAppliancesUuids = new List<string>();
|
|
||||||
|
|
||||||
private void SingleRecoverActionCompleted(ActionBase sender)
|
private void SingleRecoverActionCompleted(ActionBase sender)
|
||||||
{
|
{
|
||||||
DrRecoverAction senderAction = (DrRecoverAction)sender;
|
DrRecoverAction senderAction = (DrRecoverAction)sender;
|
||||||
@ -297,10 +299,6 @@ namespace XenAdmin.Wizards.DRWizards
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private MultipleAction multipleRecoverAction;
|
|
||||||
private Session metadataSession;
|
|
||||||
|
|
||||||
private void OpenDatabaseActionCompleted(ActionBase sender)
|
private void OpenDatabaseActionCompleted(ActionBase sender)
|
||||||
{
|
{
|
||||||
VdiOpenDatabaseAction senderAction = (VdiOpenDatabaseAction)sender;
|
VdiOpenDatabaseAction senderAction = (VdiOpenDatabaseAction)sender;
|
||||||
@ -314,7 +312,7 @@ namespace XenAdmin.Wizards.DRWizards
|
|||||||
|
|
||||||
// assign metadata session to all recover actions
|
// assign metadata session to all recover actions
|
||||||
List<AsyncAction> recoverSubActions = new List<AsyncAction>();
|
List<AsyncAction> recoverSubActions = new List<AsyncAction>();
|
||||||
foreach (var action in actions[senderAction.Vdi])
|
foreach (var action in _actions[senderAction.Vdi])
|
||||||
{
|
{
|
||||||
if (action is DrRecoverAction)
|
if (action is DrRecoverAction)
|
||||||
{
|
{
|
||||||
@ -345,7 +343,7 @@ namespace XenAdmin.Wizards.DRWizards
|
|||||||
{
|
{
|
||||||
if (objectsToBeRecovered == 0) // finished recovering, now start VMs, if required
|
if (objectsToBeRecovered == 0) // finished recovering, now start VMs, if required
|
||||||
{
|
{
|
||||||
switch (startActionAfterRecovery)
|
switch (StartActionAfterRecovery)
|
||||||
{
|
{
|
||||||
case StartActionAfterRecovery.Start :
|
case StartActionAfterRecovery.Start :
|
||||||
StartRecoveredVMs(false);
|
StartRecoveredVMs(false);
|
||||||
@ -369,7 +367,7 @@ namespace XenAdmin.Wizards.DRWizards
|
|||||||
|
|
||||||
private void RecoverNextPool()
|
private void RecoverNextPool()
|
||||||
{
|
{
|
||||||
foreach (var actionList in actions.Values)
|
foreach (var actionList in _actions.Values)
|
||||||
{
|
{
|
||||||
bool startRecovery = false;
|
bool startRecovery = false;
|
||||||
foreach (var action in actionList)
|
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);
|
var action = new StartVMsAndAppliancesAction(Connection, vmsToStart, vmAppliancesToStart, VMOperationCommand.WarningDialogHAInvalidConfig, VMOperationCommand.StartDiagnosisForm, paused);
|
||||||
if (action != null)
|
action.Completed += StartVMsActionCompleted;
|
||||||
{
|
action.Changed += StartVMsActionChanged;
|
||||||
action.Completed += StartVMsActionCompleted;
|
action.RunAsync();
|
||||||
action.Changed += StartVMsActionChanged;
|
|
||||||
action.RunAsync();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void StartVMsActionChanged(ActionBase sender)
|
private void StartVMsActionChanged(ActionBase sender)
|
||||||
@ -483,22 +478,20 @@ namespace XenAdmin.Wizards.DRWizards
|
|||||||
public class DataGridViewRowRecover : DataGridViewRow
|
public class DataGridViewRowRecover : DataGridViewRow
|
||||||
{
|
{
|
||||||
public readonly IXenObject XenObject; // it can be VM or VM_appliance
|
public readonly IXenObject XenObject; // it can be VM or VM_appliance
|
||||||
private DataGridViewImageCell imageCell = new DataGridViewImageCell();
|
private readonly DataGridViewImageCell _imageCell = new DataGridViewImageCell();
|
||||||
private DataGridViewTextBoxCell taskCell = new DataGridViewTextBoxCell();
|
private readonly DataGridViewTextBoxCell _taskCell = new DataGridViewTextBoxCell();
|
||||||
private DataGridViewTextBoxCell statusCell = new DataGridViewTextBoxCell();
|
private readonly DataGridViewTextBoxCell _statusCell = new DataGridViewTextBoxCell();
|
||||||
|
|
||||||
private DataGridViewRowRecover()
|
private DataGridViewRowRecover()
|
||||||
{
|
{
|
||||||
this.Cells.Add(taskCell);
|
this.Cells.AddRange(_taskCell, _imageCell, _statusCell);
|
||||||
this.Cells.Add(imageCell);
|
|
||||||
this.Cells.Add(statusCell);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataGridViewRowRecover(IXenObject xenObject)
|
public DataGridViewRowRecover(IXenObject xenObject)
|
||||||
: this()
|
: this()
|
||||||
{
|
{
|
||||||
XenObject = xenObject;
|
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_VM_TITLE, XenObject.Name())
|
||||||
: string.Format(Messages.ACTION_DR_RECOVER_APPLIANCE_TITLE, XenObject.Name());
|
: string.Format(Messages.ACTION_DR_RECOVER_APPLIANCE_TITLE, XenObject.Name());
|
||||||
UpdateStatus(RecoverState.NotRecovered, Messages.DR_WIZARD_RECOVERPAGE_STATUS_PENDING);
|
UpdateStatus(RecoverState.NotRecovered, Messages.DR_WIZARD_RECOVERPAGE_STATUS_PENDING);
|
||||||
@ -507,34 +500,29 @@ namespace XenAdmin.Wizards.DRWizards
|
|||||||
public DataGridViewRowRecover(string title)
|
public DataGridViewRowRecover(string title)
|
||||||
: this()
|
: this()
|
||||||
{
|
{
|
||||||
taskCell.Value = title;
|
_taskCell.Value = title;
|
||||||
UpdateStatus(RecoverState.NotRecovered, Messages.DR_WIZARD_RECOVERPAGE_STATUS_PENDING);
|
UpdateStatus(RecoverState.NotRecovered, Messages.DR_WIZARD_RECOVERPAGE_STATUS_PENDING);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateStatus(RecoverState state, string value)
|
public void UpdateStatus(RecoverState state, string value, string toolTipText = "")
|
||||||
{
|
|
||||||
UpdateStatus(state, value, "");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void UpdateStatus(RecoverState state, string value, string toolTipText)
|
|
||||||
{
|
{
|
||||||
switch (state)
|
switch (state)
|
||||||
{
|
{
|
||||||
case RecoverState.Recovered:
|
case RecoverState.Recovered:
|
||||||
imageCell.Value = Images.StaticImages._000_Tick_h32bit_16;
|
_imageCell.Value = Images.StaticImages._000_Tick_h32bit_16;
|
||||||
break;
|
break;
|
||||||
case RecoverState.Recovering:
|
case RecoverState.Recovering:
|
||||||
imageCell.Value = animatedImage;
|
_imageCell.Value = animatedImage;
|
||||||
break;
|
break;
|
||||||
case RecoverState.Error:
|
case RecoverState.Error:
|
||||||
imageCell.Value = Images.StaticImages._000_Abort_h32bit_16;
|
_imageCell.Value = Images.StaticImages._000_Abort_h32bit_16;
|
||||||
break;
|
break;
|
||||||
case RecoverState.NotRecovered:
|
case RecoverState.NotRecovered:
|
||||||
imageCell.Value = new Bitmap(1, 1);
|
_imageCell.Value = new Bitmap(1, 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
statusCell.Value = value;
|
_statusCell.Value = value;
|
||||||
statusCell.ToolTipText = toolTipText;
|
_statusCell.ToolTipText = toolTipText;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user