#750: New route {{{GET /hardware}}}.

oglive^2^2
Ramón M. Gómez 2018-06-20 20:25:30 +02:00
parent 8e4fedd75e
commit 8d427bb0d0
2 changed files with 30 additions and 3 deletions

View File

@ -353,7 +353,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] != '':
@ -382,3 +382,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()

View File

@ -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