From b2dc8a68ed70df76e01d1b5c3c26ee315c608b76 Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Sat, 22 Apr 2023 18:02:01 +0200 Subject: [PATCH] report faults --- app.py | 10 +++++++++- xmlutils.py | 2 ++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app.py b/app.py index 0b9cdbc..72697d3 100644 --- a/app.py +++ b/app.py @@ -4,7 +4,7 @@ import configparser import logging -from xml.etree.ElementTree import fromstring +from xml.etree.ElementTree import fromstring, tostring from flask import Flask, make_response, render_template, request, session from flask_caching import Cache @@ -63,6 +63,11 @@ def generate_config(params=None, serial=None, config_file='./config/femtocells.i def root(): return 'This is a femto-acs/tr069 server' +def fault(tree, node): + """ handle a Fault """ + LOG.error("Fault: %s", tostring(node).decode('utf-8')) + return "Fault" + def inform(tree, node): """ handle a device Inform request """ cwmpid = get_cwmp_id(tree) @@ -149,6 +154,9 @@ def acs(): method, node = method + if method == "Fault": + return fault(tree, node) + if method == "Inform": return inform(tree, node) diff --git a/xmlutils.py b/xmlutils.py index 233746d..1b18a75 100644 --- a/xmlutils.py +++ b/xmlutils.py @@ -14,6 +14,8 @@ def get_cwmp_method(root): return None for child in body: + if child.tag == '{' + XML_NS['soap-env'] + '}Fault': + return ('Fault', child) if child.tag == '{urn:dslforum-org:cwmp-1-0}Inform': return ('Inform', child) if child.tag == '{urn:dslforum-org:cwmp-1-0}SetParameterValuesResponse':