switched to making use of logzero for logging, provides nicer color output, and an easier path to switch to rotating log files

This commit is contained in:
Blake J. Harnden 2017-08-07 11:58:51 -07:00
parent 76bec9950d
commit e4b280196b
53 changed files with 57 additions and 202 deletions

View file

@ -1,17 +1,9 @@
# Copyright (c)2010-2012 the Boeing Company. import logzero
# See the LICENSE file included in this distribution.
""" # configure custom format with function name
core _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. logger = logzero.logger
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 *

View file

@ -10,6 +10,7 @@ import struct
from enum import Enum from enum import Enum
from core import logger
from core.enumerations import ConfigTlvs from core.enumerations import ConfigTlvs
from core.enumerations import EventTlvs from core.enumerations import EventTlvs
from core.enumerations import EventTypes 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 IpAddress
from core.misc.ipaddress import MacAddress from core.misc.ipaddress import MacAddress
logger = log.get_logger(__name__)
class CoreTlvData(object): class CoreTlvData(object):
""" """

View file

@ -2,13 +2,11 @@
Converts CORE data objects into legacy API messages. Converts CORE data objects into legacy API messages.
""" """
from core import logger
from core.api import coreapi from core.api import coreapi
from core.enumerations import NodeTlvs from core.enumerations import NodeTlvs
from core.misc import log
from core.misc import structutils from core.misc import structutils
logger = log.get_logger(__name__)
def convert_node(node_data): def convert_node(node_data):
""" """

View file

@ -9,6 +9,7 @@ import select
import socket import socket
import threading import threading
from core import logger
from core.api import coreapi from core.api import coreapi
from core.conf import ConfigurableManager from core.conf import ConfigurableManager
from core.coreobj import PyCoreNet from core.coreobj import PyCoreNet
@ -26,15 +27,12 @@ from core.enumerations import MessageTypes
from core.enumerations import NodeTlvs from core.enumerations import NodeTlvs
from core.enumerations import NodeTypes from core.enumerations import NodeTypes
from core.enumerations import RegisterTlvs from core.enumerations import RegisterTlvs
from core.misc import log
from core.misc import nodeutils from core.misc import nodeutils
from core.misc.ipaddress import IpAddress from core.misc.ipaddress import IpAddress
from core.netns.vif import GreTap from core.netns.vif import GreTap
from core.netns.vnet import GreTapBridge from core.netns.vnet import GreTapBridge
from core.phys.pnodes import PhysicalNode from core.phys.pnodes import PhysicalNode
logger = log.get_logger(__name__)
# TODO: name conflict with main core server, probably should rename # TODO: name conflict with main core server, probably should rename
class CoreServer(object): class CoreServer(object):

View file

@ -15,6 +15,7 @@ import socket
import subprocess import subprocess
from core import constants from core import constants
from core import logger
from core.api import coreapi from core.api import coreapi
from core.bsd.netgraph import connectngnodes from core.bsd.netgraph import connectngnodes
from core.bsd.netgraph import ngloadkernelmodule from core.bsd.netgraph import ngloadkernelmodule
@ -26,11 +27,8 @@ from core.enumerations import LinkTypes
from core.enumerations import NodeTypes from core.enumerations import NodeTypes
from core.enumerations import RegisterTlvs from core.enumerations import RegisterTlvs
from core.misc import ipaddress from core.misc import ipaddress
from core.misc import log
from core.misc import utils from core.misc import utils
logger = log.get_logger(__name__)
utils.check_executables([constants.IFCONFIG_BIN]) utils.check_executables([constants.IFCONFIG_BIN])

View file

@ -11,14 +11,12 @@ vnet.py: NetgraphNet and NetgraphPipeNet classes that implement virtual networks
using the FreeBSD Netgraph subsystem. using the FreeBSD Netgraph subsystem.
""" """
from core import logger
from core.bsd.netgraph import connectngnodes from core.bsd.netgraph import connectngnodes
from core.bsd.netgraph import createngnode from core.bsd.netgraph import createngnode
from core.bsd.netgraph import destroyngnode from core.bsd.netgraph import destroyngnode
from core.bsd.netgraph import ngmessage from core.bsd.netgraph import ngmessage
from core.coreobj import PyCoreNet from core.coreobj import PyCoreNet
from core.misc import log
logger = log.get_logger(__name__)
class NetgraphNet(PyCoreNet): class NetgraphNet(PyCoreNet):

View file

@ -16,15 +16,13 @@ import subprocess
import threading import threading
from core import constants from core import constants
from core import logger
from core.bsd.netgraph import createngnode from core.bsd.netgraph import createngnode
from core.bsd.netgraph import destroyngnode from core.bsd.netgraph import destroyngnode
from core.coreobj import PyCoreNetIf from core.coreobj import PyCoreNetIf
from core.coreobj import PyCoreNode from core.coreobj import PyCoreNode
from core.misc import log
from core.misc import utils from core.misc import utils
logger = log.get_logger(__name__)
utils.check_executables([constants.IFCONFIG_BIN, constants.VIMAGE_BIN]) utils.check_executables([constants.IFCONFIG_BIN, constants.VIMAGE_BIN])

View file

@ -4,12 +4,10 @@ Common support for configurable CORE objects.
import string import string
from core import logger
from core.data import ConfigData from core.data import ConfigData
from core.enumerations import ConfigDataTypes from core.enumerations import ConfigDataTypes
from core.enumerations import ConfigFlags from core.enumerations import ConfigFlags
from core.misc import log
logger = log.get_logger(__name__)
class ConfigurableManager(object): class ConfigurableManager(object):

View file

@ -12,6 +12,7 @@ import threading
import time import time
from core import coreobj from core import coreobj
from core import logger
from core.api import coreapi from core.api import coreapi
from core.coreserver import CoreServer from core.coreserver import CoreServer
from core.data import ConfigData from core.data import ConfigData
@ -31,7 +32,6 @@ from core.enumerations import NodeTlvs
from core.enumerations import NodeTypes from core.enumerations import NodeTypes
from core.enumerations import RegisterTlvs from core.enumerations import RegisterTlvs
from core.enumerations import SessionTlvs from core.enumerations import SessionTlvs
from core.misc import log
from core.misc import nodeutils from core.misc import nodeutils
from core.misc import structutils from core.misc import structutils
from core.misc import utils 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 open_session_xml
from core.xml.xmlsession import save_session_xml from core.xml.xmlsession import save_session_xml
logger = log.get_logger(__name__)
class CoreRequestHandler(SocketServer.BaseRequestHandler): class CoreRequestHandler(SocketServer.BaseRequestHandler):
""" """

View file

@ -10,9 +10,7 @@ import threading
from socket import AF_INET from socket import AF_INET
from socket import AF_INET6 from socket import AF_INET6
from core.api import coreapi
from core.data import NodeData, LinkData from core.data import NodeData, LinkData
from core.enumerations import LinkTlvs
from core.enumerations import LinkTypes from core.enumerations import LinkTypes
from core.misc import ipaddress from core.misc import ipaddress

View file

@ -8,14 +8,12 @@ import os
import threading import threading
import time import time
from core import logger
from core.api import coreapi from core.api import coreapi
from core.enumerations import EventTypes from core.enumerations import EventTypes
from core.enumerations import SessionTlvs from core.enumerations import SessionTlvs
from core.misc import log
from core.session import Session from core.session import Session
logger = log.get_logger(__name__)
class CoreServer(SocketServer.ThreadingMixIn, SocketServer.TCPServer): class CoreServer(SocketServer.ThreadingMixIn, SocketServer.TCPServer):
""" """

View file

@ -1,10 +1,8 @@
import subprocess import subprocess
from core.misc import log from core import logger
from core.misc import utils from core.misc import utils
logger = log.get_logger(__name__)
EMANEUNK = 0 EMANEUNK = 0
EMANE074 = 7 EMANE074 = 7
EMANE081 = 8 EMANE081 = 8

View file

@ -3,11 +3,9 @@ commeffect.py: EMANE CommEffect model for CORE
""" """
from core import emane from core import emane
from core import logger
from core.emane.emanemodel import EmaneModel from core.emane.emanemodel import EmaneModel
from core.enumerations import ConfigDataTypes from core.enumerations import ConfigDataTypes
from core.misc import log
logger = log.get_logger(__name__)
try: try:
import emaneeventservice import emaneeventservice

View file

@ -9,6 +9,7 @@ from xml.dom.minidom import parseString
from core import constants from core import constants
from core import emane from core import emane
from core import logger
from core.api import coreapi from core.api import coreapi
from core.conf import ConfigurableManager from core.conf import ConfigurableManager
from core.emane.bypass import EmaneBypassModel from core.emane.bypass import EmaneBypassModel
@ -23,14 +24,11 @@ from core.enumerations import ConfigTlvs
from core.enumerations import MessageFlags from core.enumerations import MessageFlags
from core.enumerations import MessageTypes from core.enumerations import MessageTypes
from core.enumerations import RegisterTlvs from core.enumerations import RegisterTlvs
from core.misc import log
from core.misc import nodeutils from core.misc import nodeutils
from core.misc import utils from core.misc import utils
from core.misc.ipaddress import MacAddress from core.misc.ipaddress import MacAddress
from core.xml import xmlutils from core.xml import xmlutils
logger = log.get_logger(__name__)
# EMANE 0.7.4/0.8.1 # EMANE 0.7.4/0.8.1
try: try:
import emaneeventservice import emaneeventservice

View file

@ -3,13 +3,11 @@ Defines Emane Models used within CORE.
""" """
from core import emane from core import emane
from core.misc import log from core import logger
from core.misc import utils from core.misc import utils
from core.mobility import WirelessModel from core.mobility import WirelessModel
from core.xml import xmlutils from core.xml import xmlutils
logger = log.get_logger(__name__)
class EmaneModel(WirelessModel): class EmaneModel(WirelessModel):
""" """

View file

@ -6,9 +6,6 @@ from core import emane
from core.emane.emanemodel import EmaneModel from core.emane.emanemodel import EmaneModel
from core.emane.universal import EmaneUniversalModel from core.emane.universal import EmaneUniversalModel
from core.enumerations import ConfigDataTypes from core.enumerations import ConfigDataTypes
from core.misc import log
logger = log.get_logger(__name__)
class EmaneIeee80211abgModel(EmaneModel): class EmaneIeee80211abgModel(EmaneModel):

View file

@ -7,13 +7,11 @@ share the same MAC+PHY model.
from os import path from os import path
from core import emane from core import emane
from core import logger
from core.coreobj import PyCoreNet from core.coreobj import PyCoreNet
from core.enumerations import LinkTypes from core.enumerations import LinkTypes
from core.enumerations import NodeTypes from core.enumerations import NodeTypes
from core.enumerations import RegisterTlvs from core.enumerations import RegisterTlvs
from core.misc import log
logger = log.get_logger(__name__)
try: try:
from emanesh.events import LocationEvent from emanesh.events import LocationEvent

View file

@ -6,9 +6,6 @@ from core import emane
from core.emane.emanemodel import EmaneModel from core.emane.emanemodel import EmaneModel
from core.emane.universal import EmaneUniversalModel from core.emane.universal import EmaneUniversalModel
from core.enumerations import ConfigDataTypes from core.enumerations import ConfigDataTypes
from core.misc import log
logger = log.get_logger(__name__)
class EmaneRfPipeModel(EmaneModel): class EmaneRfPipeModel(EmaneModel):

View file

@ -6,9 +6,6 @@ from core import emane
from core.emane.emanemodel import EmaneModel from core.emane.emanemodel import EmaneModel
from core.emane.universal import EmaneUniversalModel from core.emane.universal import EmaneUniversalModel
from core.enumerations import ConfigDataTypes from core.enumerations import ConfigDataTypes
from core.misc import log
logger = log.get_logger(__name__)
class EmaneTdmaModel(EmaneModel): class EmaneTdmaModel(EmaneModel):

View file

@ -6,9 +6,6 @@ used for the Universal PHY.
from core import emane from core import emane
from core.emane.emanemodel import EmaneModel from core.emane.emanemodel import EmaneModel
from core.enumerations import ConfigDataTypes from core.enumerations import ConfigDataTypes
from core.misc import log
logger = log.get_logger(__name__)
class EmaneUniversalModel(EmaneModel): class EmaneUniversalModel(EmaneModel):

View file

@ -5,13 +5,11 @@ systems. Depends on utm contributed module, from
https://pypi.python.org/pypi/utm (version 0.3.0). https://pypi.python.org/pypi/utm (version 0.3.0).
""" """
from core import logger
from core.conf import ConfigurableManager from core.conf import ConfigurableManager
from core.enumerations import RegisterTlvs from core.enumerations import RegisterTlvs
from core.misc import log
from core.misc import utm from core.misc import utm
logger = log.get_logger(__name__)
class CoreLocation(ConfigurableManager): class CoreLocation(ConfigurableManager):
""" """

View file

@ -6,9 +6,7 @@ import heapq
import threading import threading
import time import time
from core.misc import log from core import logger
logger = log.get_logger(__name__)
class Timer(threading.Thread): class Timer(threading.Thread):

View file

@ -8,9 +8,7 @@ import struct
from socket import AF_INET from socket import AF_INET
from socket import AF_INET6 from socket import AF_INET6
from core.misc import log from core import logger
logger = log.get_logger(__name__)
class MacAddress(object): class MacAddress(object):

View file

@ -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)

View file

@ -4,9 +4,7 @@ Serves as a global point for storing and retrieving node types needed during sim
import pprint import pprint
from core.misc import log from core import logger
logger = log.get_logger(__name__)
_NODE_MAP = None _NODE_MAP = None

View file

@ -2,9 +2,7 @@
Utilities for working with python struct data. Utilities for working with python struct data.
""" """
from core.misc import log from core import logger
logger = log.get_logger(__name__)
def pack_values(clazz, packers): def pack_values(clazz, packers):

View file

@ -8,9 +8,7 @@ import subprocess
import fcntl import fcntl
import resource import resource
from core.misc import log from core import logger
logger = log.get_logger(__name__)
def closeonexec(fd): def closeonexec(fd):

View file

@ -9,6 +9,7 @@ import subprocess
import threading import threading
import time import time
from core import logger
from core.conf import Configurable from core.conf import Configurable
from core.conf import ConfigurableManager from core.conf import ConfigurableManager
from core.coreobj import PyCoreNode from core.coreobj import PyCoreNode
@ -20,11 +21,8 @@ from core.enumerations import MessageFlags
from core.enumerations import MessageTypes from core.enumerations import MessageTypes
from core.enumerations import NodeTlvs from core.enumerations import NodeTlvs
from core.enumerations import RegisterTlvs from core.enumerations import RegisterTlvs
from core.misc import log
from core.misc.ipaddress import IpAddress from core.misc.ipaddress import IpAddress
logger = log.get_logger(__name__)
class MobilityManager(ConfigurableManager): class MobilityManager(ConfigurableManager):
""" """

View file

@ -10,6 +10,7 @@ from socket import AF_INET
from socket import AF_INET6 from socket import AF_INET6
from core import constants from core import constants
from core import logger
from core.coreobj import PyCoreNetIf from core.coreobj import PyCoreNetIf
from core.coreobj import PyCoreNode from core.coreobj import PyCoreNode
from core.coreobj import PyCoreObj from core.coreobj import PyCoreObj
@ -18,14 +19,11 @@ from core.enumerations import LinkTypes
from core.enumerations import NodeTypes from core.enumerations import NodeTypes
from core.enumerations import RegisterTlvs from core.enumerations import RegisterTlvs
from core.misc import ipaddress from core.misc import ipaddress
from core.misc import log
from core.misc import utils from core.misc import utils
from core.netns.vnet import GreTapBridge from core.netns.vnet import GreTapBridge
from core.netns.vnet import LxBrNet from core.netns.vnet import LxBrNet
from core.netns.vnode import LxcNode from core.netns.vnode import LxcNode
logger = log.get_logger(__name__)
class CtrlNet(LxBrNet): class CtrlNet(LxBrNet):
""" """

View file

@ -9,21 +9,19 @@ from socket import AF_INET
from socket import AF_INET6 from socket import AF_INET6
from core import constants from core import constants
from core import logger
from core.coreobj import PyCoreNet from core.coreobj import PyCoreNet
from core.data import LinkData from core.data import LinkData
from core.enumerations import LinkTypes from core.enumerations import LinkTypes
from core.enumerations import NodeTypes from core.enumerations import NodeTypes
from core.enumerations import RegisterTlvs from core.enumerations import RegisterTlvs
from core.misc import ipaddress from core.misc import ipaddress
from core.misc import log
from core.misc import utils from core.misc import utils
from core.netns.vif import GreTap from core.netns.vif import GreTap
from core.netns.vif import VEth from core.netns.vif import VEth
from core.netns.vnet import EbtablesQueue from core.netns.vnet import EbtablesQueue
from core.netns.vnet import GreTapBridge from core.netns.vnet import GreTapBridge
logger = log.get_logger(__name__)
# a global object because all WLANs share the same queue # a global object because all WLANs share the same queue
# cannot have multiple threads invoking the ebtables commnd # cannot have multiple threads invoking the ebtables commnd
ebtables_queue = EbtablesQueue() ebtables_queue = EbtablesQueue()

View file

@ -6,14 +6,12 @@ import subprocess
import time import time
from core import constants from core import constants
from core import logger
from core.coreobj import PyCoreNetIf from core.coreobj import PyCoreNetIf
from core.enumerations import NodeTypes from core.enumerations import NodeTypes
from core.misc import log
from core.misc import nodeutils from core.misc import nodeutils
from core.misc import utils from core.misc import utils
logger = log.get_logger(__name__)
utils.check_executables([constants.IP_BIN]) utils.check_executables([constants.IP_BIN])

View file

@ -9,14 +9,12 @@ import threading
import time import time
from core import constants from core import constants
from core import logger
from core.coreobj import PyCoreNet from core.coreobj import PyCoreNet
from core.misc import log
from core.misc import utils from core.misc import utils
from core.netns.vif import GreTap from core.netns.vif import GreTap
from core.netns.vif import VEth from core.netns.vif import VEth
logger = log.get_logger(__name__)
utils.check_executables([ utils.check_executables([
constants.BRCTL_BIN, constants.BRCTL_BIN,
constants.IP_BIN, constants.IP_BIN,

View file

@ -11,18 +11,16 @@ import subprocess
import threading import threading
from core import constants from core import constants
from core import logger
from core.coreobj import PyCoreNetIf from core.coreobj import PyCoreNetIf
from core.coreobj import PyCoreNode from core.coreobj import PyCoreNode
from core.enumerations import NodeTypes from core.enumerations import NodeTypes
from core.misc import log
from core.misc import nodeutils from core.misc import nodeutils
from core.misc import utils from core.misc import utils
from core.netns import vnodeclient from core.netns import vnodeclient
from core.netns.vif import TunTap from core.netns.vif import TunTap
from core.netns.vif import VEth from core.netns.vif import VEth
logger = log.get_logger(__name__)
utils.check_executables([constants.IP_BIN]) utils.check_executables([constants.IP_BIN])

View file

@ -10,9 +10,7 @@ import stat
import subprocess import subprocess
from core import constants from core import constants
from core.misc import log from core import logger
logger = log.get_logger(__name__)
USE_VCMD_MODULE = True USE_VCMD_MODULE = True

View file

@ -7,14 +7,12 @@ import subprocess
import threading import threading
from core import constants from core import constants
from core import logger
from core.coreobj import PyCoreNode from core.coreobj import PyCoreNode
from core.misc import log
from core.misc import utils from core.misc import utils
from core.netns.vnet import GreTap from core.netns.vnet import GreTap
from core.netns.vnet import LxBrNet from core.netns.vnet import LxBrNet
logger = log.get_logger(__name__)
class PhysicalNode(PyCoreNode): class PhysicalNode(PyCoreNode):
def __init__(self, session, objid=None, name=None, nodedir=None, start=True): def __init__(self, session, objid=None, name=None, nodedir=None, start=True):

View file

@ -6,6 +6,7 @@ import socket
from urlparse import urlparse from urlparse import urlparse
from core import constants from core import constants
from core import logger
from core.api import coreapi from core.api import coreapi
from core.coreobj import PyCoreNet from core.coreobj import PyCoreNet
from core.coreobj import PyCoreObj from core.coreobj import PyCoreObj
@ -16,11 +17,8 @@ from core.enumerations import MessageFlags
from core.enumerations import MessageTypes from core.enumerations import MessageTypes
from core.enumerations import NodeTlvs from core.enumerations import NodeTlvs
from core.enumerations import NodeTypes from core.enumerations import NodeTypes
from core.misc import log
from core.misc import nodeutils 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 # TODO: A named tuple may be more appropriate, than abusing a class dict like this
class Bunch(object): class Bunch(object):

View file

@ -15,6 +15,7 @@ import sys
import time import time
from itertools import repeat from itertools import repeat
from core import logger
from core.conf import Configurable from core.conf import Configurable
from core.conf import ConfigurableManager from core.conf import ConfigurableManager
from core.data import ConfigData from core.data import ConfigData
@ -25,11 +26,8 @@ from core.enumerations import ConfigFlags
from core.enumerations import EventTypes from core.enumerations import EventTypes
from core.enumerations import MessageFlags from core.enumerations import MessageFlags
from core.enumerations import RegisterTlvs from core.enumerations import RegisterTlvs
from core.misc import log
from core.misc import utils from core.misc import utils
logger = log.get_logger(__name__)
def _valid_module(path, file_name): def _valid_module(path, file_name):
""" """
@ -120,28 +118,28 @@ class ServiceManager(object):
:return: list of core services :return: list of core services
:rtype: list :rtype: list
""" """
# validate path exists for importing
logger.info("getting custom services from: %s", path) logger.info("getting custom services from: %s", path)
parent_path = os.path.dirname(path) parent_path = os.path.dirname(path)
if parent_path not in sys.path: if parent_path not in sys.path:
logger.info("adding parent path to allow imports: %s", parent_path) logger.info("adding parent path to allow imports: %s", parent_path)
sys.path.append(parent_path) sys.path.append(parent_path)
# retrieve potential service modules, and filter out invalid modules
base_module = os.path.basename(path) base_module = os.path.basename(path)
module_names = os.listdir(path) module_names = os.listdir(path)
module_names = filter(lambda x: _valid_module(path, x), module_names) module_names = filter(lambda x: _valid_module(path, x), module_names)
module_names = map(lambda x: x[:-3], 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: for module_name in module_names:
import_statement = "%s.%s" % (base_module, module_name) import_statement = "%s.%s" % (base_module, module_name)
logger.info("importing custom service module: %s", import_statement) logger.info("importing custom service module: %s", import_statement)
module = importlib.import_module(import_statement) module = importlib.import_module(import_statement)
members = inspect.getmembers(module, lambda x: _is_service(module, x)) members = inspect.getmembers(module, lambda x: _is_service(module, x))
for member in members: for member in members:
# custom_services.append(member[1])
cls.add(member[1]) cls.add(member[1])
# return custom_services
class CoreServices(ConfigurableManager): class CoreServices(ConfigurableManager):
""" """

View file

@ -6,11 +6,8 @@ __all__ is automatically loaded by the main core module.
""" """
import os import os
from core.misc import log
from core.service import ServiceManager from core.service import ServiceManager
logger = log.get_logger(__name__)
_PATH = os.path.abspath(os.path.dirname(__file__)) _PATH = os.path.abspath(os.path.dirname(__file__))

View file

@ -97,12 +97,10 @@ Limitations:
depending on how many nodes you have. 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 CoreService
from core.service import ServiceManager from core.service import ServiceManager
logger = log.get_logger(__name__)
try: try:
from docker import Client from docker import Client
except ImportError: except ImportError:

View file

@ -4,12 +4,10 @@ firewall)
""" """
from core import constants from core import constants
from core.misc import log from core import logger
from core.service import CoreService from core.service import CoreService
from core.service import ServiceManager from core.service import ServiceManager
logger = log.get_logger(__name__)
class VPNClient(CoreService): class VPNClient(CoreService):
_name = "VPNClient" _name = "VPNClient"

View file

@ -2,12 +2,10 @@
xorp.py: defines routing services provided by the XORP routing suite. 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 CoreService
from core.service import ServiceManager from core.service import ServiceManager
logger = log.get_logger(__name__)
class XorpRtrmgr(CoreService): class XorpRtrmgr(CoreService):
""" """

View file

@ -17,6 +17,7 @@ import time
import pwd import pwd
from core import constants from core import constants
from core import logger
from core.api import coreapi from core.api import coreapi
from core.broker import CoreBroker from core.broker import CoreBroker
from core.conf import Configurable from core.conf import Configurable
@ -36,7 +37,6 @@ from core.enumerations import MessageTypes
from core.enumerations import NodeTypes from core.enumerations import NodeTypes
from core.enumerations import RegisterTlvs from core.enumerations import RegisterTlvs
from core.location import CoreLocation from core.location import CoreLocation
from core.misc import log
from core.misc import nodeutils from core.misc import nodeutils
from core.misc import utils from core.misc import utils
from core.misc.event import EventLoop from core.misc.event import EventLoop
@ -50,8 +50,6 @@ from core.service import CoreServices
from core.xen.xenconfig import XenConfigManager from core.xen.xenconfig import XenConfigManager
from core.xml.xmlsession import save_session_xml from core.xml.xmlsession import save_session_xml
logger = log.get_logger(__name__)
class SessionManager(object): class SessionManager(object):
""" """

View file

@ -14,16 +14,14 @@ import threading
import crypt import crypt
from core import constants from core import constants
from core import logger
from core.coreobj import PyCoreNetIf from core.coreobj import PyCoreNetIf
from core.coreobj import PyCoreNode from core.coreobj import PyCoreNode
from core.enumerations import NodeTypes from core.enumerations import NodeTypes
from core.misc import log
from core.misc import nodeutils from core.misc import nodeutils
from core.misc import utils from core.misc import utils
from core.netns.vnode import LxcNode from core.netns.vnode import LxcNode
logger = log.get_logger(__name__)
try: try:
import parted import parted
except ImportError: except ImportError:

View file

@ -17,6 +17,7 @@ import os
import string import string
from core import constants from core import constants
from core import logger
from core.api import coreapi from core.api import coreapi
from core.conf import Configurable from core.conf import Configurable
from core.conf import ConfigurableManager from core.conf import ConfigurableManager
@ -24,9 +25,6 @@ from core.enumerations import ConfigDataTypes
from core.enumerations import ConfigFlags from core.enumerations import ConfigFlags
from core.enumerations import ConfigTlvs from core.enumerations import ConfigTlvs
from core.enumerations import RegisterTlvs from core.enumerations import RegisterTlvs
from core.misc import log
logger = log.get_logger(__name__)
class XenConfigManager(ConfigurableManager): class XenConfigManager(ConfigurableManager):

View file

@ -4,6 +4,7 @@ import subprocess
from core import constants from core import constants
from core import emane from core import emane
from core import logger
from core.enumerations import NodeTypes from core.enumerations import NodeTypes
from core.misc import ipaddress from core.misc import ipaddress
from core.misc import log from core.misc import log
@ -11,8 +12,6 @@ from core.misc import nodeutils
from core.netns import nodes from core.netns import nodes
from core.xml import xmlutils from core.xml import xmlutils
logger = log.get_logger(__name__)
class CoreDeploymentWriter(object): class CoreDeploymentWriter(object):
def __init__(self, dom, root, session): def __init__(self, dom, root, session):

View file

@ -1,13 +1,11 @@
from xml.dom.minidom import parse from xml.dom.minidom import parse
from core import logger
from core.enumerations import NodeTypes from core.enumerations import NodeTypes
from core.misc import log
from core.misc import nodeutils from core.misc import nodeutils
from core.service import ServiceManager from core.service import ServiceManager
from core.xml import xmlutils from core.xml import xmlutils
logger = log.get_logger(__name__)
class CoreDocumentParser0(object): class CoreDocumentParser0(object):
def __init__(self, session, filename, options): def __init__(self, session, filename, options):

View file

@ -3,15 +3,13 @@ from xml.dom.minidom import Node
from xml.dom.minidom import parse from xml.dom.minidom import parse
from core import constants from core import constants
from core import logger
from core.enumerations import NodeTypes from core.enumerations import NodeTypes
from core.misc import log
from core.misc import nodeutils from core.misc import nodeutils
from core.misc.ipaddress import MacAddress from core.misc.ipaddress import MacAddress
from core.service import ServiceManager from core.service import ServiceManager
from core.xml import xmlutils from core.xml import xmlutils
logger = log.get_logger(__name__)
class CoreDocumentParser1(object): class CoreDocumentParser1(object):
layer2_device_types = 'hub', 'switch' layer2_device_types = 'hub', 'switch'

View file

@ -1,10 +1,8 @@
from xml.dom.minidom import Node from xml.dom.minidom import Node
from core.misc import log from core import logger
from core.netns import nodes from core.netns import nodes
logger = log.get_logger(__name__)
def add_elements_from_list(dom, parent, iterable, name, attr_name): def add_elements_from_list(dom, parent, iterable, name, attr_name):
""" """

View file

@ -3,14 +3,12 @@ from xml.dom.minidom import Document
import pwd import pwd
from core import logger
from core.coreobj import PyCoreNet from core.coreobj import PyCoreNet
from core.coreobj import PyCoreNode from core.coreobj import PyCoreNode
from core.enumerations import RegisterTlvs from core.enumerations import RegisterTlvs
from core.misc import log
from core.xml import xmlutils from core.xml import xmlutils
logger = log.get_logger(__name__)
class CoreDocumentWriter0(Document): class CoreDocumentWriter0(Document):
""" """

View file

@ -5,18 +5,16 @@ from xml.dom.minidom import Document
import pwd import pwd
from core import coreobj from core import coreobj
from core import logger
from core.enumerations import EventTypes from core.enumerations import EventTypes
from core.enumerations import NodeTypes from core.enumerations import NodeTypes
from core.enumerations import RegisterTlvs from core.enumerations import RegisterTlvs
from core.misc import ipaddress from core.misc import ipaddress
from core.misc import log
from core.misc import nodeutils from core.misc import nodeutils
from core.netns import nodes from core.netns import nodes
from core.xml import xmlutils from core.xml import xmlutils
from core.xml.xmldeployment import CoreDeploymentWriter from core.xml.xmldeployment import CoreDeploymentWriter
logger = log.get_logger(__name__)
class Alias: class Alias:
ID = "COREID" ID = "COREID"

View file

@ -1,4 +1,5 @@
enum34==1.1.6 enum34==1.1.6
logzero==1.3.0
grpcio==1.0.0 grpcio==1.0.0
grpcio-tools==1.0.0 grpcio-tools==1.0.0
mock==1.3.0 mock==1.3.0

View file

@ -17,7 +17,6 @@ message handlers are defined and some support for sending messages.
import ConfigParser import ConfigParser
import atexit import atexit
import importlib import importlib
import logging
import optparse import optparse
import os import os
import signal import signal
@ -30,19 +29,17 @@ from core import constants
from core import corehandlers from core import corehandlers
from core import coreserver from core import coreserver
from core import enumerations from core import enumerations
from core import logger
from core import services from core import services
from core.api import coreapi from core.api import coreapi
from core.corehandlers import CoreDatagramRequestHandler from core.corehandlers import CoreDatagramRequestHandler
from core.enumerations import MessageFlags from core.enumerations import MessageFlags
from core.enumerations import RegisterTlvs from core.enumerations import RegisterTlvs
from core.misc import log
from core.misc import nodemaps from core.misc import nodemaps
from core.misc import nodeutils from core.misc import nodeutils
from core.misc.utils import closeonexec from core.misc.utils import closeonexec
from core.misc.utils import daemonize from core.misc.utils import daemonize
logger = log.get_logger(__name__)
DEFAULT_MAXFD = 1024 DEFAULT_MAXFD = 1024
@ -337,8 +334,6 @@ def main():
if __name__ == "__main__": if __name__ == "__main__":
log.setup(level=logging.INFO)
# configure nodes to use # configure nodes to use
node_map = nodemaps.CLASSIC_NODES node_map = nodemaps.CLASSIC_NODES
if len(sys.argv) == 2 and sys.argv[1] == "ovs": if len(sys.argv) == 2 and sys.argv[1] == "ovs":

View file

@ -25,7 +25,8 @@ setup(name="core-python",
"core.xml", "core.xml",
], ],
install_requires=[ install_requires=[
"enum34" "enum34"
"logzero"
], ],
setup_requires=[ setup_requires=[
"pytest-runner" "pytest-runner"