Skip to content

Commit

Permalink
config: eliminate duplicated qubes_base_dir
Browse files Browse the repository at this point in the history
Remove it from system_path dict, have it in one place.
  • Loading branch information
marmarek committed Jul 4, 2017
1 parent 317d140 commit 075d991
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion qubes/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ def __init__(self, store=None, load=True, offline_mode=None, lock=False,
else:
self._store = os.environ.get('QUBES_XML_PATH',
os.path.join(
qubes.config.system_path['qubes_base_dir'],
qubes.config.qubes_base_dir,
qubes.config.system_path['qubes_store_filename']))

super(Qubes, self).__init__(xml=None, **kwargs)
Expand Down
2 changes: 0 additions & 2 deletions qubes/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@
'qrexec_client_path': '/usr/lib/qubes/qrexec-client',
'qubesdb_daemon_path': '/usr/sbin/qubesdb-daemon',

'qubes_base_dir': qubes_base_dir,

# Relative to qubes_base_dir
'qubes_appvms_dir': 'appvms',
'qubes_templates_dir': 'vm-templates',
Expand Down
6 changes: 3 additions & 3 deletions qubes/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ def setUp(self):
# need some information from the real qubes.xml - at least installed
# templates; should not be used for testing, only to initialize self.app
self.host_app = qubes.Qubes(os.path.join(
qubes.config.system_path['qubes_base_dir'],
qubes.config.qubes_base_dir,
qubes.config.system_path['qubes_store_filename']))
if os.path.exists(CLASS_XMLPATH):
shutil.copy(CLASS_XMLPATH, XMLPATH)
Expand Down Expand Up @@ -727,7 +727,7 @@ def _remove_vm_disk(vmname):
'qubes_appvms_dir',
'qubes_servicevms_dir',
'qubes_templates_dir'):
dirpath = os.path.join(qubes.config.system_path['qubes_base_dir'],
dirpath = os.path.join(qubes.config.qubes_base_dir,
qubes.config.system_path[dirspec], vmname)
if os.path.exists(dirpath):
if os.path.isdir(dirpath):
Expand Down Expand Up @@ -791,7 +791,7 @@ def remove_test_vms(cls, xmlpath=XMLPATH, prefix=VMPREFIX):
'qubes_appvms_dir',
'qubes_servicevms_dir',
'qubes_templates_dir'):
dirpath = os.path.join(qubes.config.system_path['qubes_base_dir'],
dirpath = os.path.join(qubes.config.qubes_base_dir,
qubes.config.system_path[dirspec])
for name in os.listdir(dirpath):
if name.startswith(prefix):
Expand Down
6 changes: 3 additions & 3 deletions qubes/tests/storage_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,8 @@ class TC_03_FilePool(qubes.tests.QubesTestCase):
def setUp(self):
""" Add a test file based storage pool """
super(TC_03_FilePool, self).setUp()
self._orig_qubes_base_dir = qubes.config.system_path['qubes_base_dir']
qubes.config.system_path['qubes_base_dir'] = '/tmp/qubes-test'
self._orig_qubes_base_dir = qubes.config.qubes_base_dir
qubes.config.qubes_base_dir = '/tmp/qubes-test'
self.app = TestApp()
self.app.create_dummy_template()
self.app.add_pool(**self.POOL_CONFIG)
Expand All @@ -320,7 +320,7 @@ def tearDown(self):
shutil.rmtree(self.POOL_DIR, ignore_errors=True)
if os.path.exists('/tmp/qubes-test'):
shutil.rmtree('/tmp/qubes-test')
qubes.config.system_path['qubes_base_dir'] = self._orig_qubes_base_dir
qubes.config.qubes_base_dir = self._orig_qubes_base_dir

def test_001_pool_exists(self):
""" Check if the storage pool was added to the storage pool config """
Expand Down
4 changes: 2 additions & 2 deletions qubes/vm/qubesvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ def qdb(self):
def dir_path(self):
'''Root directory for files related to this domain'''
return os.path.join(
qubes.config.system_path['qubes_base_dir'],
qubes.config.qubes_base_dir,
self.dir_path_prefix,
self.name)

Expand Down Expand Up @@ -716,7 +716,7 @@ def on_property_pre_set_kernel(self, event, name, newvalue, oldvalue=None):
if not newvalue:
return
dirname = os.path.join(
qubes.config.system_path['qubes_base_dir'],
qubes.config.qubes_base_dir,
qubes.config.system_path['qubes_kernels_base_dir'],
newvalue)
if not os.path.exists(dirname):
Expand Down

0 comments on commit 075d991

Please sign in to comment.