From b15b4fa3f3de9fb5abc73253ae8330620f1ef03f Mon Sep 17 00:00:00 2001 From: lloretgalleg Date: Tue, 21 Jan 2020 14:28:49 +0100 Subject: [PATCH] minor changes to log sdn, minor changes onos openflow setup Change-Id: Ic492752a9cfd1095d9bdbfd0e0f9da7b862a2702 Signed-off-by: lloretgalleg --- RO-SDN-onos_openflow/osm_rosdn_onosof/onos_of.py | 16 ++++++++++------ .../osm_rosdn_onosof/sdnconn_onosof.py | 2 +- RO-SDN-onos_openflow/setup.py | 2 +- RO/osm_ro/openmano_schemas.py | 2 ++ RO/osm_ro/openmanod.cfg | 2 ++ RO/osm_ro/openmanod.py | 2 +- RO/osm_ro/wim/openflow_conn.py | 5 ++--- 7 files changed, 19 insertions(+), 12 deletions(-) diff --git a/RO-SDN-onos_openflow/osm_rosdn_onosof/onos_of.py b/RO-SDN-onos_openflow/osm_rosdn_onosof/onos_of.py index 68833982..373b4e0a 100644 --- a/RO-SDN-onos_openflow/osm_rosdn_onosof/onos_of.py +++ b/RO-SDN-onos_openflow/osm_rosdn_onosof/onos_of.py @@ -87,8 +87,9 @@ class OfConnOnos(OpenflowConn): self.auth = self.auth.decode() self.headers['authorization'] = 'Basic ' + self.auth - self.logger = logging.getLogger('SDN.onosOF') - self.logger.setLevel( getattr(logging, params.get("of_debug", "ERROR")) ) + self.logger = logging.getLogger('openmano.sdn.onosof') + #self.logger.setLevel( getattr(logging, params.get("of_debug", "ERROR")) ) + self.logger.debug("onosof plugin initialized") self.ip_address = None def get_of_switches(self): @@ -332,15 +333,16 @@ class OfConnOnos(OpenflowConn): """ try: + self.logger.debug("del_flow: delete flow name {}".format(flow_name)) self.headers['content-type'] = None of_response = requests.delete(self.url + "flows/" + self.id + "/" + flow_name, headers=self.headers) - error_text = "Openflow response %d: %s" % (of_response.status_code, of_response.text) + error_text = "Openflow response {}: {}".format(of_response.status_code, of_response.text) if of_response.status_code != 204: self.logger.warning("del_flow " + error_text) raise OpenflowConnUnexpectedResponse(error_text) - self.logger.debug("del_flow OK " + error_text) + self.logger.debug("del_flow: {} OK,: {} ".format(flow_name, error_text)) return None except requests.exceptions.RequestException as e: @@ -363,6 +365,7 @@ class OfConnOnos(OpenflowConn): :return: Raise a openflowconnUnexpectedResponse expection in case of failure """ try: + self.logger.debug("new_flow data: {}".format(data)) if len(self.pp2ofi) == 0: self.obtain_port_correspondence() @@ -430,9 +433,10 @@ class OfConnOnos(OpenflowConn): self.headers['content-type'] = 'application/json' path = self.url + "flows/" + self.id + self.logger.debug("new_flow post: {}".format(flow)) of_response = requests.post(path, headers=self.headers, data=json.dumps(flow) ) - error_text = "Openflow response %d: %s" % (of_response.status_code, of_response.text) + error_text = "Openflow response {}: {}".format(of_response.status_code, of_response.text) if of_response.status_code != 201: self.logger.warning("new_flow " + error_text) raise OpenflowConnUnexpectedResponse(error_text) @@ -441,7 +445,7 @@ class OfConnOnos(OpenflowConn): data['name'] = flowId - self.logger.debug("new_flow OK " + error_text) + self.logger.debug("new_flow id: {},: {} ".format(flowId, error_text)) return None except requests.exceptions.RequestException as e: diff --git a/RO-SDN-onos_openflow/osm_rosdn_onosof/sdnconn_onosof.py b/RO-SDN-onos_openflow/osm_rosdn_onosof/sdnconn_onosof.py index 79c14412..3a4e39b0 100644 --- a/RO-SDN-onos_openflow/osm_rosdn_onosof/sdnconn_onosof.py +++ b/RO-SDN-onos_openflow/osm_rosdn_onosof/sdnconn_onosof.py @@ -29,7 +29,7 @@ class SdnConnectorOnosOf(SdnConnectorOpenFlow): def __init__(self, wim, wim_account, config=None, logger=None): """Creates a connectivity based on pro-active openflow rules """ - self.logger = logging.getLogger('openmano.sdnconn.onosof') + self.logger = logging.getLogger('openmano.sdn.onosof') super().__init__(wim, wim_account, config, logger) of_params = { "of_url": wim["wim_url"], diff --git a/RO-SDN-onos_openflow/setup.py b/RO-SDN-onos_openflow/setup.py index 7050c0ce..333ee588 100644 --- a/RO-SDN-onos_openflow/setup.py +++ b/RO-SDN-onos_openflow/setup.py @@ -44,7 +44,7 @@ setup( packages=[_name], include_package_data=True, - dependency_links=["git+https://osm.etsi.org/gerrit/osm/RO.git#egg=osm-ro&subdirectory=RO"], + dependency_links=["git+https://osm.etsi.org/gerrit/osm/RO.git#egg=osm-ro"], install_requires=["requests", "osm-ro"], setup_requires=['setuptools-version-command'], entry_points={ diff --git a/RO/osm_ro/openmano_schemas.py b/RO/osm_ro/openmano_schemas.py index 3dd72e27..dda608f0 100644 --- a/RO/osm_ro/openmano_schemas.py +++ b/RO/osm_ro/openmano_schemas.py @@ -120,6 +120,7 @@ config_schema = { "log_level_http": log_level_schema, "log_level_console": log_level_schema, "log_level_ovim": log_level_schema, + "log_level_sdn": log_level_schema, "log_file_db": path_schema, "log_file_vim": path_schema, "log_file_wim": path_schema, @@ -127,6 +128,7 @@ config_schema = { "log_file_http": path_schema, "log_file_console": path_schema, "log_file_ovim": path_schema, + "log_file_sdn": path_schema, "log_socket_host": nameshort_schema, "log_socket_port": port_schema, "log_file": path_schema, diff --git a/RO/osm_ro/openmanod.cfg b/RO/osm_ro/openmanod.cfg index 6e743da4..ce53ba95 100644 --- a/RO/osm_ro/openmanod.cfg +++ b/RO/osm_ro/openmanod.cfg @@ -81,6 +81,8 @@ log_level_http: DEBUG #Main engine log levels #log_file_console: /opt/openmano/logs/openmano_console.log #log_level_ovim: DEBUG #ovim library log levels #log_file_ovim: /opt/openmano/logs/openmano_ovim.log +#log_level_sdn: DEBUG +#log_file_sdn: /opt/openmano/logs/openmano_sdn.log #Uncomment to send logs via IP to an external host #log_socket_host: localhost diff --git a/RO/osm_ro/openmanod.py b/RO/osm_ro/openmanod.py index 19fb6866..81ea96f1 100755 --- a/RO/osm_ro/openmanod.py +++ b/RO/osm_ro/openmanod.py @@ -292,7 +292,7 @@ if __name__ == "__main__": logger.critical("Starting openmano server version: '%s %s' command: '%s'", ro_version, version_date, " ".join(sys.argv)) - for log_module in ("nfvo", "http", "vim", "wim", "db", "console", "ovim"): + for log_module in ("nfvo", "http", "vim", "wim", "db", "console", "ovim","sdn"): log_level_module = "log_level_" + log_module log_file_module = "log_file_" + log_module logger_module = logging.getLogger('openmano.' + log_module) diff --git a/RO/osm_ro/wim/openflow_conn.py b/RO/osm_ro/wim/openflow_conn.py index 655860e4..c7195bd1 100644 --- a/RO/osm_ro/wim/openflow_conn.py +++ b/RO/osm_ro/wim/openflow_conn.py @@ -86,8 +86,7 @@ class OpenflowConn: self.name = "openflow_conector" self.pp2ofi = {} # From Physical Port to OpenFlow Index self.ofi2pp = {} # From OpenFlow Index to Physical Port - self.logger = logging.getLogger('openflow_conn') - self.logger.setLevel(getattr(logging, params.get("of_debug", "ERROR"))) + self.logger = logging.getLogger('openmano.sdn.openflow_conn') def get_of_switches(self): """" @@ -161,7 +160,7 @@ class SdnConnectorOpenFlow(SdnConnectorBase): flow_fields = ('priority', 'vlan', 'ingress_port', 'actions', 'dst_mac', 'src_mac', 'net_id') def __init__(self, wim, wim_account, config=None, logger=None, of_connector=None): - self.logger = logger or logging.getLogger('openmano.sdnconn.openflow') + self.logger = logger or logging.getLogger('openmano.sdn.openflow_conn') self.of_connector = of_connector self.of_controller_nets_with_same_vlan = config.get("of_controller_nets_with_same_vlan", False) -- 2.17.1