Merge "Activate the --long option for recordset list command"

This commit is contained in:
Zuul
2025-04-14 22:24:15 +00:00
committed by Gerrit Code Review
2 changed files with 30 additions and 0 deletions

View File

@@ -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)

View File

@@ -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)