Merge "Fix "security group list" command to display project ID properly"
This commit is contained in:
commit
c1503492cd
@ -210,21 +210,6 @@ class ListSecurityGroup(common.NetworkAndComputeLister):
|
|||||||
)
|
)
|
||||||
return parser
|
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):
|
def take_action_network(self, client, parsed_args):
|
||||||
filters = {}
|
filters = {}
|
||||||
if parsed_args.project:
|
if parsed_args.project:
|
||||||
@ -236,13 +221,42 @@ class ListSecurityGroup(common.NetworkAndComputeLister):
|
|||||||
).id
|
).id
|
||||||
filters['tenant_id'] = project_id
|
filters['tenant_id'] = project_id
|
||||||
filters['project_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):
|
def take_action_compute(self, client, parsed_args):
|
||||||
search = {'all_tenants': parsed_args.all_projects}
|
search = {'all_tenants': parsed_args.all_projects}
|
||||||
data = client.security_groups.list(search_opts=search)
|
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):
|
class SetSecurityGroup(common.NetworkAndComputeCommand):
|
||||||
|
@ -1071,7 +1071,7 @@ class FakeSecurityGroup(object):
|
|||||||
'id': 'security-group-id-' + uuid.uuid4().hex,
|
'id': 'security-group-id-' + uuid.uuid4().hex,
|
||||||
'name': 'security-group-name-' + uuid.uuid4().hex,
|
'name': 'security-group-name-' + uuid.uuid4().hex,
|
||||||
'description': 'security-group-description-' + uuid.uuid4().hex,
|
'description': 'security-group-description-' + uuid.uuid4().hex,
|
||||||
'tenant_id': 'project-id-' + uuid.uuid4().hex,
|
'project_id': 'project-id-' + uuid.uuid4().hex,
|
||||||
'security_group_rules': [],
|
'security_group_rules': [],
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1083,7 +1083,7 @@ class FakeSecurityGroup(object):
|
|||||||
loaded=True)
|
loaded=True)
|
||||||
|
|
||||||
# Set attributes with special mapping in OpenStack SDK.
|
# Set attributes with special mapping in OpenStack SDK.
|
||||||
security_group.project_id = security_group_attrs['tenant_id']
|
security_group.project_id = security_group_attrs['project_id']
|
||||||
|
|
||||||
return security_group
|
return security_group
|
||||||
|
|
||||||
|
@ -404,7 +404,7 @@ class TestListSecurityGroupNetwork(TestSecurityGroupNetwork):
|
|||||||
grp.id,
|
grp.id,
|
||||||
grp.name,
|
grp.name,
|
||||||
grp.description,
|
grp.description,
|
||||||
grp.tenant_id,
|
grp.project_id,
|
||||||
))
|
))
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
6
releasenotes/notes/bug-1659967-644a8ee3621c9e81.yaml
Normal file
6
releasenotes/notes/bug-1659967-644a8ee3621c9e81.yaml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
``security group list`` command now can display project IDs in the ``Project`` column
|
||||||
|
of the command output.
|
||||||
|
[Bug `1659967 <https://bugs.launchpad.net/bugs/1659967>`_]
|
Loading…
Reference in New Issue
Block a user