summaryrefslogtreecommitdiff
path: root/src/helpers/vyos_net_name
diff options
context:
space:
mode:
authorDmitriyEshenko <dmitriy.eshenko@vyos.io>2021-11-08 17:20:03 +0000
committerDmitriyEshenko <dmitriy.eshenko@vyos.io>2021-11-09 19:09:40 +0000
commitee02ca93ec7be75edd0ec4c0e07fe5d51a45edc6 (patch)
tree550eded1f03e3479231d9df89253f9debb392c43 /src/helpers/vyos_net_name
parent73be449b1cd09f3ca86400753630fb4804fbeca7 (diff)
downloadvyos-1x-ee02ca93ec7be75edd0ec4c0e07fe5d51a45edc6.tar.gz
vyos-1x-ee02ca93ec7be75edd0ec4c0e07fe5d51a45edc6.zip
interface-names: T3871: Add temporary interface names to properly renaming
Diffstat (limited to 'src/helpers/vyos_net_name')
-rwxr-xr-xsrc/helpers/vyos_net_name17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/helpers/vyos_net_name b/src/helpers/vyos_net_name
index 0652e98b1..5d9535cf0 100755
--- a/src/helpers/vyos_net_name
+++ b/src/helpers/vyos_net_name
@@ -77,10 +77,12 @@ def get_biosdevname(ifname: str) -> str:
XXX: This throws an error, and likely has for a long time, unnoticed
since vyatta_net_name redirected stderr to /dev/null.
"""
- if 'eth' not in ifname:
- return ifname
+ intf = f"eth{re.sub(r'[^0-9]', '', ifname)}" if 'e' == ifname[0] else ifname
+
+ if 'eth' not in intf:
+ return intf
if os.path.isdir('/proc/xen'):
- return ifname
+ return intf
time.sleep(1)
@@ -90,7 +92,7 @@ def get_biosdevname(ifname: str) -> str:
logging.error(f'biosdevname error: {e}')
biosname = ''
- return ifname if biosname == '' else biosname
+ return intf if biosname == '' else biosname
def leave_rescan_hint(intf_name: str, hwid: str):
"""Write interface information reported by udev
@@ -186,9 +188,9 @@ def on_boot_event(intf_name: str, hwid: str, predefined: str = '') -> str:
interfaces = get_configfile_interfaces()
logging.debug(f"config file interfaces are {interfaces}")
- if hwid in list(interfaces) and intf_name == interfaces[hwid]:
- logging.info(f"use mapping from config file: '{hwid}' -> '{intf_name}'")
- return intf_name
+ if hwid in list(interfaces):
+ logging.info(f"use mapping from config file: '{hwid}' -> '{interfaces[hwid]}'")
+ return interfaces[hwid]
add_assigned_interfaces(interfaces)
logging.debug(f"adding assigned interfaces: {interfaces}")
@@ -223,6 +225,7 @@ lock.acquire()
if not boot_configuration_complete():
res = on_boot_event(argv[1], argv[2], predefined=predef_name)
logging.debug(f"on boot, returned name is {res}")
+ print(res)
else:
logging.debug("boot configuration complete")
lock.release()