#750: New route {{{GET /hardware}}}.
parent
bb1ff4dc1d
commit
863e038f24
|
@ -334,7 +334,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] != '':
|
||||
|
@ -363,3 +363,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()
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue