Created
October 21, 2022 17:04
-
-
Save igalic/5824e72b26ecbde9f50f9459edb489f3 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/networking.py b/cloudinit/distros/networking.py | |
index ef0c5529..ea966283 100644 | |
--- a/cloudinit/distros/networking.py | |
+++ b/cloudinit/distros/networking.py | |
@@ -253,20 +253,20 @@ class FreeBSDNetworking(BSDNetworking): | |
# sense on them anyway | |
return False | |
- try: | |
- # check that `devinfo -p devname` returns the driver chain: | |
- # $ devinfo -p em0 | |
- # => em0 pci0 pcib0 acpi0 nexus0 | |
- # if it doesn't, we know something's up: | |
- # $ devinfo -p eth0 | |
- # => devinfo: eth0: Not found | |
- | |
- # we could be catching exit codes here and check if they are 0 | |
- # (success: not renamed) or 1 (failure: renamed), instead of | |
- # ripping thru the stack with an exception. | |
- # unfortunately, subp doesn't return exit codes. | |
- subp.subp(["devinfo", "-p", devname]) | |
- except subp.ProcessExecutionError: | |
+ # check that `devinfo -p devname` returns the driver chain: | |
+ # $ devinfo -p em0 | |
+ # => em0 pci0 pcib0 acpi0 nexus0 | |
+ # if it doesn't, we know something's up: | |
+ # $ devinfo -p eth0 | |
+ # => devinfo: eth0: Not found | |
+ | |
+ # we could be catching exit codes here and check if they are 0 | |
+ # (success: not renamed) or 1 (failure: renamed), instead of | |
+ # ripping thru the stack with an exception. | |
+ # unfortunately, subp doesn't return exit codes. | |
+ # so we do the next best thing, and compare the output. | |
+ _, err = subp.subp(["devinfo", "-p", devname], rcs=[0, 1]) | |
+ if err == "devinfo: {}: Not found\n".format(devname): | |
return True | |
return False | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment