refs #1698 use python scripts for most of the functionality in interfaceAdm
parent
5e4ef1851f
commit
c218eff895
|
@ -1,3 +1,16 @@
|
|||
ogagent (1.6.0-1) stable; urgency=medium
|
||||
|
||||
* Don't invoke bash code for some functionalities
|
||||
|
||||
-- OpenGnsys developers <info@opengnsys.es> Wed, 12 Mar 2025 11:59:36 +0100
|
||||
|
||||
ogagent (1.5.0-1) stable; urgency=medium
|
||||
|
||||
* Accept new "ptt" parameter in /ogAdmCli/Configurar
|
||||
* No longer recognise the unused "che" parameter in /ogAdmCli/Configurar
|
||||
|
||||
-- OpenGnsys developers <info@opengnsys.es> Wed, 12 Mar 2025 11:45:37 +0100
|
||||
|
||||
ogagent (1.4.9-1) stable; urgency=medium
|
||||
|
||||
* Notify ogcore when agent shuts down within oglive
|
||||
|
|
|
@ -1 +1 @@
|
|||
1.4.9
|
||||
1.6.0
|
||||
|
|
|
@ -173,7 +173,7 @@ class ogAdmClientWorker (ogLiveWorker):
|
|||
if buffer:
|
||||
for l in buffer.split ('@'):
|
||||
if not len (l): continue
|
||||
logger.debug ('line ({})'.format (l))
|
||||
logger.debug ('line ({})'.format (l.replace ('\r', '\\r'))) ## change \r so as not to mess with the log
|
||||
## at this point, an option would be fire up a curl to localhost, but we can also parse the params and locally call the desired function:
|
||||
post_params = {}
|
||||
for param in l.split ("\r"):
|
||||
|
|
|
@ -237,22 +237,30 @@ class ogLiveWorker(ServerWorker):
|
|||
time.sleep (1)
|
||||
|
||||
def interfaceAdmin (self, method, parametros=[]):
|
||||
exe = '{}/{}'.format (self.pathinterface, method)
|
||||
## for development only. Will be removed when the referenced bash code (/opt/opengnsys/lib/engine/bin/*.lib) is translated into python
|
||||
LANG = os.environ.get ('LANG', 'en_GB.UTF-8').replace ('UTF_8', 'UTF-8')
|
||||
devel_bash_prefix = f'''
|
||||
PATH=/opt/opengnsys/scripts/:$PATH;
|
||||
source /opt/opengnsys/etc/lang.{LANG}.conf;
|
||||
for I in /opt/opengnsys/lib/engine/bin/*.lib; do source $I; done;
|
||||
for i in $(declare -F |cut -f3 -d" "); do export -f $i; done;
|
||||
'''
|
||||
if method in ['Apagar', 'CambiarAcceso', 'Configurar', 'CrearImagen', 'EjecutarScript', 'getConfiguration', 'getIpAddress', 'IniciarSesion', 'InventarioHardware', 'InventarioSoftware', 'Reiniciar', 'RestaurarImagen']:
|
||||
## python
|
||||
logger.debug (f'({method}) is a python method')
|
||||
exe = '{}/{}.py'.format (self.pathinterface, method)
|
||||
proc = [exe]+parametros
|
||||
else: ## ConsolaRemota procesaCache
|
||||
## bash
|
||||
logger.debug (f'({method}) is a bash method')
|
||||
exe = '{}/{}'.format (self.pathinterface, method)
|
||||
|
||||
if parametros:
|
||||
proc = ['bash', '-c', '{} {} {}'.format (devel_bash_prefix, exe, ' '.join (parametros))]
|
||||
else:
|
||||
proc = ['bash', '-c', '{} {}'.format (devel_bash_prefix, exe)]
|
||||
logger.debug ('subprocess.run ("{}", capture_output=True)'.format (proc))
|
||||
LANG = os.environ.get ('LANG', 'en_GB.UTF-8').replace ('UTF_8', 'UTF-8')
|
||||
devel_bash_prefix = f'''
|
||||
PATH=/opt/opengnsys/scripts/:$PATH;
|
||||
source /opt/opengnsys/etc/lang.{LANG}.conf;
|
||||
for I in /opt/opengnsys/lib/engine/bin/*.lib; do source $I; done;
|
||||
for i in $(declare -F |cut -f3 -d" "); do export -f $i; done;
|
||||
'''
|
||||
|
||||
if parametros:
|
||||
proc = ['bash', '-c', '{} {} {}'.format (devel_bash_prefix, exe, ' '.join (parametros))]
|
||||
else:
|
||||
proc = ['bash', '-c', '{} {}'.format (devel_bash_prefix, exe)]
|
||||
|
||||
logger.debug ('subprocess.run ("{}")'.format (' '.join (proc)))
|
||||
p = subprocess.Popen (proc, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
if self.pid_q:
|
||||
self.pid_q.put (p.pid)
|
||||
|
|
Loading…
Reference in New Issue