From c5d739269adaa2036f52786ba5af7e6ba69dbe77 Mon Sep 17 00:00:00 2001 From: xfrnk2 Date: Sat, 5 Oct 2024 22:06:40 +0900 Subject: [PATCH] Activate the --long option for recordset list command Activate the --long option for openstack recordset list command When this option is used, additional columns and values are displayed. The new columns are ttl, version, and description. Add test code for the new columns. Change-Id: I69f15bc56cc0f637c66ad975d8019757adfab038 --- .../tests/osc/v2/test_recordsets.py | 20 +++++++++++++++++++ designateclient/v2/cli/recordsets.py | 10 ++++++++++ 2 files changed, 30 insertions(+) diff --git a/designateclient/tests/osc/v2/test_recordsets.py b/designateclient/tests/osc/v2/test_recordsets.py index 1a8eba86..53e5fc06 100644 --- a/designateclient/tests/osc/v2/test_recordsets.py +++ b/designateclient/tests/osc/v2/test_recordsets.py @@ -96,3 +96,23 @@ class TestDesignateListRecordSets(utils.TestCommand): results = list(data) self.assertEqual(5, len(results)) + + def test_list_recordsets_with_long_option(self): + + arg_list = ['6f106adb-0896-4114-b34f-4ac8dfee9465', '--long'] + verify_args = [ + ('zone_id', '6f106adb-0896-4114-b34f-4ac8dfee9465'), + ('long', True) + ] + + body = resources.load('recordset_list') + result = base.DesignateList() + result.extend(body['recordsets']) + self.dns_client.recordsets.list.return_value = result + + parsed_args = self.check_parser(self.cmd, arg_list, verify_args) + columns, data = self.cmd.take_action(parsed_args) + + self.assertIn('ttl', columns) + self.assertIn('version', columns) + self.assertIn('description', columns) diff --git a/designateclient/v2/cli/recordsets.py b/designateclient/v2/cli/recordsets.py index e571aa17..1147abcd 100644 --- a/designateclient/v2/cli/recordsets.py +++ b/designateclient/v2/cli/recordsets.py @@ -64,6 +64,13 @@ class ListRecordSetsCommand(command.Lister): parser.add_argument('zone_id', help="Zone ID. To list all" " recordsets specify 'all'") + parser.add_argument( + '--long', + help='List additional fields in output', + default=False, + action='store_true', + required=False + ) common.add_all_common_options(parser) @@ -108,6 +115,9 @@ class ListRecordSetsCommand(command.Lister): if client.session.all_projects and _has_project_id(data): cols.insert(1, 'project_id') + if parsed_args.long: + cols += ['ttl', 'version', 'description'] + for i, rs in enumerate(data): data[i] = _format_recordset(rs)