Merge branch 'develop' into enhancement/distributed-flask

This commit is contained in:
Blake Harnden 2019-10-04 13:31:13 -07:00
commit cc9c0eec96
7 changed files with 17 additions and 24 deletions

View file

@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script. # Process this file with autoconf to produce a configure script.
# this defines the CORE version number, must be static for AC_INIT # this defines the CORE version number, must be static for AC_INIT
AC_INIT(core, 5.5.0) AC_INIT(core, 5.5.1)
# autoconf and automake initialization # autoconf and automake initialization
AC_CONFIG_SRCDIR([netns/version.h.in]) AC_CONFIG_SRCDIR([netns/version.h.in])

View file

@ -16,7 +16,6 @@ import sys
from past.builtins import basestring from past.builtins import basestring
from core import constants
from core.errors import CoreCommandError from core.errors import CoreCommandError
DEVNULL = open(os.devnull, "wb") DEVNULL = open(os.devnull, "wb")
@ -451,16 +450,13 @@ def load_classes(path, clazz):
return classes return classes
def load_logging_config(config_path=None): def load_logging_config(config_path):
""" """
Load CORE logging configuration file. Load CORE logging configuration file.
:param str config_path: path to logging config file, :param str config_path: path to logging config file
when None defaults to /etc/core/logging.conf
:return: nothing :return: nothing
""" """
if not config_path:
config_path = os.path.join(constants.CORE_CONF_DIR, "logging.conf")
with open(config_path, "r") as log_config_file: with open(config_path, "r") as log_config_file:
log_config = json.load(log_config_file) log_config = json.load(log_config_file)
logging.config.dictConfig(log_config) logging.config.dictConfig(log_config)

View file

@ -3,6 +3,7 @@
# Example CORE Python script that attaches N nodes to an EMANE 802.11abg network. # Example CORE Python script that attaches N nodes to an EMANE 802.11abg network.
import datetime import datetime
import logging
import parser import parser
from builtins import range from builtins import range
@ -10,9 +11,6 @@ from core.emane.ieee80211abg import EmaneIeee80211abgModel
from core.emulator.coreemu import CoreEmu from core.emulator.coreemu import CoreEmu
from core.emulator.emudata import IpPrefixes from core.emulator.emudata import IpPrefixes
from core.emulator.enumerations import EventTypes from core.emulator.enumerations import EventTypes
from core.utils import load_logging_config
load_logging_config()
def example(options): def example(options):
@ -52,6 +50,7 @@ def example(options):
def main(): def main():
logging.basicConfig(level=logging.INFO)
options = parser.parse_options("emane80211") options = parser.parse_options("emane80211")
start = datetime.datetime.now() start = datetime.datetime.now()
print( print(

View file

@ -6,15 +6,13 @@
# nodestep # nodestep
import datetime import datetime
import logging
import parser import parser
from builtins import range from builtins import range
from core.emulator.coreemu import CoreEmu from core.emulator.coreemu import CoreEmu
from core.emulator.emudata import IpPrefixes from core.emulator.emudata import IpPrefixes
from core.emulator.enumerations import EventTypes, NodeTypes from core.emulator.enumerations import EventTypes, NodeTypes
from core.utils import load_logging_config
load_logging_config()
def example(options): def example(options):
@ -56,8 +54,8 @@ def example(options):
def main(): def main():
logging.basicConfig(level=logging.INFO)
options = parser.parse_options("switch") options = parser.parse_options("switch")
start = datetime.datetime.now() start = datetime.datetime.now()
print("running switch example: nodes(%s) time(%s)" % (options.nodes, options.time)) print("running switch example: nodes(%s) time(%s)" % (options.nodes, options.time))
example(options) example(options)

View file

@ -4,13 +4,11 @@
# n nodes are connected to a virtual wlan; run test for testsec # n nodes are connected to a virtual wlan; run test for testsec
# and repeat for minnodes <= n <= maxnodes with a step size of # and repeat for minnodes <= n <= maxnodes with a step size of
# nodestep # nodestep
import logging
from builtins import range from builtins import range
from core.emulator.emudata import IpPrefixes from core.emulator.emudata import IpPrefixes
from core.emulator.enumerations import EventTypes, NodeTypes from core.emulator.enumerations import EventTypes, NodeTypes
from core.utils import load_logging_config
load_logging_config()
def example(nodes): def example(nodes):
@ -38,4 +36,5 @@ def example(nodes):
if __name__ in {"__main__", "__builtin__"}: if __name__ in {"__main__", "__builtin__"}:
logging.basicConfig(level=logging.INFO)
example(2) example(2)

View file

@ -6,6 +6,7 @@
# nodestep # nodestep
import datetime import datetime
import logging
import parser import parser
from builtins import range from builtins import range
@ -13,9 +14,6 @@ from core.emulator.coreemu import CoreEmu
from core.emulator.emudata import IpPrefixes, NodeOptions from core.emulator.emudata import IpPrefixes, NodeOptions
from core.emulator.enumerations import EventTypes, NodeTypes from core.emulator.enumerations import EventTypes, NodeTypes
from core.location.mobility import BasicRangeModel from core.location.mobility import BasicRangeModel
from core.utils import load_logging_config
load_logging_config()
def example(options): def example(options):
@ -60,6 +58,7 @@ def example(options):
def main(): def main():
logging.basicConfig(level=logging.INFO)
options = parser.parse_options("wlan") options = parser.parse_options("wlan")
start = datetime.datetime.now() start = datetime.datetime.now()

View file

@ -7,6 +7,7 @@ message handlers are defined and some support for sending messages.
import argparse import argparse
import logging import logging
import os
import sys import sys
import threading import threading
import time import time
@ -96,7 +97,7 @@ def get_merged_config(filename):
"numthreads": "1", "numthreads": "1",
"grpcport": "50051", "grpcport": "50051",
"grpcaddress": "localhost", "grpcaddress": "localhost",
"logfile": "" "logfile": os.path.join(constants.CORE_CONF_DIR, "logging.conf")
} }
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(
@ -125,9 +126,6 @@ def get_merged_config(filename):
cfg = ConfigParser(defaults) cfg = ConfigParser(defaults)
cfg.read(filename) cfg.read(filename)
# load logging configuration
load_logging_config(args.logfile)
section = "core-daemon" section = "core-daemon"
if not cfg.has_section(section): if not cfg.has_section(section):
cfg.add_section(section) cfg.add_section(section)
@ -149,6 +147,10 @@ def main():
""" """
# get a configuration merged from config file and command-line arguments # get a configuration merged from config file and command-line arguments
cfg = get_merged_config("%s/core.conf" % constants.CORE_CONF_DIR) cfg = get_merged_config("%s/core.conf" % constants.CORE_CONF_DIR)
# load logging configuration
load_logging_config(cfg["logfile"])
banner() banner()
try: try: