LR v0.4.13-dev:
- fix logrotate conf; - added "info" rest-api - added check on GDB wamp recovery system failure. Change-Id: Ie73f5dcf8e1253d6ef97cacc3f02554c28810f63
This commit is contained in:
parent
5a884eeb45
commit
8b8aff48ad
|
@ -10,7 +10,7 @@ rpc_alive_timer = 10
|
|||
connection_failure_timer = 300
|
||||
|
||||
log_rotation_type = size
|
||||
max_logfile_size_mb = 5120
|
||||
max_logfile_size_mb = 5
|
||||
max_logfile_count = 3
|
||||
|
||||
|
||||
|
|
|
@ -789,7 +789,6 @@ def wampConnect(wamp_conf):
|
|||
LOG.warning("WAMP Connection Failure timer: EXPIRED")
|
||||
lr_utils.LR_restart()
|
||||
|
||||
# global connFailure # da valutare la rimozione
|
||||
connFailure = Timer(CONF.connection_failure_timer, timeout)
|
||||
connFailure.start()
|
||||
LOG.warning("WAMP Connection Failure timer: STARTED")
|
||||
|
|
|
@ -124,6 +124,46 @@ class RestManager(Module.Module):
|
|||
|
||||
return redirect("/login", code=302)
|
||||
|
||||
@app.route('/info')
|
||||
def info():
|
||||
wstun_status = service_manager.wstun_status()
|
||||
if wstun_status == 0:
|
||||
wstun_status = "Online"
|
||||
else:
|
||||
wstun_status = "Offline"
|
||||
|
||||
service_list = service_manager.services_list("list")
|
||||
if service_list == "":
|
||||
service_list = "no services exposed!"
|
||||
|
||||
lr_cty = "N/A"
|
||||
from iotronic_lightningrod.lightningrod import wport
|
||||
sock_bundle = lr_utils.get_socket_info(wport)
|
||||
|
||||
if sock_bundle != "N/A":
|
||||
lr_cty = sock_bundle[2] + " - " + sock_bundle[0] \
|
||||
+ " - " + sock_bundle[1]
|
||||
|
||||
info = {
|
||||
'board_id': board.uuid,
|
||||
'board_name': board.name,
|
||||
'wagent': board.agent,
|
||||
'session_id': board.session_id,
|
||||
'timestamp': str(
|
||||
datetime.now().strftime('%Y-%m-%dT%H:%M:%S.%f')),
|
||||
'wstun_status': wstun_status,
|
||||
'board_reg_status': str(board.status),
|
||||
'iotronic_status': str(iotronic_status(board.status)),
|
||||
'service_list': service_list,
|
||||
'serial_dev': device_manager.getSerialDevice(),
|
||||
'nic': lr_cty,
|
||||
'lr_version': str(
|
||||
utils.get_version("iotronic-lightningrod")
|
||||
)
|
||||
}
|
||||
|
||||
return str(info)
|
||||
|
||||
@app.route('/status')
|
||||
def status():
|
||||
|
||||
|
@ -137,7 +177,7 @@ class RestManager(Module.Module):
|
|||
else:
|
||||
wstun_status = "Offline"
|
||||
|
||||
service_list = service_manager.services_list()
|
||||
service_list = service_manager.services_list("html")
|
||||
if service_list == "":
|
||||
service_list = "no services exposed!"
|
||||
|
||||
|
|
|
@ -1319,20 +1319,27 @@ def get_zombies():
|
|||
return nzombies
|
||||
|
||||
|
||||
def services_list():
|
||||
def services_list(format_l="list"):
|
||||
|
||||
try:
|
||||
|
||||
s_list = ""
|
||||
|
||||
with open(s_conf_FILE) as settings:
|
||||
s_conf = json.load(settings)
|
||||
|
||||
for s_uuid in s_conf['services']:
|
||||
s_service = str(s_conf['services'][s_uuid]['name']) \
|
||||
+ " - " + str(s_conf['services'][s_uuid]['public_port']) \
|
||||
+ " - " + str(s_conf['services'][s_uuid]['local_port'])
|
||||
s_list = s_list + "<li>" + s_service + "</li>"
|
||||
if format_l == "html":
|
||||
s_list = ""
|
||||
for s_uuid in s_conf['services']:
|
||||
s_service = str(s_conf['services'][s_uuid]['name']) \
|
||||
+ " - " + str(s_conf['services'][s_uuid]['public_port']) \
|
||||
+ " - " + str(s_conf['services'][s_uuid]['local_port'])
|
||||
s_list = s_list + "<li>" + s_service + "</li>"
|
||||
else:
|
||||
s_list = []
|
||||
for s_uuid in s_conf['services']:
|
||||
s_service = str(s_conf['services'][s_uuid]['name']) \
|
||||
+ " - " + str(s_conf['services'][s_uuid]['public_port']) \
|
||||
+ " - " + str(s_conf['services'][s_uuid]['local_port'])
|
||||
s_list.append(s_service)
|
||||
|
||||
except Exception as err:
|
||||
LOG.error("Error getting services list: " + str(err))
|
||||
|
|
|
@ -19,6 +19,7 @@ import asyncio
|
|||
import pkg_resources
|
||||
from six import moves
|
||||
from stevedore import extension
|
||||
from threading import Timer
|
||||
|
||||
import os
|
||||
import psutil
|
||||
|
@ -36,6 +37,9 @@ from iotronic_lightningrod.modules import utils as lr_utils
|
|||
from oslo_log import log as logging
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
global connFailureRecovery
|
||||
connFailureRecovery = None
|
||||
|
||||
|
||||
class Utility(Module.Module):
|
||||
|
||||
|
@ -185,6 +189,21 @@ def destroyWampSocket():
|
|||
|
||||
LR_PID = os.getpid()
|
||||
|
||||
global connFailureRecovery
|
||||
if connFailureRecovery != None:
|
||||
LOG.info(
|
||||
"WAMP Connection Recovery timer: CLEANED."
|
||||
)
|
||||
connFailureRecovery.cancel()
|
||||
|
||||
def timeout():
|
||||
LOG.warning("WAMP Connection Recovery timer: EXPIRED")
|
||||
lr_utils.LR_restart()
|
||||
|
||||
connFailureRecovery = Timer(30, timeout)
|
||||
connFailureRecovery.start()
|
||||
LOG.warning("WAMP Connection Recovery timer: STARTED")
|
||||
|
||||
try:
|
||||
|
||||
process = subprocess.Popen(
|
||||
|
@ -226,6 +245,10 @@ def destroyWampSocket():
|
|||
# WAMP connection found!
|
||||
wamp_conn_set = True
|
||||
# LOG.info("WAMP CONNECTION FOUND")
|
||||
LOG.info(
|
||||
"WAMP Connection Recovery timer: CANCELLED."
|
||||
)
|
||||
connFailureRecovery.cancel()
|
||||
|
||||
if wamp_conn_set == False:
|
||||
LOG.warning("WAMP CONNECTION NOT FOUND: LR restarting...")
|
||||
|
|
Loading…
Reference in New Issue