mirror of
https://github.com/gryf/boxpy.git
synced 2025-12-19 05:30:18 +01:00
Added info if vm is running.
Also, added command for acpi shutdown.
This commit is contained in:
7
box.py
7
box.py
@@ -560,6 +560,7 @@ class VBoxManage:
|
|||||||
self.name_or_uuid = name_or_uuid
|
self.name_or_uuid = name_or_uuid
|
||||||
self.vm_info = {}
|
self.vm_info = {}
|
||||||
self.uuid = None
|
self.uuid = None
|
||||||
|
self.running = False
|
||||||
|
|
||||||
def get_vm_base_path(self):
|
def get_vm_base_path(self):
|
||||||
path = self._get_vm_config()
|
path = self._get_vm_config()
|
||||||
@@ -611,6 +612,9 @@ class VBoxManage:
|
|||||||
if line.startswith('Config file:'):
|
if line.startswith('Config file:'):
|
||||||
self.vm_info['config_file'] = line.split('Config '
|
self.vm_info['config_file'] = line.split('Config '
|
||||||
'file:')[1].strip()
|
'file:')[1].strip()
|
||||||
|
|
||||||
|
if line.startswith('State:'):
|
||||||
|
self.running = line.split(':')[1].strip().startswith('running')
|
||||||
break
|
break
|
||||||
|
|
||||||
dom = xml.dom.minidom.parse(self.vm_info['config_file'])
|
dom = xml.dom.minidom.parse(self.vm_info['config_file'])
|
||||||
@@ -654,6 +658,9 @@ class VBoxManage:
|
|||||||
def poweroff(self):
|
def poweroff(self):
|
||||||
Run(['vboxmanage', 'controlvm', self.name_or_uuid, 'poweroff'])
|
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):
|
def vmlist(self, only_running=False, long_list=False, only_boxpy=False):
|
||||||
subcommand = 'runningvms' if only_running else 'vms'
|
subcommand = 'runningvms' if only_running else 'vms'
|
||||||
machines = {}
|
machines = {}
|
||||||
|
|||||||
Reference in New Issue
Block a user