#750: Route {{{GET /getconfig}}} renamed as {{{GET /config}}}; route {{{GET /hardware}}} returns data in JSON format; new basic route {{{GET /software?disk=NDisk&part=NPart}}}
parent
a5905575e2
commit
9e81e9020c
|
@ -319,7 +319,7 @@ class OpenGnSysWorker(ServerWorker):
|
|||
def process_client_popup(self, params):
|
||||
self.REST.sendMessage('popup_done', params)
|
||||
|
||||
def process_getconfig(self, path, get_params, post_params, server):
|
||||
def process_config(self, path, get_params, post_params, server):
|
||||
"""
|
||||
Returns client configuration
|
||||
:param path:
|
||||
|
@ -372,7 +372,26 @@ class OpenGnSysWorker(ServerWorker):
|
|||
:param post_params:
|
||||
:param server:
|
||||
"""
|
||||
logger.debug('Recieved {} operation'.format(path))
|
||||
data = []
|
||||
logger.debug('Recieved hardware operation')
|
||||
self.checkSecret(server)
|
||||
# Returning raw data
|
||||
return operations.get_hardware()
|
||||
# Processing data
|
||||
try:
|
||||
for comp in operations.get_hardware():
|
||||
data.append({'component': comp.split('=')[0], 'value': comp.split('=')[1]})
|
||||
except:
|
||||
pass
|
||||
# Return list of hardware components
|
||||
return data
|
||||
|
||||
def process_software(self, path, get_params, post_params, server):
|
||||
"""
|
||||
Returns software profile installed on an operating system
|
||||
:param path:
|
||||
:param get_params:
|
||||
:param post_params:
|
||||
:param server:
|
||||
:return:
|
||||
"""
|
||||
logger.debug('Recieved software operation with params: {}'.format(post_params))
|
||||
return operations.get_software(post_params['disk'], post_params['part'])
|
||||
|
|
|
@ -164,7 +164,7 @@ def reboot():
|
|||
|
||||
def poweroff():
|
||||
"""
|
||||
Simple poweroff using OpenGnsys script
|
||||
Simple power off using OpenGnsys script
|
||||
"""
|
||||
# Workaround for dummy thread
|
||||
if six.PY3 is False:
|
||||
|
@ -178,6 +178,7 @@ def get_configuration():
|
|||
"""
|
||||
Returns client's configuration
|
||||
Warning: this operation may take some time
|
||||
:return:
|
||||
"""
|
||||
try:
|
||||
_exec_ogcommand('/opt/opengnsys/interfaceAdm/getConfiguration')
|
||||
|
@ -191,6 +192,7 @@ def get_configuration():
|
|||
def get_hardware():
|
||||
"""
|
||||
Returns client's hardware list
|
||||
:return:
|
||||
"""
|
||||
try:
|
||||
filepath = _exec_ogcommand('/opt/opengnsys/scripts/listHardwareInfo').strip()
|
||||
|
@ -200,3 +202,20 @@ def get_hardware():
|
|||
except IOError:
|
||||
harddata = ''
|
||||
return harddata
|
||||
|
||||
|
||||
def get_software(disk, part):
|
||||
"""
|
||||
Returns software list installed on an operating system
|
||||
:param disk:
|
||||
:param part:
|
||||
:return:
|
||||
"""
|
||||
try:
|
||||
filepath = _exec_ogcommand('/opt/opengnsys/scripts/listSoftwareInfo {} {}'.format(disk, part)).strip()
|
||||
# Returns content of configuration file, skipping the header line and newline characters
|
||||
with open(filepath, 'r') as f:
|
||||
softdata = map(str.strip, f.readlines())
|
||||
except IOError:
|
||||
softdata = ''
|
||||
return softdata
|
||||
|
|
Loading…
Reference in New Issue