fix regression: remove dependency on dmidecode
Bug #1900753 reported by
Mina Galić
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
cloud-init |
Fix Released
|
Undecided
|
Mina Galić |
Bug Description
When we extended ds-identify to use dmidecode, we made it x86-only, which is the platforms that dmidecode supports (on FreeBSD): https:/
it would be good if we could "fix" that, by removing our dependency on dmidecode, and instead use kenv(1) https:/
Changed in cloud-init: | |
status: | New → Triaged |
Changed in cloud-init: | |
assignee: | nobody → Mina Galić (minagalic) |
Changed in cloud-init: | |
status: | Triaged → In Progress |
To post a comment you must log in.
We don't strictly have a dependency on dmidecode.
ds-identify will only try dmidecode if values in /sys/class/dmi/id/ are not present. That is desirable, as reading files from /sys is orders of magnitude faster than invoking a program to do the same.
I think calling kenv on freebsd would be fine.
something like this:
diff --git a/tools/ds-identify b/tools/ds-identify .7019b757d 100755
index 4e5700fc6.
--- a/tools/ds-identify
+++ b/tools/ds-identify
@@ -198,6 +198,11 @@ dmi_decode() {
_RET="$val"
}
+read_kenv() { {PATH_SYS_ CLASS_DMI_ ID}/$1" "$UNAVAILABLE" KERNEL_ NAME" in
+ # left as an excersize to the reader.
+ :
+}
+
get_dmi_field() {
local path="$
_RET=
@@ -210,7 +215,10 @@ get_dmi_field() {
# do *not* fallback to dmidecode!
return
fi
- dmi_decode "$1" || _RET="$ERROR"
+ case "$DI_UNAME_
+ FreeBSD) read_kenv "$1" || _RET="$ERROR";;
+ *) dmi_decode "$1" || _RET="$ERROR"
+ esac
return
}