Format generated MAC addresses using eui48.mac_unix_expanded

In Ml2Plugin.create_port_bulk, the MAC generated using netaddr.EUI
have the following format:
  "XX-XX-XX-XX-XX-XX"

In order to make them more compatible with other systems, the
following format is more appropiate:
  "00:01:23:45:67:ab"

eui48.mac_unix_expanded formater will add leading zeros if needed.

Change-Id: Ice382c0b4738a5a2576a3a4b151059715f106b40
Closes-Bug: #1822999
(cherry picked from commit fa5e9c6fab)
This commit is contained in:
Rodolfo Alonso Hernandez 2019-04-03 14:52:39 +01:00 committed by Nate Johnston
parent f6652f0ee6
commit 5a09980314
1 changed files with 3 additions and 1 deletions

View File

@ -15,6 +15,7 @@
from eventlet import greenthread
import netaddr
from netaddr.strategy import eui48
from neutron_lib.agent import constants as agent_consts
from neutron_lib.agent import topics
from neutron_lib.api.definitions import address_scope
@ -1404,7 +1405,8 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
elif self._is_mac_in_use(context, network_id, raw_mac_address):
raise exc.MacAddressInUse(net_id=network_id,
mac=raw_mac_address)
eui_mac_address = netaddr.EUI(raw_mac_address, 48)
eui_mac_address = netaddr.EUI(raw_mac_address,
dialect=eui48.mac_unix_expanded)
# Create the Port object
db_port_obj = ports_obj.Port(context,