如何从 Linux 计算机挂起 Hyper-V VM?
我在运行 Ubuntu 的计算机上设置了一个 NMS 系统,该系统通过调用 Perl 脚本来遍历所有 VMWare 主机并挂起所有 VM 来响应各种 UPS 事件。 VMWare 很聪明,提供了一组 Perl 模块,这使得这变得相对容易。然而,我们还有三台 Hyper-V 主机,但我似乎找不到一种非特定于某些 Microsoft 技术(例如 PowerShell 脚本)的方法来控制它们。
我希望有人能建议一种从 Linux 机器控制 Hyper-V 主机的方法。我宁愿它不涉及使用 Wine,但如果没有其他可行的方法,我愿意走这条路。
I've set up an NMS system on a machine running Ubuntu that responds to various UPS events by calling a Perl script to go through all of our VMWare hosts and suspend all of the VMs. VMWare was smart and provided a set of Perl modules which made this relatively easy. We also have three Hyper-V hosts, however, and I can't seem to find a way to control them that isn't specific to some Microsoft technology (e.g. a PowerShell script).
I'm hoping somebody could suggest a way to control the Hyper-V hosts from a linux box. I'd rather it didn't involve using Wine, but I'm willing to go that route if there's nothing else that will work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我发现了一种丑陋的方法来做到这一点,但至少它不需要在虚拟机主机上安装或配置任何东西。
首先,我得到了一个名为 winexe 的实用程序,它可以让您打开到窗户机器。
然后我编写了一个长而难看的 Perl 脚本,将一些 PowerShell 代码通过管道传输到机器以暂停任何正在运行的机器:
您可能需要对此进行一些修改才能使其正常工作。我必须破解一些特定于实现的东西,但我留下了部分输出捕获代码。这需要名为 $win_user 和 $win_pass 的全局变量,其中包含目标 VM 主机的管理员帐户登录信息。它还要求您
使用 IPC::Run
。I found an ugly way to do it, but at least it doesn't require anything to be installed or configured on the VM host.
First I got a utility called winexe, which lets you open a terminal connection to a windows machine.
Then I wrote a long an ugly Perl script to pipe some PowerShell code to the machine to suspend any running machines:
You might have to mess with this a bit to get it to work. I had to hack out some of the implementation-specific things, but I left in part of the output capturing code. This requires global variables named $win_user and $win_pass containing administrator account login info for the target VM host. It also requires that you
use IPC::Run
.Hyper-V 可以使用 WMI 界面进行远程管理。 Linux 上有一个 WMI 客户端,它应该允许您进行相关的 API 调用来管理 Hyper-V。我不必自己执行此操作,但 Microsoft 提供了特定的 WMI 调用:https://msdn.microsoft.com/en-us/library/hh850319%28v=vs.85%29.aspx
Hyper-V can be managed remotely using the WMI interfaces. There is a WMI Client for Linux, which should allow you to make the relevant API calls to manage Hyper-V. I have not had to do this myself, but the specific WMI calls are available at Microsoft: https://msdn.microsoft.com/en-us/library/hh850319%28v=vs.85%29.aspx