Merge "Fix ip version check bug in create security group rule" into stable/queens

This commit is contained in:
Zuul 2023-09-12 23:28:13 +00:00 committed by Gerrit Code Review
commit 807b8fb07e

View File

@ -3533,9 +3533,17 @@ class ApicMechanismDriver(api_plus.MechanismDriver,
sg_ports = query(session).params( sg_ports = query(session).params(
sg_id=sg_rule['remote_group_id']).all() sg_id=sg_rule['remote_group_id']).all()
ip_version = 0
if sg_rule['ethertype'] == 'IPv4':
ip_version = 4
elif sg_rule['ethertype'] == 'IPv6':
ip_version = 6
for sg_port in sg_ports: for sg_port in sg_ports:
for fixed_ip in sg_port['fixed_ips']: for fixed_ip in sg_port['fixed_ips']:
remote_ips.append(fixed_ip['ip_address']) if ip_version == netaddr.IPAddress(
fixed_ip['ip_address']).version:
remote_ips.append(fixed_ip['ip_address'])
remote_group_id = sg_rule['remote_group_id'] remote_group_id = sg_rule['remote_group_id']
else: else: