tools/qvm-ls: add --raw-list option for compatibility with R3.2
There was an option to list just VM names, useful for scripting. Preserve that for compatibility.
This commit is contained in:
parent
0533703ddf
commit
080b563ae2
@ -23,6 +23,15 @@ Options
|
|||||||
|
|
||||||
List all available formats with their definitions and exit.
|
List all available formats with their definitions and exit.
|
||||||
|
|
||||||
|
.. option:: --all
|
||||||
|
|
||||||
|
List all qubes, this is default.
|
||||||
|
|
||||||
|
.. option:: --exclude
|
||||||
|
|
||||||
|
Exclude the qube from --all. You need to use --all option explicitly to use
|
||||||
|
--exclude.
|
||||||
|
|
||||||
.. option:: --format=FORMAT, -o FORMAT
|
.. option:: --format=FORMAT, -o FORMAT
|
||||||
|
|
||||||
Sets format to a list of columns defined by preset. All formats along with
|
Sets format to a list of columns defined by preset. All formats along with
|
||||||
@ -39,6 +48,11 @@ Options
|
|||||||
Output data in easy to parse format. Table header is skipped and columns are
|
Output data in easy to parse format. Table header is skipped and columns are
|
||||||
separated by `|` character.
|
separated by `|` character.
|
||||||
|
|
||||||
|
.. option:: --raw-list
|
||||||
|
|
||||||
|
Give plain list of VM names, without header or separator. Useful in scripts.
|
||||||
|
Same as --raw-data --fields=name
|
||||||
|
|
||||||
.. option:: --verbose, -v
|
.. option:: --verbose, -v
|
||||||
|
|
||||||
Increase verbosity.
|
Increase verbosity.
|
||||||
|
@ -112,6 +112,14 @@ class TC_50_List(qubesadmin.tests.QubesTestCase):
|
|||||||
'NAME STATE CLASS LABEL TEMPLATE NETVM\n'
|
'NAME STATE CLASS LABEL TEMPLATE NETVM\n'
|
||||||
'test-vm Running TestVM green template sys-net\n')
|
'test-vm Running TestVM green template sys-net\n')
|
||||||
|
|
||||||
|
def test_102_raw_list(self):
|
||||||
|
app = TestApp()
|
||||||
|
with qubesadmin.tests.tools.StdoutBuffer() as stdout:
|
||||||
|
qubesadmin.tools.qvm_ls.main(['--raw-list'], app=app)
|
||||||
|
self.assertEqual(stdout.getvalue(),
|
||||||
|
'dom0\n'
|
||||||
|
'test-vm\n')
|
||||||
|
|
||||||
|
|
||||||
class TC_90_List_with_qubesd_calls(qubesadmin.tests.QubesTestCase):
|
class TC_90_List_with_qubesd_calls(qubesadmin.tests.QubesTestCase):
|
||||||
def test_100_list_with_status(self):
|
def test_100_list_with_status(self):
|
||||||
|
@ -539,6 +539,10 @@ def get_parser():
|
|||||||
action='store_false', dest='spinner',
|
action='store_false', dest='spinner',
|
||||||
help='disable spinner')
|
help='disable spinner')
|
||||||
|
|
||||||
|
# shortcuts, compatibility with Qubes 3.2
|
||||||
|
parser.add_argument('--raw-list', action='store_true',
|
||||||
|
help='Same as --raw-data --fields=name')
|
||||||
|
|
||||||
parser.set_defaults(spinner=True)
|
parser.set_defaults(spinner=True)
|
||||||
|
|
||||||
# parser.add_argument('--conf', '-c',
|
# parser.add_argument('--conf', '-c',
|
||||||
@ -563,6 +567,10 @@ def main(args=None, app=None):
|
|||||||
parser.print_error(str(e))
|
parser.print_error(str(e))
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
if args.raw_list:
|
||||||
|
args.raw_data = True
|
||||||
|
args.fields = 'name'
|
||||||
|
|
||||||
if args.fields:
|
if args.fields:
|
||||||
columns = [col.strip() for col in args.fields.split(',')]
|
columns = [col.strip() for col in args.fields.split(',')]
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user