Browse Source

Merge remote-tracking branch 'origin/pr/123'

* origin/pr/123:
  Add test for qvm-ls --all
  qvm-ls: don't exclude dom0 when using --all
Marek Marczykowski-Górecki 4 years ago
parent
commit
de1969150d
2 changed files with 18 additions and 1 deletions
  1. 10 1
      qubesadmin/tests/tools/qvm_ls.py
  2. 8 0
      qubesadmin/tools/qvm_ls.py

+ 10 - 1
qubesadmin/tests/tools/qvm_ls.py

@@ -120,7 +120,16 @@ class TC_50_List(qubesadmin.tests.QubesTestCase):
             'dom0\n'
             'test-vm\n')
 
-    def test_103_network_tree(self):
+    def test_103_list_all(self):
+        app = TestApp()
+        with qubesadmin.tests.tools.StdoutBuffer() as stdout:
+            qubesadmin.tools.qvm_ls.main(['--all'], app=app)
+        self.assertEqual(stdout.getvalue(),
+            'NAME     STATE    CLASS   LABEL  TEMPLATE  NETVM\n'
+            'dom0     Running  TestVM  -      -         -\n'
+            'test-vm  Running  TestVM  -      -         -\n')
+
+    def test_110_network_tree(self):
         app = TestApp()
         app.domains = TestVMCollection(
             [

+ 8 - 0
qubesadmin/tools/qvm_ls.py

@@ -690,6 +690,14 @@ def main(args=None, app=None):
     else:
         domains = args.app.domains
 
+    if args.all_domains:
+        # Normally, --all means "all domains except for AdminVM".
+        # However, in the case of qvm-ls it does not make sense to exclude
+        # AdminVMs, so we override the list from parser.
+        domains = [
+            vm for vm in args.app.domains if vm.name not in args.exclude
+        ]
+
     if args.tags:
         # filter only VMs having at least one of the specified tags
         domains = [dom for dom in domains