From 3c9fb8dbacf262b3f3992c746d3886fc3a5f4487 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Thu, 20 Jul 2017 12:13:05 +0200 Subject: [PATCH] tools/qvm-volume: fix default action handling --- qubesadmin/tests/tools/qvm_volume.py | 15 +++++++++++++++ qubesadmin/tools/qvm_volume.py | 6 ++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/qubesadmin/tests/tools/qvm_volume.py b/qubesadmin/tests/tools/qvm_volume.py index de65951..cd77251 100644 --- a/qubesadmin/tests/tools/qvm_volume.py +++ b/qubesadmin/tests/tools/qvm_volume.py @@ -132,6 +132,21 @@ class TC_00_qvm_volume(qubesadmin.tests.QubesTestCase): ) self.assertAllCalled() + def test_005_list_default_action(self): + self.setup_expected_calls_for_list() + with qubesadmin.tests.tools.StdoutBuffer() as stdout: + self.assertEqual(0, + qubesadmin.tools.qvm_volume.main([], app=self.app)) + self.assertEqual(stdout.getvalue(), + 'POOL:VOLUME VMNAME VOLUME_NAME ' + 'REVERT_POSSIBLE\n' + 'other-pool:sys-net-private sys-net private Yes\n' + 'other-pool:vm1-private vm1 private Yes\n' + 'pool-file:sys-net-root sys-net root No\n' + 'pool-file:vm1-root vm1 root No\n' + ) + self.assertAllCalled() + def test_010_extend(self): self.app.expected_calls[('dom0', 'admin.vm.List', None, None)] = \ b'0\x00testvm class=AppVM state=Running\n' diff --git a/qubesadmin/tools/qvm_volume.py b/qubesadmin/tools/qvm_volume.py index fb1b168..e5e516d 100644 --- a/qubesadmin/tools/qvm_volume.py +++ b/qubesadmin/tools/qvm_volume.py @@ -95,7 +95,7 @@ def list_volumes(args): domains = app.domains volumes = [v for vm in domains for v in vm.volumes.values()] - if args.pools: + if getattr(args, 'pools', None): # only specified pools volumes = [v for v in volumes if v.pool in args.pools] @@ -126,7 +126,9 @@ def list_volumes(args): if x.domains] else: result = [x for p in vd_dict.values() for x in p.values()] - qubesadmin.tools.print_table(prepare_table(result, full=args.full)) + + qubesadmin.tools.print_table( + prepare_table(result, full=getattr(args, 'full', False))) def revert_volume(args):