updates to how and where the node map is populated, now done in CoreEmu and CoreEmu provides a method for updating the map if desired
This commit is contained in:
parent
164f02e5ac
commit
fe4c21bad4
3 changed files with 31 additions and 17 deletions
|
@ -5,10 +5,15 @@ import sys
|
|||
|
||||
import core.services
|
||||
from core import logger
|
||||
from core.coreobj import PyCoreNode, PyCoreNet
|
||||
from core.coreobj import PyCoreNet
|
||||
from core.coreobj import PyCoreNode
|
||||
from core.data import NodeData
|
||||
from core.enumerations import NodeTypes, EventTypes, LinkTypes
|
||||
from core.future.futuredata import LinkOptions, NodeOptions
|
||||
from core.enumerations import EventTypes
|
||||
from core.enumerations import LinkTypes
|
||||
from core.enumerations import NodeTypes
|
||||
from core.future.futuredata import LinkOptions
|
||||
from core.future.futuredata import NodeOptions
|
||||
from core.misc import nodemaps
|
||||
from core.misc import nodeutils
|
||||
from core.session import Session
|
||||
from core.xml.xmlparser import core_document_parser
|
||||
|
@ -842,12 +847,26 @@ class CoreEmu(object):
|
|||
self.session_id_gen = IdGen(_id=59999)
|
||||
self.sessions = {}
|
||||
|
||||
# set default nodes
|
||||
# set default node map
|
||||
node_map = nodemaps.NODES
|
||||
nodeutils.set_node_map(node_map)
|
||||
|
||||
# load default services
|
||||
core.services.load()
|
||||
|
||||
# catch exit event
|
||||
atexit.register(self.shutdown)
|
||||
|
||||
def update_nodes(self, node_map):
|
||||
"""
|
||||
Updates node map used by core.
|
||||
|
||||
:param dict node_map: node map to update existing node map with
|
||||
:return: nothing
|
||||
"""
|
||||
nodeutils.update_node_map(node_map)
|
||||
|
||||
def shutdown(self):
|
||||
"""
|
||||
Shutdown all CORE session.
|
||||
|
|
|
@ -33,7 +33,6 @@ from core.enumerations import MessageFlags
|
|||
from core.enumerations import NodeTypes
|
||||
from core.enumerations import RegisterTlvs
|
||||
from core.location import CoreLocation
|
||||
from core.misc import nodemaps
|
||||
from core.misc import nodeutils
|
||||
from core.misc import utils
|
||||
from core.misc.event import EventLoop
|
||||
|
@ -46,10 +45,6 @@ from core.sdt import Sdt
|
|||
from core.service import CoreServices
|
||||
from core.xml.xmlsession import save_session_xml
|
||||
|
||||
# set default node map
|
||||
node_map = nodemaps.NODES
|
||||
nodeutils.set_node_map(node_map)
|
||||
|
||||
|
||||
class Session(object):
|
||||
"""
|
||||
|
|
|
@ -15,7 +15,6 @@ from core import enumerations
|
|||
from core import logger
|
||||
from core.legacy.corehandler import CoreHandler
|
||||
from core.legacy.coreserver import CoreServer
|
||||
from core.misc import nodeutils
|
||||
from core.misc.utils import close_onexec
|
||||
from core.service import ServiceManager
|
||||
|
||||
|
@ -29,11 +28,12 @@ def banner():
|
|||
logger.info("CORE daemon v.%s started %s", constants.COREDPY_VERSION, time.ctime())
|
||||
|
||||
|
||||
def cored(cfg=None):
|
||||
def cored(cfg, use_ovs):
|
||||
"""
|
||||
Start the CoreServer object and enter the server loop.
|
||||
|
||||
:param dict cfg: core configuration
|
||||
:param bool use_ovs: flag to determine if ovs nodes should be used
|
||||
:return: nothing
|
||||
"""
|
||||
host = cfg["listenaddr"]
|
||||
|
@ -43,6 +43,9 @@ def cored(cfg=None):
|
|||
|
||||
try:
|
||||
server = CoreServer((host, port), CoreHandler, cfg)
|
||||
if use_ovs:
|
||||
from core.netns.openvswitch import OVS_NODES
|
||||
server.coreemu.update_nodes(OVS_NODES)
|
||||
except:
|
||||
logger.exception("error starting main server on: %s:%s", host, port)
|
||||
sys.exit(1)
|
||||
|
@ -123,8 +126,11 @@ def main():
|
|||
|
||||
banner()
|
||||
|
||||
# check if ovs flag was provided
|
||||
use_ovs = len(sys.argv) == 2 and sys.argv[1] == "ovs"
|
||||
|
||||
try:
|
||||
cored(cfg)
|
||||
cored(cfg, use_ovs)
|
||||
except KeyboardInterrupt:
|
||||
logger.info("keyboard interrupt, stopping core daemon")
|
||||
|
||||
|
@ -132,10 +138,4 @@ def main():
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# configure nodes to use
|
||||
if len(sys.argv) == 2 and sys.argv[1] == "ovs":
|
||||
from core.netns.openvswitch import OVS_NODES
|
||||
|
||||
nodeutils.update_node_map(OVS_NODES)
|
||||
|
||||
main()
|
||||
|
|
Loading…
Reference in a new issue