Merge "Show project_id field when xyz-list with global-project"
This commit is contained in:
commit
7c05b0c7d1
senlinclient
@ -120,7 +120,7 @@ class ShellTest(testtools.TestCase):
|
||||
service = mock.Mock()
|
||||
profiles = mock.Mock()
|
||||
service.profiles.return_value = profiles
|
||||
fields = ['id', 'name', 'type', 'created_at']
|
||||
fields = ['id', 'name', 'type', 'created_at', 'project_id']
|
||||
args = {
|
||||
'limit': 20,
|
||||
'marker': 'mark_id',
|
||||
@ -1383,7 +1383,7 @@ class ShellTest(testtools.TestCase):
|
||||
def test_do_node_list(self, mock_print):
|
||||
service = mock.Mock()
|
||||
fields = ['id', 'name', 'index', 'status', 'cluster_id', 'physical_id',
|
||||
'profile_name', 'created_at', 'updated_at']
|
||||
'profile_name', 'created_at', 'updated_at', 'project_id']
|
||||
args = {
|
||||
'cluster': 'cluster1',
|
||||
'sort': 'name:asc',
|
||||
@ -1545,9 +1545,10 @@ class ShellTest(testtools.TestCase):
|
||||
def test_do_event_list(self, mock_print):
|
||||
service = mock.Mock()
|
||||
fields = ['id', 'generated_at', 'obj_type', 'obj_id', 'obj_name',
|
||||
'action', 'status', 'level', 'cluster_id']
|
||||
'action', 'status', 'level', 'cluster_id', 'project_id']
|
||||
field_labels = ['id', 'timestamp', 'obj_type', 'obj_id', 'obj_name',
|
||||
'action', 'status', 'level', 'cluster_id']
|
||||
'action', 'status', 'level', 'cluster_id',
|
||||
'project_id']
|
||||
|
||||
args = {
|
||||
'sort': 'timestamp:asc',
|
||||
|
@ -97,10 +97,15 @@ class ListCluster(command.Lister):
|
||||
|
||||
clusters = senlin_client.clusters(**queries)
|
||||
formatters = {}
|
||||
if parsed_args.global_project:
|
||||
columns.append('project_id')
|
||||
if not parsed_args.full_id:
|
||||
formatters = {
|
||||
'id': lambda x: x[:8]
|
||||
}
|
||||
if 'project_id' in columns:
|
||||
formatters['project_id'] = lambda x: x[:8]
|
||||
|
||||
return (
|
||||
columns,
|
||||
(utils.get_item_properties(c, columns, formatters=formatters)
|
||||
|
@ -92,9 +92,13 @@ class ListEvent(command.Lister):
|
||||
queries.update(senlin_utils.format_parameters(parsed_args.filters))
|
||||
|
||||
formatters = {}
|
||||
if parsed_args.global_project:
|
||||
columns.append('project_id')
|
||||
if not parsed_args.full_id:
|
||||
formatters['id'] = lambda x: x[:8]
|
||||
formatters['obj_id'] = lambda x: x[:8] if x else ''
|
||||
if 'project_id' in columns:
|
||||
formatters['project_id'] = lambda x: x[:8]
|
||||
|
||||
events = senlin_client.events(**queries)
|
||||
return (columns,
|
||||
|
@ -99,13 +99,16 @@ class ListNode(command.Lister):
|
||||
queries.update(senlin_utils.format_parameters(parsed_args.filters))
|
||||
|
||||
nodes = senlin_client.nodes(**queries)
|
||||
|
||||
if parsed_args.global_project:
|
||||
columns.append('project_id')
|
||||
if not parsed_args.full_id:
|
||||
formatters = {
|
||||
'id': lambda x: x[:8],
|
||||
'cluster_id': lambda x: x[:8] if x else '',
|
||||
'physical_id': lambda x: x[:8] if x else ''
|
||||
}
|
||||
if 'project_id' in columns:
|
||||
formatters['project_id'] = lambda x: x[:8]
|
||||
else:
|
||||
formatters = {}
|
||||
|
||||
|
@ -93,10 +93,15 @@ class ListPolicy(command.Lister):
|
||||
|
||||
policies = senlin_client.policies(**queries)
|
||||
formatters = {}
|
||||
if parsed_args.global_project:
|
||||
columns.append('project_id')
|
||||
if not parsed_args.full_id:
|
||||
formatters = {
|
||||
'id': lambda x: x[:8]
|
||||
}
|
||||
if 'project_id' in columns:
|
||||
formatters['project_id'] = lambda x: x[:8]
|
||||
|
||||
return (
|
||||
columns,
|
||||
(utils.get_item_properties(p, columns, formatters=formatters)
|
||||
|
@ -140,11 +140,17 @@ class ListProfile(command.Lister):
|
||||
if parsed_args.filters:
|
||||
queries.update(senlin_utils.format_parameters(parsed_args.filters))
|
||||
data = senlin_client.profiles(**queries)
|
||||
|
||||
formatters = {}
|
||||
if parsed_args.global_project:
|
||||
columns.append('project_id')
|
||||
if not parsed_args.full_id:
|
||||
formatters = {
|
||||
'id': lambda x: x[:8],
|
||||
}
|
||||
if 'project_id' in columns:
|
||||
formatters['project_id'] = lambda x: x[:8]
|
||||
|
||||
return (
|
||||
columns,
|
||||
(utils.get_item_properties(p, columns, formatters=formatters)
|
||||
|
@ -95,11 +95,15 @@ class ListReceiver(command.Lister):
|
||||
|
||||
receivers = senlin_client.receivers(**queries)
|
||||
formatters = {}
|
||||
if parsed_args.global_project:
|
||||
columns.append('project_id')
|
||||
if not parsed_args.full_id:
|
||||
formatters = {
|
||||
'id': lambda x: x[:8],
|
||||
'cluster_id': lambda x: x[:8] if x else None,
|
||||
}
|
||||
if 'project_id' in columns:
|
||||
formatters['project_id'] = lambda x: x[:8]
|
||||
|
||||
return (
|
||||
columns,
|
||||
|
@ -120,10 +120,15 @@ def do_profile_list(service, args=None):
|
||||
|
||||
profiles = service.profiles(**queries)
|
||||
formatters = {}
|
||||
if args.global_project:
|
||||
fields.append('project_id')
|
||||
if not args.full_id:
|
||||
formatters = {
|
||||
'id': lambda x: x.id[:8],
|
||||
}
|
||||
if 'project_id' in fields:
|
||||
formatters['project_id'] = lambda x: x.id[:8]
|
||||
|
||||
utils.print_list(profiles, fields, formatters=formatters,
|
||||
sortby_index=sortby_index)
|
||||
|
||||
@ -347,10 +352,15 @@ def do_policy_list(service, args=None):
|
||||
sortby_index = None if args.sort else 1
|
||||
policies = service.policies(**queries)
|
||||
formatters = {}
|
||||
if args.global_project:
|
||||
fields.append('project_id')
|
||||
if not args.full_id:
|
||||
formatters = {
|
||||
'id': lambda x: x.id[:8]
|
||||
}
|
||||
if 'project_id' in fields:
|
||||
formatters['project_id'] = lambda x: x.id[:8]
|
||||
|
||||
utils.print_list(policies, fields, formatters=formatters,
|
||||
sortby_index=sortby_index)
|
||||
|
||||
@ -487,10 +497,15 @@ def do_cluster_list(service, args=None):
|
||||
|
||||
clusters = service.clusters(**queries)
|
||||
formatters = {}
|
||||
if args.global_project:
|
||||
fields.append('project_id')
|
||||
if not args.full_id:
|
||||
formatters = {
|
||||
'id': lambda x: x.id[:8]
|
||||
}
|
||||
if 'project_id' in fields:
|
||||
formatters['project_id'] = lambda x: x.id[:8]
|
||||
|
||||
utils.print_list(clusters, fields, formatters=formatters,
|
||||
sortby_index=sortby_index)
|
||||
|
||||
@ -1127,12 +1142,16 @@ def do_node_list(service, args):
|
||||
|
||||
nodes = service.nodes(**queries)
|
||||
|
||||
if args.global_project:
|
||||
fields.append('project_id')
|
||||
if not args.full_id:
|
||||
formatters = {
|
||||
'id': lambda x: x.id[:8],
|
||||
'cluster_id': lambda x: x.cluster_id[:8] if x.cluster_id else '',
|
||||
'physical_id': lambda x: x.physical_id[:8] if x.physical_id else ''
|
||||
}
|
||||
if 'project_id' in fields:
|
||||
formatters['project_id'] = lambda x: x.id[:8]
|
||||
else:
|
||||
formatters = {}
|
||||
|
||||
@ -1327,11 +1346,16 @@ def do_receiver_list(service, args):
|
||||
|
||||
receivers = service.receivers(**queries)
|
||||
formatters = {}
|
||||
if args.global_project:
|
||||
fields.append('project_id')
|
||||
if not args.full_id:
|
||||
formatters = {
|
||||
'id': lambda x: x.id[:8],
|
||||
'cluster_id': lambda x: x.cluster_id[:8] if x.cluster_id else '-',
|
||||
}
|
||||
if 'project_id' in fields:
|
||||
formatters['project_id'] = lambda x: x.id[:8]
|
||||
|
||||
utils.print_list(receivers, fields, formatters=formatters,
|
||||
sortby_index=sortby_index)
|
||||
|
||||
@ -1460,11 +1484,16 @@ def do_event_list(service, args):
|
||||
sortby_index = None if args.sort else 0
|
||||
|
||||
formatters = {}
|
||||
if args.global_project:
|
||||
fields.append('project_id')
|
||||
field_labels.append('project_id')
|
||||
if not args.full_id:
|
||||
formatters['id'] = lambda x: x.id[:8]
|
||||
formatters['obj_id'] = lambda x: x.obj_id[:8] if x.obj_id else ''
|
||||
formatters['cluster_id'] = (lambda x: x.cluster_id[:8]
|
||||
if x.cluster_id else '')
|
||||
if 'project_id' in fields:
|
||||
formatters['project_id'] = lambda x: x.id[:8]
|
||||
|
||||
events = service.events(**queries)
|
||||
utils.print_list(events, fields, formatters=formatters,
|
||||
|
Loading…
x
Reference in New Issue
Block a user