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
This commit is contained in:
xfrnk2
2024-10-05 22:06:40 +09:00
committed by Beomseok Kim
parent 4f98ae3c61
commit c5d739269a
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)