summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRamón M. Gómez <ramongomez@us.es>2018-06-20 20:25:30 +0200
committerRamón M. Gómez <ramongomez@us.es>2018-06-20 20:25:30 +0200
commit1c9cb7e66a14b88bcf0ca9b5365bebe1422841d7 (patch)
tree764d0a0c0f88a3384309081aac08937e9cf97198
parentf916902b7ae0cc723f1547bb8922f3fe13068735 (diff)
#750: New route {{{GET /hardware}}}.
-rw-r--r--admin/Sources/Clients/ogagent/src/opengnsys/modules/server/OpenGnSys/__init__.py15
-rw-r--r--admin/Sources/Clients/ogagent/src/opengnsys/oglive/operations.py18
2 files changed, 30 insertions, 3 deletions
diff --git a/admin/Sources/Clients/ogagent/src/opengnsys/modules/server/OpenGnSys/__init__.py b/admin/Sources/Clients/ogagent/src/opengnsys/modules/server/OpenGnSys/__init__.py
index 70c09c20..70c8973a 100644
--- a/admin/Sources/Clients/ogagent/src/opengnsys/modules/server/OpenGnSys/__init__.py
+++ b/admin/Sources/Clients/ogagent/src/opengnsys/modules/server/OpenGnSys/__init__.py
@@ -296,7 +296,7 @@ class OpenGnSysWorker(ServerWorker):
logger.debug('Recieved getconfig operation')
self.checkSecret(server)
# Processing data
- for row in operations.get_disk_config().strip().split(';'):
+ for row in operations.get_configuration().split(';'):
cols = row.split(':')
if len(cols) == 1:
if cols[0] != '':
@@ -325,3 +325,16 @@ class OpenGnSysWorker(ServerWorker):
warnings += 1
# Returning configuration data and count of warnings
return {'serialno': serialno, 'storage': storage, 'warnings': warnings}
+
+ def process_hardware(self, path, get_params, post_params, server):
+ """
+ Returns client's hardware profile
+ :param path:
+ :param get_params:
+ :param post_params:
+ :param server:
+ """
+ logger.debug('Recieved {} operation'.format(path))
+ self.checkSecret(server)
+ # Returning raw data
+ return operations.get_hardware()
diff --git a/admin/Sources/Clients/ogagent/src/opengnsys/oglive/operations.py b/admin/Sources/Clients/ogagent/src/opengnsys/oglive/operations.py
index e24e0b91..b22a6079 100644
--- a/admin/Sources/Clients/ogagent/src/opengnsys/oglive/operations.py
+++ b/admin/Sources/Clients/ogagent/src/opengnsys/oglive/operations.py
@@ -174,9 +174,9 @@ def poweroff():
_exec_ogcommand('/opt/opengnsys/scripts/poweroff')
-def get_disk_config():
+def get_configuration():
"""
- Returns disk configuration
+ Returns client's configuration
Warning: this operation may take some time
"""
try:
@@ -186,3 +186,17 @@ def get_disk_config():
except IOError:
cfgdata = ''
return cfgdata
+
+
+def get_hardware():
+ """
+ Returns client's hardware list
+ """
+ try:
+ filepath = _exec_ogcommand('/opt/opengnsys/scripts/listHardwareInfo').strip()
+ # Returns content of configuration file, skipping the header line and newline characters
+ with open(filepath, 'r') as f:
+ harddata = map(str.strip, f.readlines()[1:])
+ except IOError:
+ harddata = ''
+ return harddata