summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/vyos/airbag.py14
-rw-r--r--python/vyos/version.py21
2 files changed, 23 insertions, 12 deletions
diff --git a/python/vyos/airbag.py b/python/vyos/airbag.py
index 69b44dc9d..4e7bdfd06 100644
--- a/python/vyos/airbag.py
+++ b/python/vyos/airbag.py
@@ -78,8 +78,13 @@ def bug_report(dtype, value, trace):
note = 'noteworthy:\n'
note += '\n'.join(list(_noteworthy))
+ hardware = ''
+ if 'hardware_vendor' in information:
+ hardware = HARDWARE.format(**information)
+
information.update({
'date': datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
+ 'hardware': hardware,
'trace': trace,
'instructions': INSTRUCTIONS,
'note': note,
@@ -141,14 +146,17 @@ Build commit ID: {build_git}
Architecture: {system_arch}
Boot via: {boot_via}
System type: {system_type}
+{hardware}
+{trace}
+{note}
+"""
+# Optional section of FAULT - a container has no hardware of its own
+HARDWARE = """
Hardware vendor: {hardware_vendor}
Hardware model: {hardware_model}
Hardware S/N: {hardware_serial}
Hardware UUID: {hardware_uuid}
-
-{trace}
-{note}
"""
INTRO = """\
diff --git a/python/vyos/version.py b/python/vyos/version.py
index dcaec8817..50359ddf6 100644
--- a/python/vyos/version.py
+++ b/python/vyos/version.py
@@ -104,15 +104,18 @@ def get_full_version_data(fname=version_file):
boot_via = "installed image"
version_data['boot_via'] = boot_via
- # Get hardware details from DMI
- dmi = '/sys/class/dmi/id'
- version_data['hardware_vendor'] = read_file(dmi + '/sys_vendor', 'Unknown')
- version_data['hardware_model'] = read_file(dmi +'/product_name','Unknown')
-
- # These two assume script is run as root, normal users can't access those files
- subsystem = '/sys/class/dmi/id/subsystem/id'
- version_data['hardware_serial'] = read_file(subsystem + '/product_serial','Unknown')
- version_data['hardware_uuid'] = read_file(subsystem + '/product_uuid', 'Unknown')
+ # Get hardware details from DMI - a container has no hardware of its own and
+ # would report the DMI data of the host system, thus the keys are left unset
+ # and consumers are expected to omit them
+ if not is_running_as_container():
+ dmi = '/sys/class/dmi/id'
+ version_data['hardware_vendor'] = read_file(dmi + '/sys_vendor', 'Unknown')
+ version_data['hardware_model'] = read_file(dmi +'/product_name','Unknown')
+
+ # These two assume script is run as root, normal users can't access those files
+ subsystem = '/sys/class/dmi/id/subsystem/id'
+ version_data['hardware_serial'] = read_file(subsystem + '/product_serial','Unknown')
+ version_data['hardware_uuid'] = read_file(subsystem + '/product_uuid', 'Unknown')
return version_data