app: switch get_local_name method to property
This commit is contained in:
parent
f7740546c9
commit
03bc15dd38
@ -153,8 +153,6 @@ class QubesBase(qubesadmin.base.PropertyHolder):
|
||||
log = None
|
||||
#: do not check for object (VM, label etc) existence before really needed
|
||||
blind_mode = False
|
||||
#: local name
|
||||
local_name = None
|
||||
|
||||
def __init__(self):
|
||||
super(QubesBase, self).__init__(self, 'admin.property.', 'dom0')
|
||||
@ -166,6 +164,7 @@ class QubesBase(qubesadmin.base.PropertyHolder):
|
||||
#: cache for available storage pool drivers and options to create them
|
||||
self._pool_drivers = None
|
||||
self.log = logging.getLogger('app')
|
||||
self._local_name = None
|
||||
|
||||
def list_vmclass(self):
|
||||
"""Call Qubesd in order to obtain the vm classes list"""
|
||||
@ -228,12 +227,13 @@ class QubesBase(qubesadmin.base.PropertyHolder):
|
||||
""" Remove a storage pool """
|
||||
self.qubesd_call('dom0', 'admin.pool.Remove', name, None)
|
||||
|
||||
def get_local_name(self):
|
||||
@property
|
||||
def local_name(self):
|
||||
""" Get localhost name """
|
||||
if not self.local_name:
|
||||
self.local_name = os.uname()[1]
|
||||
if not self._local_name:
|
||||
self._local_name = os.uname()[1]
|
||||
|
||||
return self.local_name
|
||||
return self._local_name
|
||||
|
||||
def get_label(self, label):
|
||||
"""Get label as identified by index or name
|
||||
|
@ -399,7 +399,7 @@ class TC_00_qvm_start_gui(qubesadmin.tests.QubesTestCase):
|
||||
('test-vm', 'admin.vm.property.Get', 'guivm', None)] = \
|
||||
b'0\x00default=False type=vm gui-vm'
|
||||
|
||||
self.app.local_name = 'gui-vm'
|
||||
self.app._local_name = 'gui-vm'
|
||||
vm = self.app.domains['test-vm']
|
||||
mock_start_vm = unittest.mock.Mock()
|
||||
mock_start_stubdomain = unittest.mock.Mock()
|
||||
@ -681,7 +681,7 @@ HDMI1 connected 2560x1920+0+0 (normal left inverted right x axis y axis) 206mm x
|
||||
('test-vm4', 'admin.vm.property.Get', 'guivm', None)] = \
|
||||
b'0\x00default=False type=vm gui-vm'
|
||||
|
||||
self.app.local_name = 'gui-vm'
|
||||
self.app._local_name = 'gui-vm'
|
||||
|
||||
vm = self.app.domains['test-vm']
|
||||
vm2 = self.app.domains['test-vm2']
|
||||
|
@ -253,7 +253,7 @@ class GUILauncher(object):
|
||||
:param monitor_layout: monitor layout configuration
|
||||
"""
|
||||
guivm = getattr(vm, 'guivm', None)
|
||||
if guivm != vm.app.get_local_name():
|
||||
if guivm != vm.app.local_name:
|
||||
vm.log.info('GUI connected to {}. Skipping.'.format(guivm))
|
||||
return
|
||||
|
||||
@ -316,7 +316,7 @@ class GUILauncher(object):
|
||||
"""Send monitor layout to all (running) VMs"""
|
||||
monitor_layout = get_monitor_layout()
|
||||
for vm in self.app.domains:
|
||||
if getattr(vm, 'guivm', None) != vm.app.get_local_name():
|
||||
if getattr(vm, 'guivm', None) != vm.app.local_name:
|
||||
continue
|
||||
if vm.klass == 'AdminVM':
|
||||
continue
|
||||
@ -329,7 +329,7 @@ class GUILauncher(object):
|
||||
def on_domain_spawn(self, vm, _event, **kwargs):
|
||||
"""Handler of 'domain-spawn' event, starts GUI daemon for stubdomain"""
|
||||
try:
|
||||
if getattr(vm, 'guivm', None) != vm.app.get_local_name():
|
||||
if getattr(vm, 'guivm', None) != vm.app.local_name:
|
||||
return
|
||||
if not vm.features.check_with_template('gui', True):
|
||||
return
|
||||
@ -342,7 +342,7 @@ class GUILauncher(object):
|
||||
def on_domain_start(self, vm, _event, **kwargs):
|
||||
"""Handler of 'domain-start' event, starts GUI daemon for actual VM"""
|
||||
try:
|
||||
if getattr(vm, 'guivm', None) != vm.app.get_local_name():
|
||||
if getattr(vm, 'guivm', None) != vm.app.local_name:
|
||||
return
|
||||
if not vm.features.check_with_template('gui', True):
|
||||
return
|
||||
@ -360,7 +360,7 @@ class GUILauncher(object):
|
||||
for vm in self.app.domains:
|
||||
if vm.klass == 'AdminVM':
|
||||
continue
|
||||
if getattr(vm, 'guivm', None) != vm.app.get_local_name():
|
||||
if getattr(vm, 'guivm', None) != vm.app.local_name:
|
||||
continue
|
||||
if not vm.features.check_with_template('gui', True):
|
||||
continue
|
||||
|
Loading…
Reference in New Issue
Block a user