Uploaded image for project: 'RHEL'
  1. RHEL
  2. RHEL-1401

Logs were duplicated after calling netinfo.show_running_config()

Linking RHIVOS CVEs to...Migration: Automation ...Sync from "Extern...XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Do
    • Icon: Minor Minor
    • None
    • rhel-9.1.0
    • nmstate
    • None
    • None
    • rhel-net-mgmt
    • ssg_networking
    • None
    • False
    • False
    • Hide

      None

      Show
      None
    • None
    • None
    • None
    • None
    • If docs needed, set a value
    • None
    • 0

      Description of problem:
      Run the below python code

      from libnmstate import netapplier
      from libnmstate import netinfo
      from libnmstate.schema import Interface
      import logging
      import sys
      import yaml

      def logger_level(logger, verbose=False, debug=False):
      log_level = logging.DEBUG
      if debug:
      log_level = logging.DEBUG
      elif verbose:
      log_level = logging.INFO
      logger.setLevel(log_level)

      def configure_logger(log_file=False, verbose=False, debug=False):
      LOG_FORMAT = ('%(asctime)s.%(msecs)03d %(levelname)s '
      '%(name)s.%(funcName)s %(message)s')
      DATE_FORMAT = '%Y-%m-%d %H:%M:%S'
      logger = logging.getLogger("os_net_config")
      logger.handlers.clear()
      logger_level(logger, verbose, debug)
      logger.propagate = True
      formatter = logging.Formatter(fmt=LOG_FORMAT, datefmt=DATE_FORMAT)
      if log_file:
      file_handler = logging.handlers.RotatingFileHandler(
      _LOG_FILE, maxBytes=10485760, backupCount=7
      )
      file_handler.setFormatter(formatter)
      logger.addHandler(file_handler)
      stream_handler = logging.StreamHandler(sys.stdout)
      stream_handler.setFormatter(formatter)
      logger.addHandler(stream_handler)
      return logger

      logger = configure_logger()

      logger.debug("--------PRE_NETINFO LOG----------------")

      ifaces = netinfo.show_running_config()[Interface.KEY]
      ifaces_dmp = yaml.dump(ifaces, default_flow_style = False,
      allow_unicode = True, encoding = None)
      logger.debug("------POST_NETINFO_LOG-----------------")
      logger.debug("Running info: \n %s" % ifaces_dmp)

      Its found that after invoking netinfo.show_running_config(), the logs are duplicated.

      Version-Release number of selected component (if applicable):
      nmstatectl 2.2.6

      Actual results:
      [root@dell-r640-oss-14 ~]# python nmstate_test.py
      2023-02-14 16:53:59.240 DEBUG os_net_config.<module> --------PRE_NETINFO LOG----------------
      2023-02-14 16:53:59.360 DEBUG os_net_config.<module> ------POST_NETINFO_LOG-----------------
      DEBUG:os_net_config:------POST_NETINFO_LOG-----------------
      2023-02-14 16:53:59.360 DEBUG os_net_config.<module> Running info:

      .....

      Expected results:

      2023-02-14 16:53:59.240 DEBUG os_net_config.<module> --------PRE_NETINFO LOG----------------
      2023-02-14 16:53:59.360 DEBUG os_net_config.<module> ------POST_NETINFO_LOG-----------------
      2023-02-14 16:53:59.360 DEBUG os_net_config.<module> Running info:
      ....

              nm-team Network Management Team
              ksundara@redhat.com Karthik Sundaravel
              Network Management Team Network Management Team
              Mingyu Shi Mingyu Shi
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

                Created:
                Updated:
                Resolved: