Skip to content

Commit

Permalink
refresh port in get mac method
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewdmcleod committed Sep 30, 2019
1 parent 725f2f6 commit 2a917f5
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions zaza/openstack/utilities/openstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ def configure_gateway_ext_port(novaclient, neutronclient,
net_id=None, fixed_ip=None)
if add_dataport_to_netplan:
add_interface_to_netplan(server.name,
mac_address=get_mac_from_port(port),
mac_address=get_mac_from_port(port, neutronclient),
dvr_mode=dvr_mode)
ext_br_macs = []
for port in neutronclient.list_ports(network_id=net_id)['ports']:
Expand Down Expand Up @@ -642,15 +642,20 @@ def configure_gateway_ext_port(novaclient, neutronclient,

@tenacity.retry(wait=tenacity.wait_exponential(multiplier=1, max=60),
reraise=True, retry=tenacity.retry_if_exception_type(KeyError))
def get_mac_from_port(port):
def get_mac_from_port(port, neutronclient):
"""Get mac address from port, with tenacity due to openstack async.
:param port: neutron port
:type port: neutron port
:param neutronclient: Authenticated neutronclient
:type neutronclient: neutronclient.Client object
:returns: mac address
:rtype: string
"""
return port['mac_address']
logging.info("Trying to get mac address from port:"
"{}".format(port['id']))
refresh_port = neutronclient.show_port(port['id'])['port']
return refresh_port['mac_address']


def create_project_network(neutron_client, project_id, net_name='private',
Expand Down

0 comments on commit 2a917f5

Please sign in to comment.