Fixing bug 1437 82/10282/5
authorsousaedu <eduardo.sousa@canonical.com>
Tue, 9 Feb 2021 14:30:01 +0000 (15:30 +0100)
committersousaedu <eduardo.sousa@canonical.com>
Wed, 10 Feb 2021 00:22:16 +0000 (01:22 +0100)
This patchset fixes bug 1437. There will need to be done extra
changes to make logging better.

Change-Id: I2b0e477093eba798c6cd4ce7bcc105ee78b610ed
Signed-off-by: sousaedu <eduardo.sousa@canonical.com>
27 files changed:
Dockerfile-local
NG-RO/osm_ng_ro/ro_main.py
RO-SDN-arista_cloudvision/osm_rosdn_arista_cloudvision/wimconn_arista.py
RO-SDN-dpb/osm_rosdn_dpb/wimconn_dpb.py
RO-SDN-dynpac/osm_rosdn_dynpac/wimconn_dynpac.py
RO-SDN-floodlight_openflow/osm_rosdn_floodlightof/floodlight_of.py
RO-SDN-floodlight_openflow/osm_rosdn_floodlightof/sdnconn_floodlightof.py
RO-SDN-ietfl2vpn/osm_rosdn_ietfl2vpn/wimconn_ietfl2vpn.py
RO-SDN-juniper_contrail/osm_rosdn_juniper_contrail/sdn_api.py
RO-SDN-juniper_contrail/osm_rosdn_juniper_contrail/sdn_assist_juniper_contrail.py
RO-SDN-odl_openflow/osm_rosdn_odlof/odl_of.py
RO-SDN-odl_openflow/osm_rosdn_odlof/sdnconn_odlof.py
RO-SDN-onos_openflow/osm_rosdn_onosof/onos_of.py
RO-SDN-onos_openflow/osm_rosdn_onosof/sdnconn_onosof.py
RO-SDN-onos_vpls/osm_rosdn_onos_vpls/sdn_assist_onos_vpls.py
RO-VIM-aws/osm_rovim_aws/vimconn_aws.py
RO-VIM-azure/osm_rovim_azure/vimconn_azure.py
RO-VIM-fos/osm_rovim_fos/vimconn_fos.py
RO-VIM-opennebula/osm_rovim_opennebula/vimconn_opennebula.py
RO-VIM-openstack/osm_rovim_openstack/vimconn_openstack.py
RO-VIM-openvim/osm_rovim_openvim/vimconn_openvim.py
RO-VIM-vmware/osm_rovim_vmware/vimconn_vmware.py
RO-plugin/osm_ro_plugin/openflow_conn.py
RO-plugin/osm_ro_plugin/sdn_dummy.py
RO-plugin/osm_ro_plugin/sdnconn.py
RO-plugin/osm_ro_plugin/vim_dummy.py
RO-plugin/osm_ro_plugin/vimconn.py

index 92e4b03..72b28ce 100644 (file)
@@ -20,6 +20,7 @@ LABEL authors="Alfonso Tierno"
 RUN apt-get update && apt-get install -y git python3 python3-pip \
     && python3 -m pip install --upgrade pip \
     && DEBIAN_FRONTEND=noninteractive apt-get -y install libssl-dev libmysqlclient-dev mysql-client \
+    build-essential libffi-dev cargo \
     && DEBIAN_FRONTEND=noninteractive python3 -m pip install -U networking-l2gw  \
     && DEBIAN_FRONTEND=noninteractive python3 -m pip install -U progressbar pyvmomi pyvcloud==19.1.1  \
     && DEBIAN_FRONTEND=noninteractive apt-get -y install genisoimage
@@ -32,7 +33,7 @@ RUN DEBIAN_FRONTEND=noninteractive  apt-get -y install python3-neutronclient pyt
     && mv /tmp/libzenohc.so /usr/local/lib/libzenohc.so \
     && DEBIAN_FRONTEND=noninteractive python3 -m pip install -U jsonrpclib-pelix cvprac "azure==4.0.0" boto \
     pyone "oca @ git+https://github.com/python-oca/python-oca#egg=oca" \
-    pyangbind sphinx zenoh==0.3.0 yaks==0.3.0.post1 fog05-sdk==0.2.0 fog05==0.2.0
+    pyangbind sphinx zenoh==0.3.0 yaks==0.3.0.post1 fog05-sdk==0.2.0 fog05==0.2.0 "cryptography>=2.5"
 
 
 #    DEBIAN_FRONTEND=noninteractive apt-get -y install python-openstacksdk python-openstackclient && \
