本文整理汇总了C#中XenAPI.VM.HaPriorityIsRestart方法的典型用法代码示例。如果您正苦于以下问题:C# VM.HaPriorityIsRestart方法的具体用法?C# VM.HaPriorityIsRestart怎么用?C# VM.HaPriorityIsRestart使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XenAPI.VM
的用法示例。
在下文中一共展示了VM.HaPriorityIsRestart方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RelocateVmWithHa
private void RelocateVmWithHa(AsyncAction action, VM vm, Host host, int start, int end, int recommendationId)
{
bool setDoNotRestart = false;
if (vm.HaPriorityIsRestart())
{
try
{
XenAPI.VM.assert_agile(action.Session, vm.opaque_ref);
}
catch (Failure)
{
// VM is not agile, but it is 'Protected' by HA. This is an inconsistent state (see CA-20820).
// Tell the user the VM will be started without HA protection.
Program.Invoke(Program.MainWindow, delegate()
{
new ThreeButtonDialog(
new ThreeButtonDialog.Details(
SystemIcons.Warning,
String.Format(Messages.HA_INVALID_CONFIG_RESUME, Helpers.GetName(vm).Ellipsise(500)),
Messages.HIGH_AVAILABILITY)).ShowDialog(Program.MainWindow);
});
// Set the VM to 'Do not restart'.
XenAPI.VM.set_ha_restart_priority(action.Session, vm.opaque_ref, XenAPI.VM.RESTART_PRIORITY_DO_NOT_RESTART);
setDoNotRestart = true;
}
}
if (!setDoNotRestart && vm.HasSavedRestartPriority)
{
// If HA is turned on, setting ha_always_run will cause the VM to be started by itself
// but when the VM fails to start we want to know why, so we do a VM.start here too.
// This will fail with a power state exception if HA has already started the VM - but in
// that case we don't care, since the VM successfully started already.
SetHaProtection(true, action, vm, start, end);
try
{
DoAction(action, vm, host, start, end, recommendationId);
}
catch (Failure f)
{
if (f.ErrorDescription.Count == 4 && f.ErrorDescription[0] == Failure.VM_BAD_POWER_STATE && f.ErrorDescription[3] == "running")
{
// The VM started successfully via HA
}
else
{
throw;
}
}
}
else
{
// HA off: just do a regular start
DoAction(action, vm, host, start, end, recommendationId);
}
}