add default node map configuration, to avoid the need to set this up every time
This commit is contained in:
parent
afb6af5f87
commit
42bcb1c79d
14 changed files with 38 additions and 63 deletions
|
@ -9,6 +9,12 @@ from core import logger
|
||||||
_NODE_MAP = None
|
_NODE_MAP = None
|
||||||
|
|
||||||
|
|
||||||
|
def _log_map():
|
||||||
|
global _NODE_MAP
|
||||||
|
print_map = reduce(lambda x, y: _convert_map(x, y), _NODE_MAP.items(), {})
|
||||||
|
logger.info("node class map: \n%s", pprint.pformat(print_map, indent=4))
|
||||||
|
|
||||||
|
|
||||||
def _convert_map(x, y):
|
def _convert_map(x, y):
|
||||||
"""
|
"""
|
||||||
Convenience method to create a human readable version of the node map to log.
|
Convenience method to create a human readable version of the node map to log.
|
||||||
|
@ -21,6 +27,18 @@ def _convert_map(x, y):
|
||||||
return x
|
return x
|
||||||
|
|
||||||
|
|
||||||
|
def update_node_map(node_map):
|
||||||
|
"""
|
||||||
|
Update the current node map with the provided node map values.
|
||||||
|
|
||||||
|
|
||||||
|
:param dict node_map: node map to update with
|
||||||
|
"""
|
||||||
|
global _NODE_MAP
|
||||||
|
_NODE_MAP.update(node_map)
|
||||||
|
_log_map()
|
||||||
|
|
||||||
|
|
||||||
def set_node_map(node_map):
|
def set_node_map(node_map):
|
||||||
"""
|
"""
|
||||||
Set the global node map that proides a consistent way to retrieve differently configured nodes.
|
Set the global node map that proides a consistent way to retrieve differently configured nodes.
|
||||||
|
@ -29,9 +47,8 @@ def set_node_map(node_map):
|
||||||
:return: nothing
|
:return: nothing
|
||||||
"""
|
"""
|
||||||
global _NODE_MAP
|
global _NODE_MAP
|
||||||
print_map = reduce(lambda x, y: _convert_map(x, y), node_map.items(), {})
|
|
||||||
logger.info("setting node class map: \n%s", pprint.pformat(print_map, indent=4))
|
|
||||||
_NODE_MAP = node_map
|
_NODE_MAP = node_map
|
||||||
|
_log_map()
|
||||||
|
|
||||||
|
|
||||||
def get_node_class(node_type):
|
def get_node_class(node_type):
|
||||||
|
|
|
@ -35,6 +35,7 @@ from core.enumerations import MessageFlags
|
||||||
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 nodemaps
|
||||||
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
|
||||||
|
@ -49,6 +50,11 @@ from core.xen.xenconfig import XenConfigManager
|
||||||
from core.xml.xmlsession import save_session_xml
|
from core.xml.xmlsession import save_session_xml
|
||||||
|
|
||||||
|
|
||||||
|
# set default node map
|
||||||
|
node_map = nodemaps.NODES
|
||||||
|
nodeutils.set_node_map(node_map)
|
||||||
|
|
||||||
|
|
||||||
class SessionManager(object):
|
class SessionManager(object):
|
||||||
"""
|
"""
|
||||||
Manages currently known sessions.
|
Manages currently known sessions.
|
||||||
|
|
|
@ -13,8 +13,7 @@ import optparse
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from core.misc import ipaddress, nodeutils
|
from core.misc import ipaddress
|
||||||
from core.misc import nodemaps
|
|
||||||
from core.mobility import BasicRangeModel
|
from core.mobility import BasicRangeModel
|
||||||
from core.netns.nodes import WlanNode
|
from core.netns.nodes import WlanNode
|
||||||
from core.netns.vnet import EbtablesQueue
|
from core.netns.vnet import EbtablesQueue
|
||||||
|
@ -108,8 +107,4 @@ def main():
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
# configure nodes to use
|
|
||||||
node_map = nodemaps.NODES
|
|
||||||
nodeutils.set_node_map(node_map)
|
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|
|
@ -25,7 +25,7 @@ from core.enumerations import LinkTlvs
|
||||||
from core.enumerations import LinkTypes
|
from core.enumerations import LinkTypes
|
||||||
from core.enumerations import MessageFlags
|
from core.enumerations import MessageFlags
|
||||||
from core.enumerations import MessageTypes
|
from core.enumerations import MessageTypes
|
||||||
from core.misc import ipaddress, nodeutils, nodemaps
|
from core.misc import ipaddress
|
||||||
from core.netns import nodes
|
from core.netns import nodes
|
||||||
|
|
||||||
# declare classes for use with Broker
|
# declare classes for use with Broker
|
||||||
|
@ -187,8 +187,4 @@ def main():
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__" or __name__ == "__builtin__":
|
if __name__ == "__main__" or __name__ == "__builtin__":
|
||||||
# configure nodes to use
|
|
||||||
node_map = nodemaps.NODES
|
|
||||||
nodeutils.set_node_map(node_map)
|
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|
|
@ -16,7 +16,7 @@ import sys
|
||||||
from core import constants
|
from core import constants
|
||||||
from core.api import coreapi, dataconversion
|
from core.api import coreapi, dataconversion
|
||||||
from core.enumerations import CORE_API_PORT, EventTypes, EventTlvs, LinkTlvs, LinkTypes, MessageFlags
|
from core.enumerations import CORE_API_PORT, EventTypes, EventTlvs, LinkTlvs, LinkTypes, MessageFlags
|
||||||
from core.misc import ipaddress, nodeutils, nodemaps
|
from core.misc import ipaddress
|
||||||
from core.netns import nodes
|
from core.netns import nodes
|
||||||
from core.session import Session
|
from core.session import Session
|
||||||
|
|
||||||
|
@ -124,8 +124,4 @@ def main():
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__" or __name__ == "__builtin__":
|
if __name__ == "__main__" or __name__ == "__builtin__":
|
||||||
# configure nodes to use
|
|
||||||
node_map = nodemaps.NODES
|
|
||||||
nodeutils.set_node_map(node_map)
|
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|
|
@ -13,7 +13,7 @@ import sys
|
||||||
from core import constants
|
from core import constants
|
||||||
from core.emane.ieee80211abg import EmaneIeee80211abgModel
|
from core.emane.ieee80211abg import EmaneIeee80211abgModel
|
||||||
from core.emane.nodes import EmaneNode
|
from core.emane.nodes import EmaneNode
|
||||||
from core.misc import ipaddress, nodeutils, nodemaps
|
from core.misc import ipaddress
|
||||||
from core.netns import nodes
|
from core.netns import nodes
|
||||||
|
|
||||||
# node list (count from 1)
|
# node list (count from 1)
|
||||||
|
@ -100,8 +100,4 @@ def main():
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__" or __name__ == "__builtin__":
|
if __name__ == "__main__" or __name__ == "__builtin__":
|
||||||
# configure nodes to use
|
|
||||||
node_map = nodemaps.NODES
|
|
||||||
nodeutils.set_node_map(node_map)
|
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|
|
@ -20,7 +20,7 @@ import sys
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from core import constants
|
from core import constants
|
||||||
from core.misc import ipaddress, nodeutils, nodemaps
|
from core.misc import ipaddress
|
||||||
from core.netns import nodes
|
from core.netns import nodes
|
||||||
from core.session import Session
|
from core.session import Session
|
||||||
|
|
||||||
|
@ -206,8 +206,4 @@ def main():
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
# configure nodes to use
|
|
||||||
node_map = nodemaps.NODES
|
|
||||||
nodeutils.set_node_map(node_map)
|
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|
|
@ -19,7 +19,7 @@ import optparse
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from core import constants
|
from core import constants
|
||||||
from core.misc import ipaddress, nodeutils, nodemaps
|
from core.misc import ipaddress
|
||||||
from core.netns import nodes
|
from core.netns import nodes
|
||||||
|
|
||||||
# node list (count from 1)
|
# node list (count from 1)
|
||||||
|
@ -100,8 +100,4 @@ def main():
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__" or __name__ == "__builtin__":
|
if __name__ == "__main__" or __name__ == "__builtin__":
|
||||||
# configure nodes to use
|
|
||||||
node_map = nodemaps.NODES
|
|
||||||
nodeutils.set_node_map(node_map)
|
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|
|
@ -16,7 +16,7 @@ import time
|
||||||
from string import Template
|
from string import Template
|
||||||
|
|
||||||
from core.constants import QUAGGA_STATE_DIR
|
from core.constants import QUAGGA_STATE_DIR
|
||||||
from core.misc import ipaddress, nodeutils, nodemaps
|
from core.misc import ipaddress
|
||||||
from core.misc.utils import mutecall
|
from core.misc.utils import mutecall
|
||||||
from core.netns import nodes
|
from core.netns import nodes
|
||||||
|
|
||||||
|
@ -602,8 +602,4 @@ def main():
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
# configure nodes to use
|
|
||||||
node_map = nodemaps.NODES
|
|
||||||
nodeutils.set_node_map(node_map)
|
|
||||||
|
|
||||||
me = main()
|
me = main()
|
||||||
|
|
|
@ -10,7 +10,7 @@ import optparse
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from core import constants
|
from core import constants
|
||||||
from core.misc import ipaddress, nodeutils, nodemaps
|
from core.misc import ipaddress
|
||||||
from core.netns import nodes
|
from core.netns import nodes
|
||||||
|
|
||||||
# node list (count from 1)
|
# node list (count from 1)
|
||||||
|
@ -73,8 +73,4 @@ def main():
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__" or __name__ == "__builtin__":
|
if __name__ == "__main__" or __name__ == "__builtin__":
|
||||||
# configure nodes to use
|
|
||||||
node_map = nodemaps.NODES
|
|
||||||
nodeutils.set_node_map(node_map)
|
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|
|
@ -12,7 +12,7 @@ import datetime
|
||||||
import optparse
|
import optparse
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from core.misc import ipaddress, nodeutils, nodemaps
|
from core.misc import ipaddress
|
||||||
from core.misc.utils import mutecall
|
from core.misc.utils import mutecall
|
||||||
from core.netns import nodes
|
from core.netns import nodes
|
||||||
from core.session import Session
|
from core.session import Session
|
||||||
|
@ -101,8 +101,4 @@ def main():
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
# configure nodes to use
|
|
||||||
node_map = nodemaps.NODES
|
|
||||||
nodeutils.set_node_map(node_map)
|
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|
|
@ -41,7 +41,7 @@ from core import emane
|
||||||
from core.emane.bypass import EmaneBypassModel
|
from core.emane.bypass import EmaneBypassModel
|
||||||
from core.emane.nodes import EmaneNode
|
from core.emane.nodes import EmaneNode
|
||||||
from core.emane.rfpipe import EmaneRfPipeModel
|
from core.emane.rfpipe import EmaneRfPipeModel
|
||||||
from core.misc import ipaddress, nodemaps, nodeutils
|
from core.misc import ipaddress
|
||||||
from core.netns import nodes
|
from core.netns import nodes
|
||||||
from core.session import Session
|
from core.session import Session
|
||||||
|
|
||||||
|
@ -851,8 +851,4 @@ def main():
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
# configure nodes to use
|
|
||||||
node_map = nodemaps.NODES
|
|
||||||
nodeutils.set_node_map(node_map)
|
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|
|
@ -12,7 +12,7 @@ import datetime
|
||||||
import optparse
|
import optparse
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from core.misc import ipaddress, nodeutils, nodemaps
|
from core.misc import ipaddress
|
||||||
from core.misc.utils import mutecall
|
from core.misc.utils import mutecall
|
||||||
from core.netns import nodes
|
from core.netns import nodes
|
||||||
from core.session import Session
|
from core.session import Session
|
||||||
|
@ -99,8 +99,4 @@ def main():
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
# configure nodes to use
|
|
||||||
node_map = nodemaps.NODES
|
|
||||||
nodeutils.set_node_map(node_map)
|
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|
|
@ -336,17 +336,14 @@ def main():
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
# configure nodes to use
|
# configure nodes to use
|
||||||
node_map = nodemaps.NODES
|
|
||||||
if len(sys.argv) == 2 and sys.argv[1] == "ovs":
|
if len(sys.argv) == 2 and sys.argv[1] == "ovs":
|
||||||
from core.netns.openvswitch import OVS_NODES
|
from core.netns.openvswitch import OVS_NODES
|
||||||
node_map.update(OVS_NODES)
|
nodeutils.update_node_map(OVS_NODES)
|
||||||
|
|
||||||
# update with BSD based nodes
|
# update with BSD based nodes
|
||||||
if os.uname()[0] == "FreeBSD":
|
if os.uname()[0] == "FreeBSD":
|
||||||
from core.bsd.nodes import BSD_NODES
|
from core.bsd.nodes import BSD_NODES
|
||||||
node_map.update(BSD_NODES)
|
nodeutils.update_node_map(BSD_NODES)
|
||||||
|
|
||||||
nodeutils.set_node_map(node_map)
|
|
||||||
|
|
||||||
# load default services
|
# load default services
|
||||||
services.load()
|
services.load()
|
||||||
|
|
Loading…
Reference in a new issue