@@ -83,7 +84,7 @@ ENV OSMRO_MESSAGE_PORT    9092
 # logs
 ENV OSMRO_LOG_LEVEL       DEBUG
 
-CMD python3 -m osm_ng_ro.ro_main
+CMD ["python3", "-u", "-m", "osm_ng_ro.ro_main"]
 
 # HEALTHCHECK --start-period=30s --interval=10s --timeout=5s --retries=12 \
 #  CMD curl --silent --fail http://localhost:9090/ro || exit 1
index 768f205..485f15d 100644 (file)
@@ -621,18 +621,18 @@ def _start_service():
     logger_server = logging.getLogger("cherrypy.error")
     logger_access = logging.getLogger("cherrypy.access")
     logger_cherry = logging.getLogger("cherrypy")
-    logger_nbi = logging.getLogger("ro")
+    logger = logging.getLogger("ro")
 
     if "log.file" in engine_config["global"]:
         file_handler = logging.handlers.RotatingFileHandler(engine_config["global"]["log.file"],
                                                             maxBytes=100e6, backupCount=9, delay=0)
         file_handler.setFormatter(log_formatter_simple)
         logger_cherry.addHandler(file_handler)
-        logger_nbi.addHandler(file_handler)
+        logger.addHandler(file_handler)
     # log always to standard output
     for format_, logger in {"ro.server %(filename)s:%(lineno)s": logger_server,
                             "ro.access %(filename)s:%(lineno)s": logger_access,
-                            "%(name)s %(filename)s:%(lineno)s": logger_nbi
+                            "%(name)s %(filename)s:%(lineno)s": logger
                             }.items():
         log_format_cherry = "%(asctime)s %(levelname)s {} %(message)s".format(format_)
         log_formatter_cherry = logging.Formatter(log_format_cherry, datefmt='%Y-%m-%dT%H:%M:%S')
@@ -642,7 +642,7 @@ def _start_service():
 
     if engine_config["global"].get("log.level"):
         logger_cherry.setLevel(engine_config["global"]["log.level"])
-        logger_nbi.setLevel(engine_config["global"]["log.level"])
+        logger.setLevel(engine_config["global"]["log.level"])
     # logging other modules
     for k1, logname in {"message": "ro.msg", "database": "ro.db", "storage": "ro.fs"}.items():
         engine_config[k1]["logger_name"] = logname
index ac371ec..e72a082 100644 (file)
@@ -103,7 +103,7 @@ class AristaSdnConnector(SdnConnectorBase):
     __ELINE_num_connection_points = 2
     __supported_service_types = ["ELINE", "ELAN"]
     __supported_encapsulation_types = ["dot1q"]
-    __WIM_LOGGER = 'openmano.sdnconn.arista'
+    __WIM_LOGGER = 'ro.sdn.arista'
     __SERVICE_ENDPOINT_MAPPING = 'service_endpoint_mapping'
     __ENCAPSULATION_TYPE_PARAM = "service_endpoint_encapsulation_type"
     __ENCAPSULATION_INFO_PARAM = "service_endpoint_encapsulation_info"
@@ -156,7 +156,7 @@ class AristaSdnConnector(SdnConnectorBase):
                 datacenter_id           vim_account                 vim_account
                 id: (internal, do not use)
                 wim_id: (internal, do not use)
