diff --git a/debian/control b/debian/control index 6a9d1e13..4cb75513 100644 --- a/debian/control +++ b/debian/control @@ -42,6 +42,7 @@ Architecture: any Depends: python3-docutils, python3-lxml, + python3-qubesdb, python3-rpm, python3-tqdm, ${python3:Depends}, diff --git a/qubesadmin/app.py b/qubesadmin/app.py index 5c36fc08..987dbc5c 100644 --- a/qubesadmin/app.py +++ b/qubesadmin/app.py @@ -41,6 +41,12 @@ import qubesadmin.config import qubesadmin.devices +try: + import qubesdb + has_qubesdb = True +except ImportError: + has_qubesdb = False + class VMCollection(object): """Collection of VMs objects""" @@ -257,7 +263,18 @@ def remove_pool(self, name): def local_name(self): """ Get localhost name """ if not self._local_name: - self._local_name = os.uname()[1] + local_name = None + if has_qubesdb: + try: + local_qdb = qubesdb.QubesDB() + local_name_b = local_qdb.read('/name') + if local_name_b: + local_name = local_name_b.decode() + except qubesdb.Error: + pass + if local_name is None: + local_name = os.uname()[1] + self._local_name = local_name return self._local_name diff --git a/rpm_spec/qubes-core-admin-client.spec.in b/rpm_spec/qubes-core-admin-client.spec.in index 02b470e0..a0f279b2 100644 --- a/rpm_spec/qubes-core-admin-client.spec.in +++ b/rpm_spec/qubes-core-admin-client.spec.in @@ -39,6 +39,7 @@ Requires: python%{python3_pkgversion}-daemon Requires: python%{python3_pkgversion}-docutils Requires: python%{python3_pkgversion}-lxml Requires: python%{python3_pkgversion}-xcffib +Requires: python%{python3_pkgversion}-qubesdb Requires: python%{python3_pkgversion}-rpm Requires: python%{python3_pkgversion}-tqdm Requires: python%{python3_pkgversion}-pyxdg diff --git a/test-packages/qubesdb.py b/test-packages/qubesdb.py new file mode 100644 index 00000000..85ad9a10 --- /dev/null +++ b/test-packages/qubesdb.py @@ -0,0 +1,6 @@ +class QubesDB: + def read(self, key): + return b'testvm' + +class Error(Exception): + pass