added permissions api and websocket stuff

This commit is contained in:
2019-11-28 19:39:53 +01:00
parent c4b54357f7
commit a709dbcaef
14 changed files with 229 additions and 24 deletions

View File

@@ -106,6 +106,7 @@ def get_recorder_adapter(recorder_info: dict) -> RecorderAdapter:
def check_capture_agent_state(a: dict):
agent_state_error_msg = None
logger.debug("Checking Agent {}".format(a['name']))
c = get_calender(a['name'])
is_recording_in_calendar = len(list(c.timeline.now())) >= 1
@@ -122,6 +123,7 @@ def check_capture_agent_state(a: dict):
else:
logger.info(rec.get_recording_status())
logger.error("FATAL - recorder {} must be recording but is not!!!!".format(a['name']))
agent_state_error_msg = "FATAL - recorder must be recording but is not!"
with agent_states_lock:
agent_states[a['name']] = 'FATAL - recorder is NOT recording, but should!'
except LrcException as e:
@@ -129,12 +131,14 @@ def check_capture_agent_state(a: dict):
logger.error("Could not check state of recorder {}, Address: {}".format(a['name'], recorder_info['ip']))
else:
logger.error("FATAL: {} is not in capturing state...but should be!!".format(a['name']))
agent_state_error_msg = "FATAL - is not in capturing state...but should be!"
else:
recorder_info = get_recorder_by_name(a['name'])
try:
rec = get_recorder_adapter(recorder_info)
if rec.is_recording():
logger.error("FATAL - recorder must not be recording!!!!")
agent_state_error_msg = "FATAL - is not in capturing state...but should be!"
with agent_states_lock:
agent_states[a['name']] = 'FATAL - recorder IS recording, but should NOT!'
else:
@@ -144,6 +148,11 @@ def check_capture_agent_state(a: dict):
except LrcException as e:
logger.fatal("Exception occurred: {}".format(str(e)))
logger.error("Could not check state of recorder {}, Address: {}".format(a['name'], recorder_info['ip']))
agent_state_error_msg = "FATAL - Could not check state of recorder! Address: {}".format(recorder_info['ip'])
if agent_state_error_msg is None:
return True, "", a['name']
return False, agent_state_error_msg, a['name']
def ping_capture_agent(a: dict):
@@ -157,8 +166,10 @@ def ping_capture_agent(a: dict):
universal_newlines=True # return string not bytes
)
logger.info("Successfully pinged {} ({}). :-)".format(a['name'], recorder_ip))
return True, "", a['name']
except subprocess.CalledProcessError:
logger.error("Can not ping {} ({})!!".format(a['name'], recorder_ip))
return False, "Unable to ping", a['name']
agents = get_capture_agents()