Fix --security-group for port list

"openstack port list --security-group <id>" was using a filter that
didn't exist in `openstacksdk`: "security_groups". Up until version
1.0.1, `openstacksdk` did not support filtering `Port` objects by
security groups. Later versions will support the filtering (via [1]),
but the filter is called the same way the attribute on the `Port` object
is called: `security_group_ids`.

We're not bumping the `openstacksdk` version here, because the feature
we're using [1] is merged too recently and a bump of min requirements
thus unlikely. `openstackclient` continue to work with older versions of
`openstacksdk` - the "--security-group" filter will just do nothing like
before.

[1] https://review.opendev.org/c/openstack/openstacksdk/+/866008

Change-Id: I07088484592e99ce0a12b67d68a3e47ae7c7af81
This commit is contained in:
Johannes Kulik 2023-03-16 11:46:00 +01:00
parent 5eb89e4ca1
commit aa227f8d16
2 changed files with 2 additions and 2 deletions
openstackclient
network/v2
tests/unit/network/v2

@ -694,7 +694,7 @@ class ListPort(command.Lister):
filters['fixed_ips'] = _prepare_filter_fixed_ips(
self.app.client_manager, parsed_args)
if parsed_args.security_groups:
filters['security_groups'] = parsed_args.security_groups
filters['security_group_ids'] = parsed_args.security_groups
_tag.get_tag_filtering_args(parsed_args, filters)

@ -1318,7 +1318,7 @@ class TestListPort(TestPort):
columns, data = self.cmd.take_action(parsed_args)
filters = {
'security_groups': ['sg-id1', 'sg-id2'],
'security_group_ids': ['sg-id1', 'sg-id2'],
'fields': LIST_FIELDS_TO_RETRIEVE,
}