-        :param logger (logging.Logger): optional logger object. If none is passed 'openmano.sdn.sdnconn' is used.
+        :param logger (logging.Logger): optional logger object. If none is passed 'ro.sdn.sdnconn' is used.
         """
         self.__regex = re.compile(
             r'^(?:http|ftp)s?://'  # http:// or https://
index 423ceff..dc717e5 100755 (executable)
@@ -205,7 +205,7 @@ class DpbRestInterface():
 class DpbConnector(SdnConnectorBase):
     """ Use the DPB to establish multipoint connections """
 
-    __LOGGER_NAME = "openmano.rosdnconn.dpb"
+    __LOGGER_NAME = "ro.sdn.dpb"
     __SUPPORTED_SERV_TYPES = ["ELAN (L2)", "ELINE (L2)"]
     __SUPPORTED_CONNECTION_TYPES = ["REST", "SSH"]
     __SUPPORTED_SSH_AUTH_TYPES = ["KEY", "PASS"]
index c99627c..0e16cfc 100644 (file)
@@ -58,7 +58,7 @@ class SdnAPIActions(Enum):
 class DynpacConnector(SdnConnectorBase):
     __supported_service_types = ["ELINE (L2)", "ELINE"]
     __supported_encapsulation_types = ["dot1q"]
-    __WIM_LOGGER = 'openmano.sdnconn.dynpac'
+    __WIM_LOGGER = 'ro.sdn.dynpac'
     __ENCAPSULATION_TYPE_PARAM = "service_endpoint_encapsulation_type"
     __ENCAPSULATION_INFO_PARAM = "service_endpoint_encapsulation_info"
     __BACKUP_PARAM = "backup"
index d4c7e3f..4829386 100644 (file)
@@ -76,7 +76,7 @@ class OfConnFloodLight(OpenflowConn):
         self.ofi2pp = {}  # From OpenFlow Index to Physical Port
         self.headers = {'content-type': 'application/json', 'Accept': 'application/json'}
         self.version = None
-        self.logger = logging.getLogger('SDN.floodlightOF')
+        self.logger = logging.getLogger('ro.sdn.floodlightof')
         self.logger.setLevel(params.get("of_debug", "ERROR"))
         self._set_version(params.get("of_version"))
 
index 3303a4d..2c7910b 100644 (file)
@@ -29,7 +29,7 @@ class SdnConnectorFloodLightOf(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.floodlightof')
+        self.logger = logging.getLogger('ro.sdn.floodlightof')
         super().__init__(wim, wim_account, config, logger)
         of_params = {
             "of_url": wim["wim_url"],
index 9b67fc1..8ea422d 100644 (file)
@@ -46,7 +46,7 @@ class WimconnectorIETFL2VPN(SdnConnectorBase):
             wim (dict): WIM record, as stored in the database
             wim_account (dict): WIM account record, as stored in the database
         """
