1
0
mirror of https://github.com/gryf/boxpy.git synced 2025-12-18 13:00:17 +01:00

Added info if vm is running.

Also, added command for acpi shutdown.
This commit is contained in:
2022-05-23 12:00:47 +02:00
parent 1c39cd1985
commit 38ed618b5b

7
box.py
View File

@@ -560,6 +560,7 @@ class VBoxManage:
self.name_or_uuid = name_or_uuid
self.vm_info = {}
self.uuid = None
self.running = False
def get_vm_base_path(self):
path = self._get_vm_config()
@@ -611,6 +612,9 @@ class VBoxManage:
if line.startswith('Config file:'):
self.vm_info['config_file'] = line.split('Config '
'file:')[1].strip()
if line.startswith('State:'):
self.running = line.split(':')[1].strip().startswith('running')
break
dom = xml.dom.minidom.parse(self.vm_info['config_file'])
@@ -654,6 +658,9 @@ class VBoxManage:
def poweroff(self):
Run(['vboxmanage', 'controlvm', self.name_or_uuid, 'poweroff'])
def acpipowerbutton(self):
Run(['vboxmanage', 'controlvm', self.name_or_uuid, 'acpipowerbutton'])
def vmlist(self, only_running=False, long_list=False, only_boxpy=False):
subcommand = 'runningvms' if only_running else 'vms'
machines = {}