refs #1483 report progress of operations to ogcore

pull/15/head
Natalia Serrano 2025-02-18 14:03:31 +01:00
parent 1de04f3a7a
commit d5275c6dbe
4 changed files with 18 additions and 7 deletions

View File

@ -1,4 +1,10 @@
ogagent (1.4.7-1) UNRELEASED; urgency=medium
ogagent (1.4.8-1) stable; urgency=medium
* Optionally return disk config in /status
-- OpenGnsys developers <info@opengnsys.es> Tue, 18 Feb 2025 13:48:54 +0100
ogagent (1.4.7-1) stable; urgency=medium
* Merge server modules
* Track the progress of children

View File

@ -1 +1 @@
1.4.7
1.4.8

View File

@ -337,20 +337,25 @@ class ogAdmClientWorker (ogLiveWorker):
@check_secret
def process_status (self, path, get_params, post_params, server):
logger.debug ('in process_status, path "{}" get_params "{}" post_params "{}" server "{}"'.format (path, get_params, post_params, server))
cfg = self.LeeConfiguracion()
full_config = 'full-config' in post_params and post_params['full-config']
thr_status = {}
for k in self.thread_list:
thr_status[k] = {
'running': self.thread_list[k]['running'],
'result': self.thread_list[k]['result'],
}
return {
ret = {
'nfn': 'RESPUESTA_status',
'mac': self.mac,
'st': 'OGL',
'ip': self.IPlocal,
'cfg': self.cfg2obj (cfg),
'threads': thr_status,
}
if full_config:
cfg = self.LeeConfiguracion()
ret['cfg'] = self.cfg2obj (cfg)
return ret
@check_secret
def process_popup (self, path, get_params, post_params, server):

View File

@ -224,8 +224,7 @@ class ogLiveWorker(ServerWorker):
p = self._extract_progress (k, lines)
if p:
m = { "job_id": k, "progress": p }
logger.debug (f'would sendMessage ({m})')
#self.REST.sendMessage ('clients/status/webhook', { "job_id": "EjecutarScript-333feb3f", "progress": 0.91337824 })
self.REST.sendMessage ('clients/status/webhook', { "job_id": k, "progress": p })
elem['thread'].join (0.05)
if not elem['thread'].is_alive():
@ -240,8 +239,9 @@ class ogLiveWorker(ServerWorker):
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
devel_bash_prefix = '''
devel_bash_prefix = f'''
PATH=/opt/opengnsys/scripts/:$PATH;
source /opt/opengnsys/etc/lang.{os.environ.get ('LANG', 'en_GB.UTF-8')}.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;
'''