summaryrefslogtreecommitdiff
path: root/cloudinit/net/__init__.py
diff options
context:
space:
mode:
authorScott Moser <smoser@brickies.net>2017-07-19 09:28:52 -0400
committerScott Moser <smoser@brickies.net>2017-07-19 09:51:55 -0400
commitc0060fe4892197179a5cfbfd3239cf3b6c3e5029 (patch)
treecd1ae5e0f2f4cd889d9565f1f450e9a5673aa51f /cloudinit/net/__init__.py
parent865e941f3f88c7daeafbf1eab856e02ce2b6a5f7 (diff)
downloadvyos-cloud-init-c0060fe4892197179a5cfbfd3239cf3b6c3e5029.tar.gz
vyos-cloud-init-c0060fe4892197179a5cfbfd3239cf3b6c3e5029.zip
net: fix renaming of nics to support mac addresses written in upper case.
The network device renaming code previously required the case of the mac address input to match that of the data read from the system. For example, if user provided network config with mac address in upper case, then cloud-init would not rename the device correctly as /sys/class/net/address stores lower case values. The fix here is to always compare lower case mac addresses. LP: #1705147
Diffstat (limited to 'cloudinit/net/__init__.py')
-rw-r--r--cloudinit/net/__init__.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/cloudinit/net/__init__.py b/cloudinit/net/__init__.py
index cba991a5..d1740e56 100644
--- a/cloudinit/net/__init__.py
+++ b/cloudinit/net/__init__.py
@@ -302,7 +302,7 @@ def _get_current_rename_info(check_downable=True):
device has only automatically assigned ip addrs.
'device_id': Device id value (if it has one)
'driver': Device driver (if it has one)
- 'mac': mac address
+ 'mac': mac address (in lower case)
'name': name
'up': boolean: is_up(name)
}}
@@ -313,7 +313,7 @@ def _get_current_rename_info(check_downable=True):
'downable': None,
'device_id': device_id,
'driver': driver,
- 'mac': mac,
+ 'mac': mac.lower(),
'name': name,
'up': is_up(name),
}
@@ -348,6 +348,8 @@ def _rename_interfaces(renames, strict_present=True, strict_busy=True,
cur_info = {}
for name, data in current_info.items():
cur = data.copy()
+ if cur.get('mac'):
+ cur['mac'] = cur['mac'].lower()
cur['name'] = name
cur_info[name] = cur
@@ -399,6 +401,8 @@ def _rename_interfaces(renames, strict_present=True, strict_busy=True,
return None
for mac, new_name, driver, device_id in renames:
+ if mac:
+ mac = mac.lower()
cur_ops = []
cur = find_entry(mac, driver, device_id)
if not cur: