当前位置: 首页>>代码示例>>C#>>正文


C# VM.HaPriorityIsRestart方法代码示例

本文整理汇总了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);
            }
        }
开发者ID:heiden-deng,项目名称:xenadmin,代码行数:58,代码来源:WlbOptimizePoolAction.cs


注:本文中的XenAPI.VM.HaPriorityIsRestart方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。