Skip to content

Commit aa227f8

Browse files
committed
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
1 parent 5eb89e4 commit aa227f8

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

openstackclient/network/v2/port.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ def take_action(self, parsed_args):
694694
filters['fixed_ips'] = _prepare_filter_fixed_ips(
695695
self.app.client_manager, parsed_args)
696696
if parsed_args.security_groups:
697-
filters['security_groups'] = parsed_args.security_groups
697+
filters['security_group_ids'] = parsed_args.security_groups
698698

699699
_tag.get_tag_filtering_args(parsed_args, filters)
700700

openstackclient/tests/unit/network/v2/test_port.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1318,7 +1318,7 @@ def test_port_list_security_group(self):
13181318

13191319
columns, data = self.cmd.take_action(parsed_args)
13201320
filters = {
1321-
'security_groups': ['sg-id1', 'sg-id2'],
1321+
'security_group_ids': ['sg-id1', 'sg-id2'],
13221322
'fields': LIST_FIELDS_TO_RETRIEVE,
13231323
}
13241324

0 commit comments

Comments
 (0)