vm: add/fix lifecycle-related methods

This commit is contained in:
Marek Marczykowski-Górecki 2017-04-15 14:22:30 +02:00
parent e066656903
commit 914c2d7e5e
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -167,9 +167,38 @@ class QubesVM(qubesmgmt.base.PropertyHolder):
vm_list_info = self.qubesd_call(
self._method_dest, 'mgmt.vm.List', None, None).decode('ascii')
# name class=... state=... other=...
vm_state = vm_list_info.partition('state=')[2].split(' ')[0]
vm_state = vm_list_info.strip().partition('state=')[2].split(' ')[0]
return vm_state
def is_halted(self):
''' Check whether this domain's state is 'Halted'
:returns: :py:obj:`True` if this domain is halted, \
:py:obj:`False` otherwise.
:rtype: bool
'''
return self.get_power_state() == 'Halted'
def is_paused(self):
'''Check whether this domain is paused.
:returns: :py:obj:`True` if this domain is paused, \
:py:obj:`False` otherwise.
:rtype: bool
'''
return self.get_power_state() == 'Paused'
def is_running(self):
'''Check whether this domain is running.
:returns: :py:obj:`True` if this domain is started, \
:py:obj:`False` otherwise.
:rtype: bool
'''
return self.get_power_state() != 'Halted'
@property
def volumes(self):
'''VM disk volumes'''