-        self.logger = logging.getLogger('openmano.sdnconn.ietfl2vpn')
+        self.logger = logging.getLogger('ro.sdn.ietfl2vpn')
         super().__init__(wim, wim_account, config, logger)
         self.headers = {'Content-Type': 'application/json'}
         self.mappings = {m['service_endpoint_id']: m
index 151bf6c..6c2f72b 100644 (file)
@@ -29,7 +29,7 @@ class UnderlayApi:
 
     def __init__(self, url, config=None, user=None, password=None, logger=None):
 
-        self.logger = logger or logging.getLogger("openmano.sdnconn.junipercontrail.sdnapi")
+        self.logger = logger or logging.getLogger("ro.sdn.junipercontrail.sdnapi")
         self.controller_url = url
 
         if not url:
index 43bfb87..a1cc3de 100644 (file)
@@ -39,7 +39,7 @@ class JuniperContrail(SdnConnectorBase):
       tutorial_with_rest.html
     - https://github.com/tonyliu0592/contrail-toolbox/blob/master/sriov/sriov
     """
-    _WIM_LOGGER = "openmano.sdnconn.junipercontrail"
+    _WIM_LOGGER = "ro.sdn.junipercontrail"
 
     def __init__(self, wim, wim_account, config=None, logger=None):
         """
@@ -62,7 +62,7 @@ class JuniperContrail(SdnConnectorBase):
                 datacenter_id           vim_account                 vim_account
                 id: (internal, do not use)
                 wim_id: (internal, do not use)
-        :param logger (logging.Logger): optional logger object. If none is passed 'openmano.sdn.sdnconn' is used.
+        :param logger (logging.Logger): optional logger object. If none is passed 'ro.sdn.sdnconn' is used.
         """
         self.logger = logger or logging.getLogger(self._WIM_LOGGER)
         self.logger.debug('wim: {}, wim_account: {}, config: {}'.format(wim, wim_account, config))
@@ -680,7 +680,7 @@ if __name__ == '__main__':
     log_formatter = logging.Formatter(log_format, datefmt='%Y-%m-%dT%H:%M:%S')
     handler = logging.StreamHandler()
     handler.setFormatter(log_formatter)
-    logger = logging.getLogger('openmano.sdnconn.junipercontrail')
+    logger = logging.getLogger('ro.sdn.junipercontrail')
     # logger.setLevel(level=logging.ERROR)
     # logger.setLevel(level=logging.INFO)
     logger.setLevel(level=logging.DEBUG)
index 355ec7a..7cf7ee2 100644 (file)
@@ -82,7 +82,7 @@ class OfConnOdl(OpenflowConn):
             self.auth = self.auth.decode()
             self.headers['authorization'] = 'Basic ' + self.auth
 
-        self.logger = logging.getLogger('openmano.sdnconn.onosof')
+        self.logger = logging.getLogger('ro.sdn.onosof')
         # self.logger.setLevel(getattr(logging, params.get("of_debug", "ERROR")))
         self.logger.debug("odlof plugin initialized")
 
index 190372a..0b13921 100644 (file)
@@ -29,7 +29,7 @@ class SdnConnectorOdlOf(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.odlof')
+        self.logger = logging.getLogger('ro.sdn.odlof')
         super().__init__(wim, wim_account, config, logger)
         of_params = {
             "of_url": wim["wim_url"],
index ef32be2..a29b408 100644 (file)
@@ -86,7 +86,7 @@ class OfConnOnos(OpenflowConn):
             self.auth = self.auth.decode()
             self.headers['authorization'] = 'Basic ' + self.auth
 
-        self.logger = logging.getLogger('openmano.sdnconn.onosof')
+        self.logger = logging.getLogger('ro.sdn.onosof')
         # self.logger.setLevel( getattr(logging, params.get("of_debug", "ERROR")) )
         self.logger.debug("onosof plugin initialized")
         self.ip_address = None
index c5e081a..fa820d2 100644 (file)
@@ -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('ro.sdn.onosof')
         super().__init__(wim, wim_account, config, logger)
         of_params = {
             "of_url": wim["wim_url"],
index ced63d2..372de66 100644 (file)
@@ -34,7 +34,7 @@ class OnosVpls(SdnConnectorBase):
     """
     https://wiki.onosproject.org/display/ONOS/VPLS+User+Guide
     """
-    _WIM_LOGGER = "openmano.sdnconn.onosvpls"
+    _WIM_LOGGER = "ro.sdn.onosvpls"
 
     def __init__(self, wim, wim_account, config=None, logger=None):
         self.logger = logger or logging.getLogger(self._WIM_LOGGER)
@@ -373,7 +373,7 @@ class OnosVpls(SdnConnectorBase):
 
 
 if __name__ == '__main__':
-    logger = logging.getLogger('openmano.sdn.onos_vpls')
+    logger = logging.getLogger('ro.sdn.onos_vpls')
     logging.basicConfig()
     logger.setLevel(getattr(logging, "DEBUG"))
     # wim_url = "http://10.95.172.251:8181"
index ee024d4..1144292 100644 (file)
@@ -119,7 +119,7 @@ class vimconnector(vimconn.VimConnector):
             elif isinstance(flavor_data, dict):
                 self.flavor_info = flavor_data
 
-        self.logger = logging.getLogger('openmano.vim.aws')
+        self.logger = logging.getLogger('ro.vim.aws')
         if log_level:
             self.logger.setLevel(getattr(logging, log_level))
 
index 3752f29..f2b1805 100755 (executable)
@@ -93,7 +93,7 @@ class vimconnector(vimconn.VimConnector):
 
         self.vnet_address_space = None
         # LOGGER
-        self.logger = logging.getLogger('openmano.vim.azure')
+        self.logger = logging.getLogger('ro.vim.azure')
         if log_level:
             logging.basicConfig()
             self.logger.setLevel(getattr(logging, log_level))
index 21f1b9f..e851fd3 100644 (file)
@@ -32,6 +32,7 @@ Support config dict:
 
 """
 
+import logging
 import uuid
 import socket
 import struct
@@ -70,6 +71,7 @@ class vimconnector(vimconn.VimConnector):
         vimconn.VimConnector.__init__(self, uuid, name, tenant_id, tenant_name, url, url_admin, user, passwd, log_level,
                                       config, persistent_info)
 
+        self.logger = logging.getLogger('ro.vim.fos')
         self.logger.debug('vimconn_fos init with config: {}'.format(config))
         self.arch = config.get('arch', 'x86_64')
         self.hv = config.get('hypervisor', 'LXD')
index a84b665..a646036 100644 (file)
@@ -28,7 +28,9 @@ vimconnector implements all the methods to interact with OpenNebula using the XM
 __author__ = "Jose Maria Carmona Perez,Juan Antonio Hernando Labajo, Emilio Abraham Garrido Garcia,Alberto Florez " \
              "Pages, Andres Pozo Munoz, Santiago Perez Marin, Onlife Networks Telefonica I+D Product Innovation "
 __date__ = "$13-dec-2017 11:09:29$"
+
 from osm_ro_plugin import vimconn
+import logging
 import requests
 # import logging
 import oca
@@ -63,6 +65,8 @@ class vimconnector(vimconn.VimConnector):
         vimconn.VimConnector.__init__(self, uuid, name, tenant_id, tenant_name, url, url_admin, user, passwd, log_level,
                                       config)
 
+        self.logger = logging.getLogger('ro.vim.openstack')
+
     def _new_one_connection(self):
         return pyone.OneServer(self.url, session=self.user + ':' + self.passwd)
 
index 0645e54..bd3955a 100644 (file)
@@ -152,7 +152,7 @@ class vimconnector(vimconn.VimConnector):
         logging.getLogger('urllib3').setLevel(logging.WARNING)
         logging.getLogger('keystoneauth').setLevel(logging.WARNING)
         logging.getLogger('novaclient').setLevel(logging.WARNING)
-        self.logger = logging.getLogger('openmano.vim.openstack')
+        self.logger = logging.getLogger('ro.vim.openstack')
 
         # allow security_groups to be a list or a single string
         if isinstance(self.config.get('security_groups'), str):
@@ -161,7 +161,7 @@ class vimconnector(vimconn.VimConnector):
 
         # ###### VIO Specific Changes #########
         if self.vim_type == "VIO":
-            self.logger = logging.getLogger('openmano.vim.vio')
+            self.logger = logging.getLogger('ro.vim.vio')
 
         if log_level:
             self.logger.setLevel(getattr(logging, log_level))
index 0c24003..8fb02cc 100644 (file)
@@ -330,7 +330,7 @@ class vimconnector(vimconn.VimConnector):
         vimconn.VimConnector.__init__(self, uuid, name, tenant_id, tenant_name, url, url_admin, user, passwd, log_level, config)
         self.tenant = None
         self.headers_req = {'content-type': 'application/json'}
-        self.logger = logging.getLogger('openmano.vim.openvim')
+        self.logger = logging.getLogger('ro.vim.openvim')
         self.persistent_info = persistent_info
         if tenant_id:
             self.tenant = tenant_id
index b698f4c..34fed52 100644 (file)
@@ -151,7 +151,7 @@ class vimconnector(vimconn.VimConnector):
         vimconn.VimConnector.__init__(self, uuid, name, tenant_id, tenant_name, url,
                                       url_admin, user, passwd, log_level, config)
 
-        self.logger = logging.getLogger('openmano.vim.vmware')
+        self.logger = logging.getLogger('ro.vim.vmware')
         self.logger.setLevel(10)
         self.persistent_info = persistent_info
 
index f60deea..f46c6cf 100644 (file)
@@ -86,7 +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('openmano.sdn.openflow_conn')
+        self.logger = logging.getLogger('ro.sdn.openflow_conn')
 
     def get_of_switches(self):
         """"
@@ -160,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.sdn.openflow_conn')
+        self.logger = logger or logging.getLogger('ro.sdn.openflow_conn')
         self.of_connector = of_connector
         config = config or {}
         self.of_controller_nets_with_same_vlan = config.get("of_controller_nets_with_same_vlan", False)
index a2d189a..687d4ab 100644 (file)
@@ -44,7 +44,7 @@ class SdnDummyConnector(SdnConnectorBase):
     An extra property, ``service_endpoint_mapping`` is created from ``config``.
     """
     def __init__(self, wim, wim_account, config=None, logger=None):
-        self.logger = logger or logging.getLogger('openmano.sdnconn.dummy')
+        self.logger = logger or logging.getLogger('ro.sdn.dummy')
         super(SdnDummyConnector, self).__init__(wim, wim_account, config, self.logger)
         self.logger.debug("__init: wim='{}' wim_account='{}'".format(wim, wim_account))
         self.connections = {}
index b7b1faa..ccf16b1 100644 (file)
@@ -92,7 +92,7 @@ class SdnConnectorBase(object):
                 wim_id: (internal, do not use)
         :param logger (logging.Logger): optional logger object. If none is passed 'openmano.sdn.sdnconn' is used.
         """
-        self.logger = logger or logging.getLogger('openmano.sdnconn')
+        self.logger = logger or logging.getLogger('ro.sdn')
 
         self.wim = wim
         self.wim_account = wim_account
index e90d213..22379b6 100644 (file)
@@ -41,7 +41,7 @@ class VimDummyConnector(vimconn.VimConnector):
                  config={}, persistent_info={}):
         super().__init__(uuid, name, tenant_id, tenant_name, url, url_admin, user, passwd, log_level,
                          config, persistent_info)
-        self.logger = logging.getLogger('openmano.vim.dummy')
+        self.logger = logging.getLogger('ro.vim.dummy')
         if log_level:
             self.logger.setLevel(getattr(logging, log_level))
         self.nets = {
index dd60e46..c71e821 100644 (file)
@@ -150,7 +150,7 @@ class VimConnector():
         self.passwd = passwd
         self.config = config or {}
         self.availability_zone = None
-        self.logger = logging.getLogger('openmano.vim')
+        self.logger = logging.getLogger('ro.vim')
         if log_level:
             self.logger.setLevel(getattr(logging, log_level))
         if not self.url_admin:   # try to use normal url