diff --git a/daemon/core/__init__.py b/daemon/core/__init__.py index 50d263c3..61f36a41 100644 --- a/daemon/core/__init__.py +++ b/daemon/core/__init__.py @@ -1,17 +1,9 @@ -# Copyright (c)2010-2012 the Boeing Company. -# See the LICENSE file included in this distribution. +import logzero -""" -core +# configure custom format with function name +_format_template = "%(color)s[%(levelname)1.1s %(asctime)s %(module)s:%(funcName)s:" \ + "%(lineno)d]%(end_color)s %(message)s" +_formatter = logzero.LogFormatter(fmt=_format_template) +logzero.formatter(_formatter) -Top-level Python package containing CORE components. - -See http://www.nrl.navy.mil/itd/ncs/products/core for more information on CORE. - -Pieces can be imported individually, for example - - from core.netns import vnode -""" - -# Automatically import all add-ons listed in addons.__all__ -from addons import * +logger = logzero.logger diff --git a/daemon/core/api/coreapi.py b/daemon/core/api/coreapi.py index 1fd6dab6..b59446ef 100644 --- a/daemon/core/api/coreapi.py +++ b/daemon/core/api/coreapi.py @@ -10,6 +10,7 @@ import struct from enum import Enum +from core import logger from core.enumerations import ConfigTlvs from core.enumerations import EventTlvs from core.enumerations import EventTypes @@ -27,8 +28,6 @@ from core.misc import log, structutils from core.misc.ipaddress import IpAddress from core.misc.ipaddress import MacAddress -logger = log.get_logger(__name__) - class CoreTlvData(object): """ diff --git a/daemon/core/api/dataconversion.py b/daemon/core/api/dataconversion.py index 29a7369e..9080eee8 100644 --- a/daemon/core/api/dataconversion.py +++ b/daemon/core/api/dataconversion.py @@ -2,13 +2,11 @@ Converts CORE data objects into legacy API messages. """ +from core import logger from core.api import coreapi from core.enumerations import NodeTlvs -from core.misc import log from core.misc import structutils -logger = log.get_logger(__name__) - def convert_node(node_data): """ diff --git a/daemon/core/broker.py b/daemon/core/broker.py index c1b8570d..7507218a 100644 --- a/daemon/core/broker.py +++ b/daemon/core/broker.py @@ -9,6 +9,7 @@ import select import socket import threading +from core import logger from core.api import coreapi from core.conf import ConfigurableManager from core.coreobj import PyCoreNet @@ -26,15 +27,12 @@ from core.enumerations import MessageTypes from core.enumerations import NodeTlvs from core.enumerations import NodeTypes from core.enumerations import RegisterTlvs -from core.misc import log from core.misc import nodeutils from core.misc.ipaddress import IpAddress from core.netns.vif import GreTap from core.netns.vnet import GreTapBridge from core.phys.pnodes import PhysicalNode -logger = log.get_logger(__name__) - # TODO: name conflict with main core server, probably should rename class CoreServer(object): diff --git a/daemon/core/bsd/nodes.py b/daemon/core/bsd/nodes.py index 44eda5e1..68e825eb 100644 --- a/daemon/core/bsd/nodes.py +++ b/daemon/core/bsd/nodes.py @@ -15,6 +15,7 @@ import socket import subprocess from core import constants +from core import logger from core.api import coreapi from core.bsd.netgraph import connectngnodes from core.bsd.netgraph import ngloadkernelmodule @@ -26,11 +27,8 @@ from core.enumerations import LinkTypes from core.enumerations import NodeTypes from core.enumerations import RegisterTlvs from core.misc import ipaddress -from core.misc import log from core.misc import utils -logger = log.get_logger(__name__) - utils.check_executables([constants.IFCONFIG_BIN]) diff --git a/daemon/core/bsd/vnet.py b/daemon/core/bsd/vnet.py index cadf8877..917bac51 100644 --- a/daemon/core/bsd/vnet.py +++ b/daemon/core/bsd/vnet.py @@ -11,14 +11,12 @@ vnet.py: NetgraphNet and NetgraphPipeNet classes that implement virtual networks using the FreeBSD Netgraph subsystem. """ +from core import logger from core.bsd.netgraph import connectngnodes from core.bsd.netgraph import createngnode from core.bsd.netgraph import destroyngnode from core.bsd.netgraph import ngmessage from core.coreobj import PyCoreNet -from core.misc import log - -logger = log.get_logger(__name__) class NetgraphNet(PyCoreNet): diff --git a/daemon/core/bsd/vnode.py b/daemon/core/bsd/vnode.py index c270b491..589d7c16 100644 --- a/daemon/core/bsd/vnode.py +++ b/daemon/core/bsd/vnode.py @@ -16,15 +16,13 @@ import subprocess import threading from core import constants +from core import logger from core.bsd.netgraph import createngnode from core.bsd.netgraph import destroyngnode from core.coreobj import PyCoreNetIf from core.coreobj import PyCoreNode -from core.misc import log from core.misc import utils -logger = log.get_logger(__name__) - utils.check_executables([constants.IFCONFIG_BIN, constants.VIMAGE_BIN]) diff --git a/daemon/core/conf.py b/daemon/core/conf.py index b436dd2e..8d195394 100644 --- a/daemon/core/conf.py +++ b/daemon/core/conf.py @@ -4,12 +4,10 @@ Common support for configurable CORE objects. import string +from core import logger from core.data import ConfigData from core.enumerations import ConfigDataTypes from core.enumerations import ConfigFlags -from core.misc import log - -logger = log.get_logger(__name__) class ConfigurableManager(object): diff --git a/daemon/core/corehandlers.py b/daemon/core/corehandlers.py index 4d10dc5a..ac05249d 100644 --- a/daemon/core/corehandlers.py +++ b/daemon/core/corehandlers.py @@ -12,6 +12,7 @@ import threading import time from core import coreobj +from core import logger from core.api import coreapi from core.coreserver import CoreServer from core.data import ConfigData @@ -31,7 +32,6 @@ from core.enumerations import NodeTlvs from core.enumerations import NodeTypes from core.enumerations import RegisterTlvs from core.enumerations import SessionTlvs -from core.misc import log from core.misc import nodeutils from core.misc import structutils from core.misc import utils @@ -39,8 +39,6 @@ from core.netns import nodes from core.xml.xmlsession import open_session_xml from core.xml.xmlsession import save_session_xml -logger = log.get_logger(__name__) - class CoreRequestHandler(SocketServer.BaseRequestHandler): """ diff --git a/daemon/core/coreobj.py b/daemon/core/coreobj.py index 4cee157c..c85b56a1 100644 --- a/daemon/core/coreobj.py +++ b/daemon/core/coreobj.py @@ -10,9 +10,7 @@ import threading from socket import AF_INET from socket import AF_INET6 -from core.api import coreapi from core.data import NodeData, LinkData -from core.enumerations import LinkTlvs from core.enumerations import LinkTypes from core.misc import ipaddress diff --git a/daemon/core/coreserver.py b/daemon/core/coreserver.py index 8620945d..882f2239 100644 --- a/daemon/core/coreserver.py +++ b/daemon/core/coreserver.py @@ -8,14 +8,12 @@ import os import threading import time +from core import logger from core.api import coreapi from core.enumerations import EventTypes from core.enumerations import SessionTlvs -from core.misc import log from core.session import Session -logger = log.get_logger(__name__) - class CoreServer(SocketServer.ThreadingMixIn, SocketServer.TCPServer): """ diff --git a/daemon/core/emane/__init__.py b/daemon/core/emane/__init__.py index 698aa63d..892feb6e 100644 --- a/daemon/core/emane/__init__.py +++ b/daemon/core/emane/__init__.py @@ -1,10 +1,8 @@ import subprocess -from core.misc import log +from core import logger from core.misc import utils -logger = log.get_logger(__name__) - EMANEUNK = 0 EMANE074 = 7 EMANE081 = 8 diff --git a/daemon/core/emane/commeffect.py b/daemon/core/emane/commeffect.py index eebdad2a..f99bda78 100644 --- a/daemon/core/emane/commeffect.py +++ b/daemon/core/emane/commeffect.py @@ -3,11 +3,9 @@ commeffect.py: EMANE CommEffect model for CORE """ from core import emane +from core import logger from core.emane.emanemodel import EmaneModel from core.enumerations import ConfigDataTypes -from core.misc import log - -logger = log.get_logger(__name__) try: import emaneeventservice diff --git a/daemon/core/emane/emanemanager.py b/daemon/core/emane/emanemanager.py index 0004924f..335c0db1 100644 --- a/daemon/core/emane/emanemanager.py +++ b/daemon/core/emane/emanemanager.py @@ -9,6 +9,7 @@ from xml.dom.minidom import parseString from core import constants from core import emane +from core import logger from core.api import coreapi from core.conf import ConfigurableManager from core.emane.bypass import EmaneBypassModel @@ -23,14 +24,11 @@ from core.enumerations import ConfigTlvs from core.enumerations import MessageFlags from core.enumerations import MessageTypes from core.enumerations import RegisterTlvs -from core.misc import log from core.misc import nodeutils from core.misc import utils from core.misc.ipaddress import MacAddress from core.xml import xmlutils -logger = log.get_logger(__name__) - # EMANE 0.7.4/0.8.1 try: import emaneeventservice diff --git a/daemon/core/emane/emanemodel.py b/daemon/core/emane/emanemodel.py index 80c1c13a..ae8fac81 100644 --- a/daemon/core/emane/emanemodel.py +++ b/daemon/core/emane/emanemodel.py @@ -3,13 +3,11 @@ Defines Emane Models used within CORE. """ from core import emane -from core.misc import log +from core import logger from core.misc import utils from core.mobility import WirelessModel from core.xml import xmlutils -logger = log.get_logger(__name__) - class EmaneModel(WirelessModel): """ diff --git a/daemon/core/emane/ieee80211abg.py b/daemon/core/emane/ieee80211abg.py index 1ee22c84..56868201 100644 --- a/daemon/core/emane/ieee80211abg.py +++ b/daemon/core/emane/ieee80211abg.py @@ -6,9 +6,6 @@ from core import emane from core.emane.emanemodel import EmaneModel from core.emane.universal import EmaneUniversalModel from core.enumerations import ConfigDataTypes -from core.misc import log - -logger = log.get_logger(__name__) class EmaneIeee80211abgModel(EmaneModel): diff --git a/daemon/core/emane/nodes.py b/daemon/core/emane/nodes.py index bdc824d7..55c74bce 100644 --- a/daemon/core/emane/nodes.py +++ b/daemon/core/emane/nodes.py @@ -7,13 +7,11 @@ share the same MAC+PHY model. from os import path from core import emane +from core import logger from core.coreobj import PyCoreNet from core.enumerations import LinkTypes from core.enumerations import NodeTypes from core.enumerations import RegisterTlvs -from core.misc import log - -logger = log.get_logger(__name__) try: from emanesh.events import LocationEvent diff --git a/daemon/core/emane/rfpipe.py b/daemon/core/emane/rfpipe.py index 54a27104..3b88ff5f 100644 --- a/daemon/core/emane/rfpipe.py +++ b/daemon/core/emane/rfpipe.py @@ -6,9 +6,6 @@ from core import emane from core.emane.emanemodel import EmaneModel from core.emane.universal import EmaneUniversalModel from core.enumerations import ConfigDataTypes -from core.misc import log - -logger = log.get_logger(__name__) class EmaneRfPipeModel(EmaneModel): diff --git a/daemon/core/emane/tdma.py b/daemon/core/emane/tdma.py index 3029bbcb..b5f01618 100644 --- a/daemon/core/emane/tdma.py +++ b/daemon/core/emane/tdma.py @@ -6,9 +6,6 @@ from core import emane from core.emane.emanemodel import EmaneModel from core.emane.universal import EmaneUniversalModel from core.enumerations import ConfigDataTypes -from core.misc import log - -logger = log.get_logger(__name__) class EmaneTdmaModel(EmaneModel): diff --git a/daemon/core/emane/universal.py b/daemon/core/emane/universal.py index 347123cc..619606b8 100644 --- a/daemon/core/emane/universal.py +++ b/daemon/core/emane/universal.py @@ -6,9 +6,6 @@ used for the Universal PHY. from core import emane from core.emane.emanemodel import EmaneModel from core.enumerations import ConfigDataTypes -from core.misc import log - -logger = log.get_logger(__name__) class EmaneUniversalModel(EmaneModel): diff --git a/daemon/core/location.py b/daemon/core/location.py index 858f8af5..6915fc4b 100644 --- a/daemon/core/location.py +++ b/daemon/core/location.py @@ -5,13 +5,11 @@ systems. Depends on utm contributed module, from https://pypi.python.org/pypi/utm (version 0.3.0). """ +from core import logger from core.conf import ConfigurableManager from core.enumerations import RegisterTlvs -from core.misc import log from core.misc import utm -logger = log.get_logger(__name__) - class CoreLocation(ConfigurableManager): """ diff --git a/daemon/core/misc/event.py b/daemon/core/misc/event.py index eec851c9..74887067 100644 --- a/daemon/core/misc/event.py +++ b/daemon/core/misc/event.py @@ -6,9 +6,7 @@ import heapq import threading import time -from core.misc import log - -logger = log.get_logger(__name__) +from core import logger class Timer(threading.Thread): diff --git a/daemon/core/misc/ipaddress.py b/daemon/core/misc/ipaddress.py index 2142ebf8..032a51c4 100644 --- a/daemon/core/misc/ipaddress.py +++ b/daemon/core/misc/ipaddress.py @@ -8,9 +8,7 @@ import struct from socket import AF_INET from socket import AF_INET6 -from core.misc import log - -logger = log.get_logger(__name__) +from core import logger class MacAddress(object): diff --git a/daemon/core/misc/log.py b/daemon/core/misc/log.py deleted file mode 100644 index a12b183e..00000000 --- a/daemon/core/misc/log.py +++ /dev/null @@ -1,35 +0,0 @@ -""" -Convenience methods to setup logging. -""" - -import logging - -_LOG_LEVEL = logging.INFO -_LOG_FORMAT = "%(levelname)-7s %(asctime)s %(name)-15s %(funcName)-15s %(lineno)-4d: %(message)s" -_INITIAL = True - - -def setup(level=_LOG_LEVEL, log_format=_LOG_FORMAT): - """ - Configure a logging with a basic configuration, output to console. - - :param logging.LEVEL level: level for logger, defaults to module defined format - :param int log_format: format for logger, default to DEBUG - :return: nothing - """ - logging.basicConfig(level=level, format=log_format) - - -def get_logger(name): - """ - Retrieve a logger for logging. - - :param str name: name for logger to retrieve - :return: logging.logger - """ - global _INITIAL - if _INITIAL: - setup() - _INITIAL = False - - return logging.getLogger(name) diff --git a/daemon/core/misc/nodeutils.py b/daemon/core/misc/nodeutils.py index 27a41892..eadd42c2 100644 --- a/daemon/core/misc/nodeutils.py +++ b/daemon/core/misc/nodeutils.py @@ -4,9 +4,7 @@ Serves as a global point for storing and retrieving node types needed during sim import pprint -from core.misc import log - -logger = log.get_logger(__name__) +from core import logger _NODE_MAP = None diff --git a/daemon/core/misc/structutils.py b/daemon/core/misc/structutils.py index c58c6f56..657f623c 100644 --- a/daemon/core/misc/structutils.py +++ b/daemon/core/misc/structutils.py @@ -2,9 +2,7 @@ Utilities for working with python struct data. """ -from core.misc import log - -logger = log.get_logger(__name__) +from core import logger def pack_values(clazz, packers): diff --git a/daemon/core/misc/utils.py b/daemon/core/misc/utils.py index 9f5d76e3..62dccd0c 100644 --- a/daemon/core/misc/utils.py +++ b/daemon/core/misc/utils.py @@ -8,9 +8,7 @@ import subprocess import fcntl import resource -from core.misc import log - -logger = log.get_logger(__name__) +from core import logger def closeonexec(fd): diff --git a/daemon/core/mobility.py b/daemon/core/mobility.py index 12fc129b..e3075055 100644 --- a/daemon/core/mobility.py +++ b/daemon/core/mobility.py @@ -9,6 +9,7 @@ import subprocess import threading import time +from core import logger from core.conf import Configurable from core.conf import ConfigurableManager from core.coreobj import PyCoreNode @@ -20,11 +21,8 @@ from core.enumerations import MessageFlags from core.enumerations import MessageTypes from core.enumerations import NodeTlvs from core.enumerations import RegisterTlvs -from core.misc import log from core.misc.ipaddress import IpAddress -logger = log.get_logger(__name__) - class MobilityManager(ConfigurableManager): """ diff --git a/daemon/core/netns/nodes.py b/daemon/core/netns/nodes.py index 46b51e85..202c0622 100644 --- a/daemon/core/netns/nodes.py +++ b/daemon/core/netns/nodes.py @@ -10,6 +10,7 @@ from socket import AF_INET from socket import AF_INET6 from core import constants +from core import logger from core.coreobj import PyCoreNetIf from core.coreobj import PyCoreNode from core.coreobj import PyCoreObj @@ -18,14 +19,11 @@ from core.enumerations import LinkTypes from core.enumerations import NodeTypes from core.enumerations import RegisterTlvs from core.misc import ipaddress -from core.misc import log from core.misc import utils from core.netns.vnet import GreTapBridge from core.netns.vnet import LxBrNet from core.netns.vnode import LxcNode -logger = log.get_logger(__name__) - class CtrlNet(LxBrNet): """ diff --git a/daemon/core/netns/openvswitch.py b/daemon/core/netns/openvswitch.py index 142b83e0..36fa0d01 100644 --- a/daemon/core/netns/openvswitch.py +++ b/daemon/core/netns/openvswitch.py @@ -9,21 +9,19 @@ from socket import AF_INET from socket import AF_INET6 from core import constants +from core import logger from core.coreobj import PyCoreNet from core.data import LinkData from core.enumerations import LinkTypes from core.enumerations import NodeTypes from core.enumerations import RegisterTlvs from core.misc import ipaddress -from core.misc import log from core.misc import utils from core.netns.vif import GreTap from core.netns.vif import VEth from core.netns.vnet import EbtablesQueue from core.netns.vnet import GreTapBridge -logger = log.get_logger(__name__) - # a global object because all WLANs share the same queue # cannot have multiple threads invoking the ebtables commnd ebtables_queue = EbtablesQueue() diff --git a/daemon/core/netns/vif.py b/daemon/core/netns/vif.py index 2032303d..7f254858 100644 --- a/daemon/core/netns/vif.py +++ b/daemon/core/netns/vif.py @@ -6,14 +6,12 @@ import subprocess import time from core import constants +from core import logger from core.coreobj import PyCoreNetIf from core.enumerations import NodeTypes -from core.misc import log from core.misc import nodeutils from core.misc import utils -logger = log.get_logger(__name__) - utils.check_executables([constants.IP_BIN]) diff --git a/daemon/core/netns/vnet.py b/daemon/core/netns/vnet.py index 619c3496..d31df94c 100644 --- a/daemon/core/netns/vnet.py +++ b/daemon/core/netns/vnet.py @@ -9,14 +9,12 @@ import threading import time from core import constants +from core import logger from core.coreobj import PyCoreNet -from core.misc import log from core.misc import utils from core.netns.vif import GreTap from core.netns.vif import VEth -logger = log.get_logger(__name__) - utils.check_executables([ constants.BRCTL_BIN, constants.IP_BIN, diff --git a/daemon/core/netns/vnode.py b/daemon/core/netns/vnode.py index bed14453..3f50d028 100644 --- a/daemon/core/netns/vnode.py +++ b/daemon/core/netns/vnode.py @@ -11,18 +11,16 @@ import subprocess import threading from core import constants +from core import logger from core.coreobj import PyCoreNetIf from core.coreobj import PyCoreNode from core.enumerations import NodeTypes -from core.misc import log from core.misc import nodeutils from core.misc import utils from core.netns import vnodeclient from core.netns.vif import TunTap from core.netns.vif import VEth -logger = log.get_logger(__name__) - utils.check_executables([constants.IP_BIN]) diff --git a/daemon/core/netns/vnodeclient.py b/daemon/core/netns/vnodeclient.py index e597a009..f20fd739 100644 --- a/daemon/core/netns/vnodeclient.py +++ b/daemon/core/netns/vnodeclient.py @@ -10,9 +10,7 @@ import stat import subprocess from core import constants -from core.misc import log - -logger = log.get_logger(__name__) +from core import logger USE_VCMD_MODULE = True diff --git a/daemon/core/phys/pnodes.py b/daemon/core/phys/pnodes.py index e73672a0..2788fc0a 100644 --- a/daemon/core/phys/pnodes.py +++ b/daemon/core/phys/pnodes.py @@ -7,14 +7,12 @@ import subprocess import threading from core import constants +from core import logger from core.coreobj import PyCoreNode -from core.misc import log from core.misc import utils from core.netns.vnet import GreTap from core.netns.vnet import LxBrNet -logger = log.get_logger(__name__) - class PhysicalNode(PyCoreNode): def __init__(self, session, objid=None, name=None, nodedir=None, start=True): diff --git a/daemon/core/sdt.py b/daemon/core/sdt.py index 59a28f43..1e14c110 100644 --- a/daemon/core/sdt.py +++ b/daemon/core/sdt.py @@ -6,6 +6,7 @@ import socket from urlparse import urlparse from core import constants +from core import logger from core.api import coreapi from core.coreobj import PyCoreNet from core.coreobj import PyCoreObj @@ -16,11 +17,8 @@ from core.enumerations import MessageFlags from core.enumerations import MessageTypes from core.enumerations import NodeTlvs from core.enumerations import NodeTypes -from core.misc import log from core.misc import nodeutils -logger = log.get_logger(__name__) - # TODO: A named tuple may be more appropriate, than abusing a class dict like this class Bunch(object): diff --git a/daemon/core/service.py b/daemon/core/service.py index 77ed89e1..f8ab6251 100644 --- a/daemon/core/service.py +++ b/daemon/core/service.py @@ -15,6 +15,7 @@ import sys import time from itertools import repeat +from core import logger from core.conf import Configurable from core.conf import ConfigurableManager from core.data import ConfigData @@ -25,11 +26,8 @@ from core.enumerations import ConfigFlags from core.enumerations import EventTypes from core.enumerations import MessageFlags from core.enumerations import RegisterTlvs -from core.misc import log from core.misc import utils -logger = log.get_logger(__name__) - def _valid_module(path, file_name): """ @@ -120,28 +118,28 @@ class ServiceManager(object): :return: list of core services :rtype: list """ + # validate path exists for importing logger.info("getting custom services from: %s", path) parent_path = os.path.dirname(path) if parent_path not in sys.path: logger.info("adding parent path to allow imports: %s", parent_path) sys.path.append(parent_path) + + # retrieve potential service modules, and filter out invalid modules base_module = os.path.basename(path) module_names = os.listdir(path) module_names = filter(lambda x: _valid_module(path, x), module_names) module_names = map(lambda x: x[:-3], module_names) - # custom_services = [] + # import and add all service modules in the path for module_name in module_names: import_statement = "%s.%s" % (base_module, module_name) logger.info("importing custom service module: %s", import_statement) module = importlib.import_module(import_statement) members = inspect.getmembers(module, lambda x: _is_service(module, x)) for member in members: - # custom_services.append(member[1]) cls.add(member[1]) - # return custom_services - class CoreServices(ConfigurableManager): """ diff --git a/daemon/core/services/__init__.py b/daemon/core/services/__init__.py index 391fc9a1..2598d105 100644 --- a/daemon/core/services/__init__.py +++ b/daemon/core/services/__init__.py @@ -6,11 +6,8 @@ __all__ is automatically loaded by the main core module. """ import os -from core.misc import log from core.service import ServiceManager -logger = log.get_logger(__name__) - _PATH = os.path.abspath(os.path.dirname(__file__)) diff --git a/daemon/core/services/dockersvc.py b/daemon/core/services/dockersvc.py index 2f682e26..0e65a42f 100644 --- a/daemon/core/services/dockersvc.py +++ b/daemon/core/services/dockersvc.py @@ -97,12 +97,10 @@ Limitations: depending on how many nodes you have. """ -from core.misc import log +from core import logger from core.service import CoreService from core.service import ServiceManager -logger = log.get_logger(__name__) - try: from docker import Client except ImportError: diff --git a/daemon/core/services/security.py b/daemon/core/services/security.py index 5331ef18..27478368 100644 --- a/daemon/core/services/security.py +++ b/daemon/core/services/security.py @@ -4,12 +4,10 @@ firewall) """ from core import constants -from core.misc import log +from core import logger from core.service import CoreService from core.service import ServiceManager -logger = log.get_logger(__name__) - class VPNClient(CoreService): _name = "VPNClient" diff --git a/daemon/core/services/xorp.py b/daemon/core/services/xorp.py index f03b6731..a626b0af 100644 --- a/daemon/core/services/xorp.py +++ b/daemon/core/services/xorp.py @@ -2,12 +2,10 @@ xorp.py: defines routing services provided by the XORP routing suite. """ -from core.misc import log +from core import logger from core.service import CoreService from core.service import ServiceManager -logger = log.get_logger(__name__) - class XorpRtrmgr(CoreService): """ diff --git a/daemon/core/session.py b/daemon/core/session.py index a9c7dd4a..b9ac4e12 100644 --- a/daemon/core/session.py +++ b/daemon/core/session.py @@ -17,6 +17,7 @@ import time import pwd from core import constants +from core import logger from core.api import coreapi from core.broker import CoreBroker from core.conf import Configurable @@ -36,7 +37,6 @@ from core.enumerations import MessageTypes from core.enumerations import NodeTypes from core.enumerations import RegisterTlvs from core.location import CoreLocation -from core.misc import log from core.misc import nodeutils from core.misc import utils from core.misc.event import EventLoop @@ -50,8 +50,6 @@ from core.service import CoreServices from core.xen.xenconfig import XenConfigManager from core.xml.xmlsession import save_session_xml -logger = log.get_logger(__name__) - class SessionManager(object): """ diff --git a/daemon/core/xen/xen.py b/daemon/core/xen/xen.py index bb656faf..74909f51 100644 --- a/daemon/core/xen/xen.py +++ b/daemon/core/xen/xen.py @@ -14,16 +14,14 @@ import threading import crypt from core import constants +from core import logger from core.coreobj import PyCoreNetIf from core.coreobj import PyCoreNode from core.enumerations import NodeTypes -from core.misc import log from core.misc import nodeutils from core.misc import utils from core.netns.vnode import LxcNode -logger = log.get_logger(__name__) - try: import parted except ImportError: diff --git a/daemon/core/xen/xenconfig.py b/daemon/core/xen/xenconfig.py index 7e3c6c46..42e6e842 100644 --- a/daemon/core/xen/xenconfig.py +++ b/daemon/core/xen/xenconfig.py @@ -17,6 +17,7 @@ import os import string from core import constants +from core import logger from core.api import coreapi from core.conf import Configurable from core.conf import ConfigurableManager @@ -24,9 +25,6 @@ from core.enumerations import ConfigDataTypes from core.enumerations import ConfigFlags from core.enumerations import ConfigTlvs from core.enumerations import RegisterTlvs -from core.misc import log - -logger = log.get_logger(__name__) class XenConfigManager(ConfigurableManager): diff --git a/daemon/core/xml/xmldeployment.py b/daemon/core/xml/xmldeployment.py index d94bfce6..91f22abb 100644 --- a/daemon/core/xml/xmldeployment.py +++ b/daemon/core/xml/xmldeployment.py @@ -4,6 +4,7 @@ import subprocess from core import constants from core import emane +from core import logger from core.enumerations import NodeTypes from core.misc import ipaddress from core.misc import log @@ -11,8 +12,6 @@ from core.misc import nodeutils from core.netns import nodes from core.xml import xmlutils -logger = log.get_logger(__name__) - class CoreDeploymentWriter(object): def __init__(self, dom, root, session): diff --git a/daemon/core/xml/xmlparser0.py b/daemon/core/xml/xmlparser0.py index e701879a..0c7108a7 100644 --- a/daemon/core/xml/xmlparser0.py +++ b/daemon/core/xml/xmlparser0.py @@ -1,13 +1,11 @@ from xml.dom.minidom import parse +from core import logger from core.enumerations import NodeTypes -from core.misc import log from core.misc import nodeutils from core.service import ServiceManager from core.xml import xmlutils -logger = log.get_logger(__name__) - class CoreDocumentParser0(object): def __init__(self, session, filename, options): diff --git a/daemon/core/xml/xmlparser1.py b/daemon/core/xml/xmlparser1.py index 3e2ec376..d325deb9 100644 --- a/daemon/core/xml/xmlparser1.py +++ b/daemon/core/xml/xmlparser1.py @@ -3,15 +3,13 @@ from xml.dom.minidom import Node from xml.dom.minidom import parse from core import constants +from core import logger from core.enumerations import NodeTypes -from core.misc import log from core.misc import nodeutils from core.misc.ipaddress import MacAddress from core.service import ServiceManager from core.xml import xmlutils -logger = log.get_logger(__name__) - class CoreDocumentParser1(object): layer2_device_types = 'hub', 'switch' diff --git a/daemon/core/xml/xmlutils.py b/daemon/core/xml/xmlutils.py index a911d81a..3300fcd1 100644 --- a/daemon/core/xml/xmlutils.py +++ b/daemon/core/xml/xmlutils.py @@ -1,10 +1,8 @@ from xml.dom.minidom import Node -from core.misc import log +from core import logger from core.netns import nodes -logger = log.get_logger(__name__) - def add_elements_from_list(dom, parent, iterable, name, attr_name): """ diff --git a/daemon/core/xml/xmlwriter0.py b/daemon/core/xml/xmlwriter0.py index 3b3c7b04..e7155ce8 100644 --- a/daemon/core/xml/xmlwriter0.py +++ b/daemon/core/xml/xmlwriter0.py @@ -3,14 +3,12 @@ from xml.dom.minidom import Document import pwd +from core import logger from core.coreobj import PyCoreNet from core.coreobj import PyCoreNode from core.enumerations import RegisterTlvs -from core.misc import log from core.xml import xmlutils -logger = log.get_logger(__name__) - class CoreDocumentWriter0(Document): """ diff --git a/daemon/core/xml/xmlwriter1.py b/daemon/core/xml/xmlwriter1.py index 19b882f2..c113ff31 100644 --- a/daemon/core/xml/xmlwriter1.py +++ b/daemon/core/xml/xmlwriter1.py @@ -5,18 +5,16 @@ from xml.dom.minidom import Document import pwd from core import coreobj +from core import logger from core.enumerations import EventTypes from core.enumerations import NodeTypes from core.enumerations import RegisterTlvs from core.misc import ipaddress -from core.misc import log from core.misc import nodeutils from core.netns import nodes from core.xml import xmlutils from core.xml.xmldeployment import CoreDeploymentWriter -logger = log.get_logger(__name__) - class Alias: ID = "COREID" diff --git a/daemon/requirements.txt b/daemon/requirements.txt index d626b47d..831a7390 100644 --- a/daemon/requirements.txt +++ b/daemon/requirements.txt @@ -1,4 +1,5 @@ enum34==1.1.6 +logzero==1.3.0 grpcio==1.0.0 grpcio-tools==1.0.0 mock==1.3.0 diff --git a/daemon/sbin/core-daemon b/daemon/sbin/core-daemon index 6f78afb2..ab492f13 100755 --- a/daemon/sbin/core-daemon +++ b/daemon/sbin/core-daemon @@ -17,7 +17,6 @@ message handlers are defined and some support for sending messages. import ConfigParser import atexit import importlib -import logging import optparse import os import signal @@ -30,19 +29,17 @@ from core import constants from core import corehandlers from core import coreserver from core import enumerations +from core import logger from core import services from core.api import coreapi from core.corehandlers import CoreDatagramRequestHandler from core.enumerations import MessageFlags from core.enumerations import RegisterTlvs -from core.misc import log from core.misc import nodemaps from core.misc import nodeutils from core.misc.utils import closeonexec from core.misc.utils import daemonize -logger = log.get_logger(__name__) - DEFAULT_MAXFD = 1024 @@ -337,8 +334,6 @@ def main(): if __name__ == "__main__": - log.setup(level=logging.INFO) - # configure nodes to use node_map = nodemaps.CLASSIC_NODES if len(sys.argv) == 2 and sys.argv[1] == "ovs": diff --git a/daemon/setup.py b/daemon/setup.py index 2931f02c..03006589 100644 --- a/daemon/setup.py +++ b/daemon/setup.py @@ -25,7 +25,8 @@ setup(name="core-python", "core.xml", ], install_requires=[ - "enum34" + "enum34" + "logzero" ], setup_requires=[ "pytest-runner"