Compare commits
3 Commits
2d6cd923a0
...
a2df6afda7
Author | SHA1 | Date |
---|---|---|
|
a2df6afda7 | |
|
376dec466f | |
|
58b7f0d406 |
|
@ -306,15 +306,26 @@ class ogAdmClientWorker (ogLiveWorker):
|
|||
|
||||
logger.info ('onActivation ok')
|
||||
|
||||
@check_secret
|
||||
def process_status (self, path, get_params, post_params, server):
|
||||
def do_status (self, post_params):
|
||||
cfg = self.LeeConfiguracion()
|
||||
thr_status = {}
|
||||
for k in self.thread_list:
|
||||
thr_status[k] = {
|
||||
'running': self.thread_list[k]['running'],
|
||||
'result': self.thread_list[k]['result'],
|
||||
}
|
||||
return thr_status
|
||||
return {
|
||||
'nfn': 'RESPUESTA_status',
|
||||
'mac': self.mac,
|
||||
'ip': self.IPlocal,
|
||||
'cfg': self.cfg2obj (cfg),
|
||||
'threads': thr_status,
|
||||
}
|
||||
|
||||
@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))
|
||||
return self._long_running_job ('status', self.do_status, args=(post_params,))
|
||||
|
||||
@check_secret
|
||||
def process_popup (self, path, get_params, post_params, server):
|
||||
|
|
|
@ -200,6 +200,15 @@ class ogLiveWorker(ServerWorker):
|
|||
logger.info ('local IP is "{}"'.format (self.IPlocal))
|
||||
return True
|
||||
|
||||
def tomaMAClocal (self):
|
||||
## tomaIPlocal() calls interfaceAdm('getIpAddress')
|
||||
## getIpAddress runs 'ip addr show' and returns the IP address of every network interface except "lo"
|
||||
## (ie. breaks badly if there's more than one network interface)
|
||||
## let's make the same assumptions here
|
||||
mac = subprocess.run (["ip -json link show |jq -r '.[] |select (.ifname != \"lo\") |.address'"], shell=True, capture_output=True, text=True)
|
||||
self.mac = mac.stdout.strip()
|
||||
return True
|
||||
|
||||
def enviaMensajeServidor (self, path, obj={}):
|
||||
obj['iph'] = self.IPlocal ## Ip del ordenador
|
||||
obj['ido'] = self.idordenador ## Identificador del ordenador
|
||||
|
@ -264,6 +273,30 @@ class ogLiveWorker(ServerWorker):
|
|||
logger.debug ('parametroscfg ({})'.format (parametroscfg))
|
||||
return parametroscfg
|
||||
|
||||
def cfg2obj (self, cfg):
|
||||
obj = []
|
||||
ptrPar = cfg.split ('\n')
|
||||
for line in ptrPar:
|
||||
elem = {}
|
||||
ptrCfg = line.split ('\t')
|
||||
|
||||
## Si la 1ª línea solo incluye el número de serie del equipo; actualizar BD.
|
||||
#if es_la_primera_iteracion and 1 == len (ptrCfg):
|
||||
# elem['ser'] = ptrCfg[0].split ('=')[1]
|
||||
# continue ## si hemos entrado en este if, entonces no hacemos todo lo demas de particiones y tal: iteramos el bucle de nuevo
|
||||
|
||||
elem['disk'] = ptrCfg[0].split ('=')[1] ## Número de disco
|
||||
elem['par'] = ptrCfg[1].split ('=')[1] ## Número de partición
|
||||
elem['cpt'] = ptrCfg[2].split ('=')[1] or 0 ## Código de partición
|
||||
elem['sfi'] = ptrCfg[3].split ('=')[1] ## Sistema de ficheros
|
||||
elem['soi'] = ptrCfg[4].split ('=')[1] ## Nombre del S.O. instalado
|
||||
elem['tam'] = ptrCfg[5].split ('=')[1] ## Tamaño de la partición
|
||||
elem['uso'] = ptrCfg[6].split ('=')[1] ## Porcentaje de uso del S.F.
|
||||
|
||||
obj.append (elem)
|
||||
|
||||
return obj
|
||||
|
||||
def onActivation (self):
|
||||
if not os.path.exists ('/scripts/oginit'):
|
||||
## no estamos en oglive, este modulo no debe cargarse
|
||||
|
@ -272,6 +305,7 @@ class ogLiveWorker(ServerWorker):
|
|||
|
||||
self.pathinterface = None
|
||||
self.IPlocal = None ## Ip del ordenador
|
||||
self.mac = None ## MAC del ordenador
|
||||
self.idordenador = None ## Identificador del ordenador
|
||||
self.nombreordenador = None ## Nombre del ordenador
|
||||
self.cache = None
|
||||
|
@ -294,6 +328,9 @@ class ogLiveWorker(ServerWorker):
|
|||
if not self.tomaIPlocal():
|
||||
raise Exception ('Se han generado errores. No se puede continuar la ejecución de este módulo')
|
||||
|
||||
if not self.tomaMAClocal():
|
||||
raise Exception ('Se han generado errores. No se puede continuar la ejecución de este módulo')
|
||||
|
||||
threading.Thread (name='monitoring_thread', target=self.mon, daemon=True).start()
|
||||
|
||||
def _long_running_job (self, name, f, args):
|
||||
|
|
Loading…
Reference in New Issue