如何使用php与vmware工作站安装主机关闭和唤醒虚拟机? [英] How to shutdown and wake up virtual machine by using php with vmware workstation installed host machine?

查看:148
本文介绍了如何使用php与vmware工作站安装主机关闭和唤醒虚拟机?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要明确的工作说明



我试过以下关闭主机并运行



系统('shutdown / p'); //对于主人

system('shutdown -s -m\\\​​\\192.168.1.4'); //对于vm

?>

i需要关闭已安装的虚拟机..虚拟机使用VMWARE网桥连接到我们的LAN网络。



谢谢!

I need clear working explanation

I tried the below to shutdown host machine and it works

system('shutdown /p' ); // for host
system('shutdown -s -m\\192.168.1.4' ); // for vm
?>
i need to shutdown installed vm's.. virtual machine are connected to our LAN network using VMWARE bridge.

Thanks!

推荐答案

我不知道你是否说关机有效,但是因为你问的是唤醒它们up ...



唤醒机器的方法是在网络上发送魔术包。这个魔术包被发送到广播地址,它包含的数据是6个字节的0xFF,并且是你想要唤醒的机器的MAC地址的16个重复。



以下是PHP套接字的参考: PHP套接字 [ ^ ]



以下是 Wake On LAN Magic Packet的数据 [ ^ ]。



但是,通过VMWare文档阅读,如果机器仅处于S1睡眠模式,则似乎只能使用WOL恢复虚拟机。断电或休眠的机器无法恢复。



另一种方法是创建一个脚本,将其放在远程vmware服务器上,并在你想要启动机器时运行它。您可能需要PowerShell才能执行此操作以及在远程计算机上执行脚本的权限。



出于好奇,为什么选择PHP?看起来像是更适合直接使用PowerShell脚本的东西,除非你试图通过网络界面做到这一点?
I can't tell if you are saying the shutdown works or not, but since you are asking about waking them up...

The way you wake up a machine is by sending a "magic packet" out on the network. This magic packet is sent to the broadcast address and the data it contains is 6 bytes of 0xFF and 16 repetitions of the MAC address of the machine you want to wake up.

Here is a reference on PHP sockets: PHP Sockets[^]

Here is data on the Wake On LAN Magic Packet[^].

However, reading through the VMWare documentation, it seems that the virtual machine can only be resumed using WOL if the machine is in the S1 sleep mode only. Powered off or hibernated machines cannot be resumed.

Another alternative is to make a script, place it on the remote vmware server and run that when you want to start the machine up. You will probably need powershell for this and permissions to execute scripts on the remote machine.

Out of curiosity, why PHP for this? Seems like something better suited to powershell scripting directly, unless you are trying to do this through a web interface?


这篇关于如何使用php与vmware工作站安装主机关闭和唤醒虚拟机?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