So i've build a PowerShell based prototype to provide a simple webgui and rules engine with a similar approach and look and feel as the ESP nodes. They will communicate through MQTT, but the Windows node will also manage the nodelist updates using UDP messages.
So here is the first working prototype in action: Now i can control the Virtual machines that run on the Hyper-V hosts from a webpage button or from events using MQTT. So in theory an ESP unit could start or stop a Virtual Machine.
I also use another Windows Host to manage my secure email (TLS) and my PushOver messages (HTTPS). Running secure communications is a lot easier from Windows/PowerShell than native ESP and the ESP units just let the Windows Host send the alerts.
Not sure where this will end, but anyway it was fun to learn and build the prototype. I've used PowerShell a lot before, but now its even more easy to run and schedule scripts.
The rules engine will support some basic ESPEasy commands but i can also directly run native PowerShell from the rules engine like this:
Code: Select all
On webPrint do
webPrint
webPrint Role: Hyper-V host
webPrint <br>VM States:
webPrintcall Get-VM | where {$_.state -ne "Off"} | select name,state | ConvertTo-HTML -head ""
webPrint <table>
webPrint <tr><td>DC19<td><a class="button-link" href="/?group=windows&cmd=event suspendVM=DC19">Pause</a>
webPrint <td><a class="button-link" href="/?group=windows&cmd=event resumeVM=DC19">Resume</a>
webPrint <td><a class="button-link" href="/?group=windows&cmd=event startVM=DC19">Start</a>
webPrint <td><a class="button-link" href="/?group=windows&cmd=event shutdownVM=DC19">Stop</a>
webPrint <tr><td>SP19<td><a class="button-link" href="/?group=windows&cmd=event suspendVM=SP19">Pause</a>
webPrint <td><a class="button-link" href="/?group=windows&cmd=event resumeVM=SP19">Resume</a>
webPrint <td><a class="button-link" href="/?group=windows&cmd=event startVM=SP19">Start</a>
webPrint <td><a class="button-link" href="/?group=windows&cmd=event shutdownVM=SP19">Stop</a>
Endon
On SuspendVM do
call suspend-vm -name %eventpayload%
Endon
On ResumeVM do
call resume-vm -name %eventpayload%
Endon
On StartVM do
call start-vm -name %eventpayload%
Endon
On ShutdownVM do
call stop-vm -name %eventpayload%
Endon