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
|
ogagent (1.4.9-1) stable; urgency=medium
|
||||||
|
|
||||||
* Notify ogcore when agent shuts down within oglive
|
* 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:
|
if buffer:
|
||||||
for l in buffer.split ('@'):
|
for l in buffer.split ('@'):
|
||||||
if not len (l): continue
|
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:
|
## 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 = {}
|
post_params = {}
|
||||||
for param in l.split ("\r"):
|
for param in l.split ("\r"):
|
||||||
|
|
|
@ -237,22 +237,30 @@ class ogLiveWorker(ServerWorker):
|
||||||
time.sleep (1)
|
time.sleep (1)
|
||||||
|
|
||||||
def interfaceAdmin (self, method, parametros=[]):
|
def interfaceAdmin (self, method, parametros=[]):
|
||||||
exe = '{}/{}'.format (self.pathinterface, method)
|
if method in ['Apagar', 'CambiarAcceso', 'Configurar', 'CrearImagen', 'EjecutarScript', 'getConfiguration', 'getIpAddress', 'IniciarSesion', 'InventarioHardware', 'InventarioSoftware', 'Reiniciar', 'RestaurarImagen']:
|
||||||
## for development only. Will be removed when the referenced bash code (/opt/opengnsys/lib/engine/bin/*.lib) is translated into python
|
## python
|
||||||
LANG = os.environ.get ('LANG', 'en_GB.UTF-8').replace ('UTF_8', 'UTF-8')
|
logger.debug (f'({method}) is a python method')
|
||||||
devel_bash_prefix = f'''
|
exe = '{}/{}.py'.format (self.pathinterface, method)
|
||||||
PATH=/opt/opengnsys/scripts/:$PATH;
|
proc = [exe]+parametros
|
||||||
source /opt/opengnsys/etc/lang.{LANG}.conf;
|
else: ## ConsolaRemota procesaCache
|
||||||
for I in /opt/opengnsys/lib/engine/bin/*.lib; do source $I; done;
|
## bash
|
||||||
for i in $(declare -F |cut -f3 -d" "); do export -f $i; done;
|
logger.debug (f'({method}) is a bash method')
|
||||||
'''
|
exe = '{}/{}'.format (self.pathinterface, method)
|
||||||
|
|
||||||
if parametros:
|
LANG = os.environ.get ('LANG', 'en_GB.UTF-8').replace ('UTF_8', 'UTF-8')
|
||||||
proc = ['bash', '-c', '{} {} {}'.format (devel_bash_prefix, exe, ' '.join (parametros))]
|
devel_bash_prefix = f'''
|
||||||
else:
|
PATH=/opt/opengnsys/scripts/:$PATH;
|
||||||
proc = ['bash', '-c', '{} {}'.format (devel_bash_prefix, exe)]
|
source /opt/opengnsys/etc/lang.{LANG}.conf;
|
||||||
logger.debug ('subprocess.run ("{}", capture_output=True)'.format (proc))
|
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)
|
p = subprocess.Popen (proc, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
if self.pid_q:
|
if self.pid_q:
|
||||||
self.pid_q.put (p.pid)
|
self.pid_q.put (p.pid)
|
||||||
|
|
Loading…
Reference in New Issue