summaryrefslogtreecommitdiffstats
path: root/src/live
diff options
context:
space:
mode:
authorJose M. Guisado <jguisado@soleta.eu>2023-04-17 13:02:54 +0200
committerJose M. Guisado <jguisado@soleta.eu>2023-04-18 17:15:57 +0200
commitee80dc89ad8227e277bf39d12bcbe7ef0176b8a3 (patch)
treeecc6910566968ad6af5f5ffde123d5d924e9dbf5 /src/live
parent49a86bddd9cee5941bdcafd304a00ad127368ed2 (diff)
live: rewrite hardware inventory command
Replace legacy shell script InventarioHardware for helper functions from hw_inventory.py Use get_hardware_inventory to obtain a HardwareInventory object with the hardware information. Map the HardwareInventory object to a legacy response string with the legacy_list_hardware_inventory function. Remove "Chrd-*" file reading logic, it's no longer needed. Legacy shell script InventarioHardware uses that file. Expect a change in the structure of hardware inventory response payload in the future. This patch does not address the HTTP response containing the hardware inventory as a '\n' separated string of hardware elements.
Diffstat (limited to 'src/live')
-rw-r--r--src/live/ogOperations.py26
1 files changed, 12 insertions, 14 deletions
diff --git a/src/live/ogOperations.py b/src/live/ogOperations.py
index f11b221..56f0a75 100644
--- a/src/live/ogOperations.py
+++ b/src/live/ogOperations.py
@@ -31,6 +31,7 @@ from src.utils.disk import *
from src.utils.cache import generate_cache_txt, umount_cache, init_cache
from src.utils.tiptorrent import *
from src.utils.sw_inventory import get_package_set
+from src.utils.hw_inventory import get_hardware_inventory, legacy_list_hardware_inventory
OG_SHELL = '/bin/bash'
@@ -274,24 +275,21 @@ class OgLiveOperations:
# "{package_name} {package_version}"
return '\n'.join(map(str,pkgset))
- def hardware(self, path, ogRest):
+ def hardware(self, ogRest):
self._restartBrowser(self._url_log)
+ logging.info('Running hardware inventory command')
try:
- cmd = f'{ogClient.OG_PATH}interfaceAdm/InventarioHardware {path}'
- ogRest.proc = subprocess.Popen([cmd],
- stdout=subprocess.PIPE,
- shell=True,
- executable=OG_SHELL)
- (output, error) = ogRest.proc.communicate()
- except:
- logging.error('Exception when running hardware inventory subprocess')
- raise ValueError('Error: Incorrect command value')
-
- self._restartBrowser(self._url)
+ inventory = get_hardware_inventory()
+ except ValueError as e:
+ logging.error('Error occurred while running get_hardware_inventory')
+ raise e
+ finally:
+ self._restartBrowser(self._url)
- logging.info('Hardware inventory command OK')
- return output.decode('utf-8')
+ result = legacy_list_hardware_inventory(inventory)
+ logging.info('Successful hardware inventory command execution')
+ return result
def setup(self, request, ogRest):
table_type = request.getType()