Use normalized_cidr of the SG in the backen drivers

Patch [1] introduced new, read only field "normalized_cidr" in
the security groups' rules.
With this patch this new field is send as source or
destination_ip_prefix field in the rule's dict in case if
remote_ip_prefix and normalized_cidr are set in the rule.

[1] https://review.opendev.org/c/openstack/neutron/+/749158

Related-Bug: #1869129
Change-Id: Icebe0255ce11eae859c05a273335b027da3f1545
This commit is contained in:
Slawek Kaplonski 2021-02-22 23:11:38 +01:00
parent 787444ac9e
commit 2bfe143d83
1 changed files with 6 additions and 2 deletions

View File

@ -221,8 +221,10 @@ class SecurityGroupInfoAPIMixin(object):
'remote_address_group_id'):
if rule_in_db.get(key) is not None:
if key == 'remote_ip_prefix':
normalized_cidr = rule_in_db.get('normalized_cidr')
direction_ip_prefix = DIRECTION_IP_PREFIX[direction]
rule_dict[direction_ip_prefix] = rule_in_db[key]
rule_dict[direction_ip_prefix] = (
normalized_cidr or rule_in_db[key])
continue
rule_dict[key] = rule_in_db[key]
if security_group_id not in sg_info['security_groups']:
@ -384,8 +386,10 @@ class SecurityGroupInfoAPIMixin(object):
'remote_address_group_id'):
if rule_in_db.get(key) is not None:
if key == 'remote_ip_prefix':
normalized_cidr = rule_in_db.get('normalized_cidr')
direction_ip_prefix = DIRECTION_IP_PREFIX[direction]
rule_dict[direction_ip_prefix] = rule_in_db[key]
rule_dict[direction_ip_prefix] = (
normalized_cidr or rule_in_db[key])
continue
rule_dict[key] = rule_in_db[key]
port['security_group_rules'].append(rule_dict)