mirror of https://git.48k.eu/ogclient
sw_inventory: consolidate os_probe logic
Reuse os_probe() function from probe.py and change the fallback case to "unknown" to prevent OS id mismatch in ogserver. The OS id mismatch causes the images to stop being associated with partitions after the /refresh command.master
parent
51258613cc
commit
3b40ec7918
|
@ -177,4 +177,4 @@ def os_probe(mountpoint):
|
|||
elif os.path.exists(winreghives):
|
||||
return getwindowsversion(winreghives)
|
||||
else:
|
||||
return ''
|
||||
return 'unknown'
|
||||
|
|
|
@ -15,7 +15,7 @@ from collections import namedtuple
|
|||
|
||||
import hivex
|
||||
|
||||
from src.utils.probe import getwindowsversion, getlinuxversion
|
||||
from src.utils.probe import os_probe
|
||||
|
||||
|
||||
Package = namedtuple('Package', ['name', 'version'])
|
||||
|
@ -119,17 +119,13 @@ def _get_package_set_dpkg(dpkg_status_path):
|
|||
|
||||
def get_package_set(mountpoint):
|
||||
dpkg_status_path = f'{mountpoint}{DPKG_STATUS_PATH}'
|
||||
winreghives = f'{mountpoint}{WINDOWS_HIVES_PATH}'
|
||||
osrelease = f'{mountpoint}{OSRELEASE_PATH}'
|
||||
softwarehive = f'{mountpoint}{WINDOWS_HIVES_SOFTWARE}'
|
||||
if os.path.exists(softwarehive):
|
||||
pkgset = _get_package_set_windows(softwarehive)
|
||||
osname = getwindowsversion(winreghives)
|
||||
elif os.path.exists(dpkg_status_path):
|
||||
pkgset = _get_package_set_dpkg(dpkg_status_path)
|
||||
osname = getlinuxversion(osrelease)
|
||||
else:
|
||||
pkgset = set()
|
||||
osname = "unknown"
|
||||
osname = os_probe(mountpoint)
|
||||
# Legacy software inventory first element is the OS name
|
||||
return [osname] + list(pkgset)
|
||||
|
|
Loading…
Reference in New Issue