Merge "Populate 'security_groups' field from pre-existing port"

This commit is contained in:
Zuul 2018-01-23 19:30:06 +00:00 committed by Gerrit Code Review
commit 84dd0dc361
2 changed files with 9 additions and 1 deletions

View File

@ -192,6 +192,13 @@ class KuryrNetwork(network.Network):
# We might revisit this behaviour later. Alternatively, we could
# either throw an exception or overwrite the port's security
# groups.
if not container.security_groups:
container.security_groups = []
if neutron_port['security_groups']:
for sg in neutron_port['security_groups']:
if sg not in container.security_groups:
container.security_groups += [sg]
container.save(self.context)
# update device_id in port
port_req_body = {'port': {'device_id': container.uuid}}

View File

@ -46,7 +46,8 @@ class FakeNeutronClient(object):
def get_neutron_port(self, port_id):
return {'fixed_ips': [{'ip_address': '192.168.2.22'}],
'id': '1234567'}
'id': '1234567',
'security_groups': []}
def get_neutron_network(self, network_id):
return {'shared': False}