#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):
|
def process_client_popup(self, params):
|
||||||
self.REST.sendMessage('popup_done', 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
|
Returns client configuration
|
||||||
:param path:
|
:param path:
|
||||||
|
@ -372,7 +372,26 @@ class OpenGnSysWorker(ServerWorker):
|
||||||
:param post_params:
|
:param post_params:
|
||||||
:param server:
|
:param server:
|
||||||
"""
|
"""
|
||||||
logger.debug('Recieved {} operation'.format(path))
|
data = []
|
||||||
|
logger.debug('Recieved hardware operation')
|
||||||
self.checkSecret(server)
|
self.checkSecret(server)
|
||||||
# Returning raw data
|
# Processing data
|
||||||
return operations.get_hardware()
|
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():
|
def poweroff():
|
||||||
"""
|
"""
|
||||||
Simple poweroff using OpenGnsys script
|
Simple power off using OpenGnsys script
|
||||||
"""
|
"""
|
||||||
# Workaround for dummy thread
|
# Workaround for dummy thread
|
||||||
if six.PY3 is False:
|
if six.PY3 is False:
|
||||||
|
@ -178,6 +178,7 @@ def get_configuration():
|
||||||
"""
|
"""
|
||||||
Returns client's configuration
|
Returns client's configuration
|
||||||
Warning: this operation may take some time
|
Warning: this operation may take some time
|
||||||
|
:return:
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
_exec_ogcommand('/opt/opengnsys/interfaceAdm/getConfiguration')
|
_exec_ogcommand('/opt/opengnsys/interfaceAdm/getConfiguration')
|
||||||
|
@ -191,6 +192,7 @@ def get_configuration():
|
||||||
def get_hardware():
|
def get_hardware():
|
||||||
"""
|
"""
|
||||||
Returns client's hardware list
|
Returns client's hardware list
|
||||||
|
:return:
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
filepath = _exec_ogcommand('/opt/opengnsys/scripts/listHardwareInfo').strip()
|
filepath = _exec_ogcommand('/opt/opengnsys/scripts/listHardwareInfo').strip()
|
||||||
|
@ -200,3 +202,20 @@ def get_hardware():
|
||||||
except IOError:
|
except IOError:
|
||||||
harddata = ''
|
harddata = ''
|
||||||
return 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