Created
October 19, 2022 22:53
-
-
Save igalic/63a2163a644910128ebf463807a9cd14 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/cloudinit/distros/bsd_utils.py b/cloudinit/distros/bsd_utils.py | |
index 00cd0662..a1764cae 100644 | |
--- a/cloudinit/distros/bsd_utils.py | |
+++ b/cloudinit/distros/bsd_utils.py | |
@@ -1,5 +1,6 @@ | |
# This file is part of cloud-init. See LICENSE file for license information. | |
+import re | |
import shlex | |
from cloudinit import util | |
@@ -26,6 +27,13 @@ def get_rc_config_value(key, fn="/etc/rc.conf"): | |
return _unquote(value) | |
+def get_rc_config_line(search, fn="/etc/rc.conf"): | |
+ for line in util.load_file(fn).splitlines(): | |
+ x = re.match(search, line) | |
+ if x: | |
+ return x | |
+ | |
+ | |
def set_rc_config_value(key, value, fn="/etc/rc.conf"): | |
lines = [] | |
done = False | |
diff --git a/cloudinit/distros/networking.py b/cloudinit/distros/networking.py | |
index 47daf8db..c3f0122c 100644 | |
--- a/cloudinit/distros/networking.py | |
+++ b/cloudinit/distros/networking.py | |
@@ -5,6 +5,7 @@ import re | |
from typing import List, Optional | |
from cloudinit import net, subp, util | |
+from cloudinit.distros import bsd_utils | |
from cloudinit.distros.parsers import ifconfig | |
LOG = logging.getLogger(__name__) | |
@@ -273,6 +274,17 @@ class FreeBSDNetworking(BSDNetworking): | |
return True | |
return False | |
+ def device_driver(self, devname: DeviceName): | |
+ if self.is_renamed(devname): | |
+ search = """ifconfig_([^_]+)_name={}""".format(devname) | |
+ devname = bsd_utils.get_rc_config_line(search) | |
+ base, _ = re.fullmatch("([a-z]+)([0-9]+).*", devname).groups() | |
+ # optionally, verify the driver: | |
+ # driver, _ = subp.subp( | |
+ # ["sysctl", "-b", "dev.{}.{}.%driver".format(base, index)] | |
+ # ) | |
+ return base | |
+ | |
class LinuxNetworking(Networking): | |
"""Implementation of networking functionality common to Linux distros.""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment