From: Paul Greenberg <[email protected]> There is no INFO or WARN level log function. It is either ERROR or FATAL. This PR adds it.
Signed-off-by: Paul Greenberg <[email protected]> Submitted-at: https://github.com/openvswitch/ovs/pull/229 --- Posting to ovs-dev so that it gets reviewed. ovn/utilities/ovn-docker-overlay-driver.in | 14 ++++++++++++++ python/ovs/util.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/ovn/utilities/ovn-docker-overlay-driver.in b/ovn/utilities/ovn-docker-overlay-driver.in index 65edfcd9d19e..28778d1e5263 100755 --- a/ovn/utilities/ovn-docker-overlay-driver.in +++ b/ovn/utilities/ovn-docker-overlay-driver.in @@ -110,6 +110,7 @@ def prepare(): fo = open(PLUGIN_FILE, "w") fo.write("tcp://0.0.0.0:5000") fo.close() + ovs.util.ovs_info("configuration file: %s" % (PLUGIN_FILE), vlog) except Exception as e: ovs.util.ovs_fatal(0, "Failed to write to spec file (%s)" % str(e), vlog) @@ -437,6 +438,19 @@ def network_leave(): return jsonify({}) [email protected]('/', defaults={'path': ''}) [email protected]('/<path:path>') +def unsupported_libnetwork_call(path): + ''' + This function handles any new endpoints that are being added to + Docker libnetwork remote network plugin API. If this function receives + a request and that request is valid, there is a need to refactor + this plugin, because a new functionality is being introduced. + ''' + ovs.util.ovs_warn("received unsupported libnetwork %s request to: %s, with payload: %s" % (request.method, request.path, request.data), vlog) + + return jsonify({}) + if __name__ == '__main__': prepare() app.run(host='0.0.0.0') diff --git a/python/ovs/util.py b/python/ovs/util.py index 411ac99c85a4..13a34d8c302b 100644 --- a/python/ovs/util.py +++ b/python/ovs/util.py @@ -93,3 +93,31 @@ def ovs_fatal(*args, **kwargs): ovs_error(*args, **kwargs) sys.exit(1) + + +def ovs_info(message, vlog=None): + """Prints 'message' on stdout and emits an INFO level log message to + 'vlog' if supplied. + + 'message' should not end with a new-line, because this function will add + one itself.""" + + info_msg = "%s: %s" % (PROGRAM_NAME, message) + + sys.stdout.write("%s\n" % info_msg) + if vlog: + vlog.info(info_msg) + + +def ovs_warn(message, vlog=None): + """Prints 'message' on stdout and emits an WARN level log message to + 'vlog' if supplied. + + 'message' should not end with a new-line, because this function will add + one itself.""" + + info_msg = "%s: %s" % (PROGRAM_NAME, message) + + sys.stdout.write("%s\n" % info_msg) + if vlog: + vlog.warn(info_msg) -- 2.16.1 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
