-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #149 from ogayot/probe-firmware
Add way to probe firmware information
- Loading branch information
Showing
7 changed files
with
109 additions
and
3 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
probert (0.0.21) UNRELEASED; urgency=medium | ||
|
||
* Add probert-firmware to probe information about the firmware. | ||
|
||
-- Olivier Gayot <[email protected]> Tue, 02 Jul 2024 15:55:59 +0200 | ||
|
||
probert (0.0.20) groovy; urgency=medium | ||
|
||
[ Ryan Harper ] | ||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
usr/lib/python3.*/dist-packages/probert/firmware.py |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# Copyright 2024 Canonical, Ltd. | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, version 3. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
"""Collect information about the firmware. Unlike network and storage, which | ||
support hotplugging, firmware information should not need to be queried | ||
multiple times.""" | ||
|
||
import logging | ||
import shutil | ||
from typing import Any | ||
|
||
from probert.utils import arun | ||
|
||
|
||
log = logging.getLogger('probert.firmware') | ||
|
||
|
||
schema = { | ||
"$schema": "http://json-schema.org/draft-07/schema", | ||
"type": "object", | ||
"additionalProperties": False, | ||
"required": ["bios-vendor", "bios-version", "bios-release-date"], | ||
"properties": { | ||
"bios-vendor": { | ||
"type": ["string", "null"], | ||
}, | ||
"bios-version": { | ||
"type": ["string", "null"], | ||
}, | ||
"bios-release-data": { | ||
"type": ["string", "null"], | ||
}, | ||
}, | ||
} | ||
|
||
|
||
class FirmwareProber: | ||
async def _probe_bios_string(self, string: str) -> str | None: | ||
dmidecode = shutil.which("dmidecode") | ||
if dmidecode is None: | ||
log.debug("could not determine bios %s: dmidecode not found", | ||
string) | ||
return None | ||
|
||
out = await arun([dmidecode, "--string", string]) | ||
if out is None: | ||
log.warning("could not determine bios %s: dmidecode failure", | ||
string) | ||
else: | ||
out = out.strip() | ||
return out | ||
|
||
async def probe(self) -> dict[str, Any]: | ||
return { | ||
"bios-vendor": await self._probe_bios_string("bios-vendor"), | ||
"bios-version": await self._probe_bios_string("bios-version"), | ||
"bios-release-date": | ||
await self._probe_bios_string("bios-release-date"), | ||
} |
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
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