fix: prevent multiple IP assignments

A recent change[0] to address PEP8 issues resulted in an unintended
behavior modification, in some cases resulting in MAAS allocation of
multiple IP addresses to the same NIC.

This reverts to the original code logic.

[0] 1755930331

Change-Id: I6dccd1b60c414e3aa966085e81dc0b61244e9814
This commit is contained in:
Phil Sphicas 2020-05-30 20:17:57 +00:00
parent e0d804ed31
commit a75704b8cb
1 changed files with 6 additions and 6 deletions

View File

@ -273,13 +273,13 @@ class Interface(model_base.ResourceBase):
link_list = []
if isinstance(refined_dict.get('links', None), list):
for link in refined_dict['links']:
if isinstance(link, dict):
link = {'resource_id': link['id'], 'mode': link['mode']}
for li in refined_dict['links']:
if isinstance(li, dict):
link = {'resource_id': li['id'], 'mode': li['mode']}
if link.get('subnet', None) is not None:
link['subnet_id'] = link['subnet']['id']
link['ip_address'] = link.get('ip_address', None)
if li.get('subnet', None) is not None:
link['subnet_id'] = li['subnet']['id']
link['ip_address'] = li.get('ip_address', None)
link_list.append(link)