diff options
| author | Jenkins <jenkins@review.openstack.org> | 2017-03-16 13:02:17 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2017-03-16 13:02:17 +0000 |
| commit | c1503492cdada52086da353d06f082f2a53782e5 (patch) | |
| tree | 256ac6ea6be4fdb0564421de640585639e6a1769 /openstackclient/network | |
| parent | 3d4750cdc875049c4332052d3dd46296d5f74319 (diff) | |
| parent | 888022f8c0a2911a03fc682fdbe4c68c35a27db7 (diff) | |
| download | python-openstackclient-c1503492cdada52086da353d06f082f2a53782e5.tar.gz | |
Merge "Fix "security group list" command to display project ID properly"
Diffstat (limited to 'openstackclient/network')
| -rw-r--r-- | openstackclient/network/v2/security_group.py | 50 |
1 files changed, 32 insertions, 18 deletions
diff --git a/openstackclient/network/v2/security_group.py b/openstackclient/network/v2/security_group.py index c6d9ede7..182d4817 100644 --- a/openstackclient/network/v2/security_group.py +++ b/openstackclient/network/v2/security_group.py @@ -210,21 +210,6 @@ class ListSecurityGroup(common.NetworkAndComputeLister): ) return parser - def _get_return_data(self, data, include_project=True): - columns = ( - "ID", - "Name", - "Description", - ) - column_headers = columns - if include_project: - columns = columns + ('Tenant ID',) - column_headers = column_headers + ('Project',) - return (column_headers, - (utils.get_item_properties( - s, columns, - ) for s in data)) - def take_action_network(self, client, parsed_args): filters = {} if parsed_args.project: @@ -236,13 +221,42 @@ class ListSecurityGroup(common.NetworkAndComputeLister): ).id filters['tenant_id'] = project_id filters['project_id'] = project_id - return self._get_return_data(client.security_groups(**filters)) + data = client.security_groups(**filters) + + columns = ( + "ID", + "Name", + "Description", + "Project ID" + ) + column_headers = ( + "ID", + "Name", + "Description", + "Project" + ) + return (column_headers, + (utils.get_item_properties( + s, columns, + ) for s in data)) def take_action_compute(self, client, parsed_args): search = {'all_tenants': parsed_args.all_projects} data = client.security_groups.list(search_opts=search) - return self._get_return_data(data, - include_project=parsed_args.all_projects) + + columns = ( + "ID", + "Name", + "Description", + ) + column_headers = columns + if parsed_args.all_projects: + columns = columns + ('Tenant ID',) + column_headers = column_headers + ('Project',) + return (column_headers, + (utils.get_item_properties( + s, columns, + ) for s in data)) class SetSecurityGroup(common.NetworkAndComputeCommand): |
