Esempio n. 1
0
 def __init__(self, session, verbose = False):
     ConfigurableManager.__init__(self, session)
     self.session_id_master = None
     self.myip = None
     self.verbose = verbose
     # dict containing tuples of (host, port, sock)
     self.servers = {}
     self.servers_lock = threading.Lock()
     self.addserver("localhost", None, None)
     # dict containing node number to server name mapping
     self.nodemap = {}
     # this lock also protects self.nodecounts
     self.nodemap_lock = threading.Lock()
     # reference counts of nodes on servers
     self.nodecounts = { }
     self.bootcount = 0
     # list of node numbers that are link-layer nodes (networks)
     self.nets = []
     # list of node numbers that are PhysicalNode nodes
     self.phys = []
     # allows for other message handlers to process API messages (e.g. EMANE)
     self.handlers = ()
     # dict with tunnel key to tunnel device mapping
     self.tunnels = {}
     self.dorecvloop = False
     self.recvthread = None
Esempio n. 2
0
    def __init__(self, session):
        """
        Creates a Emane instance.

        :param core.session.Session session: session this manager is tied to
        :return: nothing
        """
        ConfigurableManager.__init__(self)
        self.session = session
        self._emane_nodes = {}
        self._emane_node_lock = threading.Lock()
        self._ifccounts = {}
        self._ifccountslock = threading.Lock()
        # Port numbers are allocated from these counters
        self.platformport = self.session.get_config_item_int(
            "emane_platform_port", 8100)
        self.transformport = self.session.get_config_item_int(
            "emane_transform_port", 8200)
        self.doeventloop = False
        self.eventmonthread = None

        # model for global EMANE configuration options
        self.emane_config = EmaneGlobalModel(session, None)
        session.broker.handlers.add(self.handledistributed)
        self.service = None
        self.event_device = None
        self._modelclsmap = {self.emane_config.name: self.emane_config}

        self.service = None
        self.emane_check()
Esempio n. 3
0
    def __init__(self, session, verbose = False):
        ConfigurableManager.__init__(self, session)
        self.session_id_master = None
        self.myip = None
        self.verbose = verbose
        # dict containing tuples of (host, port, sock)
        self.servers = {}
        self.servers_lock = threading.Lock()
        self.addserver("localhost", None, None)
        # dict containing node number to server name mapping
        self.nodemap = {}
        # this lock also protects self.nodecounts
        self.nodemap_lock = threading.Lock()
        # reference counts of nodes on servers
        self.nodecounts = { }
        self.bootcount = 0
        # list of node numbers that are link-layer nodes (networks)
        self.nets = []
        # list of node numbers that are PhysicalNode nodes
        self.phys = []
        # allows for other message handlers to process API messages (e.g. EMANE)
        self.handlers = ()
        # dict with tunnel key to tunnel device mapping
        self.tunnels = {}
        self.dorecvloop = False
        self.recvthread = None

        self.recvbuffer = {}
Esempio n. 4
0
File: emane.py Progetto: Benocs/core
 def __init__(self, session):
     ConfigurableManager.__init__(self, session)
     self.verbose = self.session.getcfgitembool('verbose', False)
     self._objs = {}
     self._objslock = threading.Lock()
     self._ifccounts = {}
     self._ifccountslock = threading.Lock()
     self._modelclsmap = {}
     # Port numbers are allocated from these counters
     self.platformport = self.session.getcfgitemint('emane_platform_port',
                                                    8100)
     self.transformport = self.session.getcfgitemint('emane_transform_port',
                                                     8200)
     # model for global EMANE configuration options
     self.emane_config = EmaneGlobalModel(session, None, self.verbose)
     session.broker.handlers += (self.handledistributed, )
     self.loadmodels()
     self.initeventservice()
     self.doeventloop = False
     self.eventmonthread = None
     # EMANE 0.7.4 support -- to be removed when 0.7.4 support is deprecated
     self.emane074 = False
     try:
         tmp = emaneeventlocation.EventLocation(1)
         # check if yaw parameter is supported by Location Events
         # if so, we have EMANE 0.8.1+; if not, we have EMANE 0.7.4/earlier
         tmp.set(0, 1, 2, 2, 2, 3)
     except TypeError:
         self.emane074 = True
     except Exception:
         pass
Esempio n. 5
0
    def __init__(self, session):
        """
        Creates a CoreBroker instance.

        :param core.session.Session session: session this manager is tied to
        :return: nothing
        """

        ConfigurableManager.__init__(self)
        self.session = session
        self.session_clients = []
        self.session_id_master = None
        self.myip = None
        # dict containing tuples of (host, port, sock)
        self.servers = {}
        self.servers_lock = threading.Lock()
        self.addserver("localhost", None, None)
        # dict containing node number to server name mapping
        self.nodemap = {}
        # this lock also protects self.nodecounts
        self.nodemap_lock = threading.Lock()
        # reference counts of nodes on servers
        self.nodecounts = {}
        # set of node numbers that are link-layer nodes (networks)
        self.network_nodes = set()
        # set of node numbers that are PhysicalNode nodes
        self.physical_nodes = set()
        # allows for other message handlers to process API messages (e.g. EMANE)
        self.handlers = set()
        self.handlers.add(self.handle_distributed)
        # dict with tunnel key to tunnel device mapping
        self.tunnels = {}
        self.dorecvloop = False
        self.recvthread = None
        self.bootcount = 0
Esempio n. 6
0
 def __init__(self, session):
     ConfigurableManager.__init__(self, session)
     self.verbose = self.session.getcfgitembool('verbose', False)
     # configurations for basic range, indexed by WLAN node number, are
     # stored in self.configs
     # mapping from model names to their classes
     self._modelclsmap = {}
     # dummy node objects for tracking position of nodes on other servers
     self.phys = {}
     self.physnets = {}
     self.session.broker.handlers += (self.physnodehandlelink, )
     self.register()
Esempio n. 7
0
 def __init__(self, session):
     ConfigurableManager.__init__(self, session)
     self.verbose = self.session.getcfgitembool('verbose', False)
     # configurations for basic range, indexed by WLAN node number, are
     # stored in self.configs
     # mapping from model names to their classes
     self._modelclsmap = {}
     # dummy node objects for tracking position of nodes on other servers
     self.phys = {}
     self.physnets = {}
     self.session.broker.handlers += (self.physnodehandlelink, )
     self.register()
Esempio n. 8
0
 def __init__(self, session):
     ConfigurableManager.__init__(self, session)
     # dict of default services tuples, key is node type
     self.defaultservices = {}
     # dict of tuple of service objects, key is node number
     self.customservices = {}
     importcmd = "from core.services import *"
     exec(importcmd)
     paths = self.session.getcfgitem('custom_services_dir')
     if paths:
         for path in paths.split(','):
             path = path.strip()
             self.importcustom(path)
Esempio n. 9
0
    def test_config_reset_node(self):
        # given
        config_manager = ConfigurableManager()
        test_config = {1: 2}
        node_id = 1
        config_manager.set_configs(test_config)
        config_manager.set_configs(test_config, node_id=node_id)

        # when
        config_manager.config_reset(node_id)

        # then
        assert not config_manager.get_configs(node_id=node_id)
        assert config_manager.get_configs()
Esempio n. 10
0
    def __init__(self):
        """
        Creates a MobilityManager instance.

        :return: nothing
        """
        ConfigurableManager.__init__(self)
        self.reset()
        self.zonemap = {}
        self.refxyz = (0.0, 0.0, 0.0)
        self.refscale = 1.0
        self.zoneshifts = {}
        self.refgeo = (0.0, 0.0, 0.0)
        for n, l in utm.ZONE_LETTERS:
            self.zonemap[l] = n
Esempio n. 11
0
 def getconfig(self, nodenum, conftype, defaultvalues):
     """ get configuration values for a node; if the values don't exist in
         our dictionary then return the default values supplied; if conftype
         is None then we return a match on any conftype.
     """
     if nodenum is None:
         nodenum = 0  # used for storing the global default config
     return ConfigurableManager.getconfig(self, nodenum, conftype, defaultvalues)
 def setconfig(self, nodenum, conftype, values):
     ''' add configuration values for a node to a dictionary; values are
         usually received from a Configuration Message, and may refer to a
         node for which no object exists yet
     '''
     if nodenum is None:
         nodenum = 0  # used for storing the global default config
     return ConfigurableManager.setconfig(self, nodenum, conftype, values)
Esempio n. 13
0
 def setconfig(self, nodenum, conftype, values):
     ''' add configuration values for a node to a dictionary; values are
         usually received from a Configuration Message, and may refer to a
         node for which no object exists yet
     '''
     if nodenum is None: 
         nodenum = 0 # used for storing the global default config
     return ConfigurableManager.setconfig(self, nodenum, conftype, values)
Esempio n. 14
0
    def __init__(self, session):
        """
        Creates a CoreServices instance.

        :param core.session.Session session: session this manager is tied to
        :return: nothing
        """
        ConfigurableManager.__init__(self)
        self.session = session
        # dict of default services tuples, key is node type
        self.defaultservices = {}
        # dict of tuple of service objects, key is node number
        self.customservices = {}

        # TODO: remove need for cyclic import
        from core.services import startup
        self.is_startup_service = startup.Startup.is_startup_service
 def getconfig(self, nodenum, conftype, defaultvalues):
     ''' get configuration values for a node; if the values don't exist in
         our dictionary then return the default values supplied; if conftype
         is None then we return a match on any conftype.
     '''
     if nodenum is None:
         nodenum = 0  # used for storing the global default config
     return ConfigurableManager.getconfig(self, nodenum, conftype,
                                          defaultvalues)
Esempio n. 16
0
    def __init__(self, session):
        """
        Creates a MobilityManager instance.

        :param core.session.Session session: session this manager is tied to
        """
        ConfigurableManager.__init__(self)
        self.session = session
        # configurations for basic range, indexed by WLAN node number, are
        # stored in self.configs
        # mapping from model names to their classes
        self._modelclsmap = {
            BasicRangeModel.name: BasicRangeModel,
            Ns2ScriptedMobility.name: Ns2ScriptedMobility
        }
        # dummy node objects for tracking position of nodes on other servers
        self.phys = {}
        self.physnets = {}
        self.session.broker.handlers.add(self.physnodehandlelink)
Esempio n. 17
0
    def test_config_reset_all(self):
        # given
        config_manager = ConfigurableManager()
        test_config = {1: 2}
        node_id = 1
        config_manager.set_configs(test_config)
        config_manager.set_configs(test_config, node_id=node_id)

        # when
        config_manager.config_reset()

        # then
        assert not config_manager.node_configurations
Esempio n. 18
0
    def test_configs_setget(self):
        # given
        config_manager = ConfigurableManager()
        test_config = {1: 2}
        node_id = 1
        config_manager.set_configs(test_config)
        config_manager.set_configs(test_config, node_id=node_id)

        # when
        default_config = config_manager.get_configs()
        node_config = config_manager.get_configs(node_id)

        # then
        assert default_config
        assert node_config
Esempio n. 19
0
    def test_config_setget(self):
        # given
        config_manager = ConfigurableManager()
        name = "test"
        value = "1"
        node_id = 1
        config_manager.set_config(name, value)
        config_manager.set_config(name, value, node_id=node_id)

        # when
        defaults_value = config_manager.get_config(name)
        node_value = config_manager.get_config(name, node_id=node_id)

        # then
        assert defaults_value == value
        assert node_value == value
Esempio n. 20
0
    def __init__(self, session):
        """
        Creates a CoreServices instance.

        :param core.session.Session session: session this manager is tied to
        :return: nothing
        """
        ConfigurableManager.__init__(self)
        self.session = session
        # dict of default services tuples, key is node type
        self.defaultservices = {}
        # dict of tuple of service objects, key is node number
        self.customservices = {}

        paths = self.session.get_config_item('custom_services_dir')
        if paths:
            for path in paths.split(','):
                path = path.strip()
                self.importcustom(path)

        # TODO: remove need for cyclic import
        from core.services import startup
        self.is_startup_service = startup.Startup.is_startup_service
Esempio n. 21
0
File: emane.py Progetto: Benocs/core
 def getmodels(self, n):
     ''' Used with XML export; see ConfigurableManager.getmodels()
     '''
     r = ConfigurableManager.getmodels(self, n)
     # EMANE global params are stored with first EMANE node (if non-default
     # values are configured)
     sorted_ids = sorted(self.configs.keys())
     if None in self.configs and len(sorted_ids) > 1 and \
       n.objid == sorted_ids[1]:
         v = self.configs[None]
         for model in v:
             cls = self._modelclsmap[model[0]]
             vals = model[1]
             r.append((cls, vals))
     return r
Esempio n. 22
0
 def getmodels(self, n):
     """
     Used with XML export; see ConfigurableManager.getmodels()
     """
     r = ConfigurableManager.getmodels(self, n)
     # EMANE global params are stored with first EMANE node (if non-default
     # values are configured)
     sorted_ids = sorted(self.configs.keys())
     if None in self.configs and len(
             sorted_ids) > 1 and n.objid == sorted_ids[1]:
         v = self.configs[None]
         for model in v:
             cls = self._modelclsmap[model[0]]
             vals = model[1]
             r.append((cls, vals))
     return r
Esempio n. 23
0
    def test_nodes(self):
        # given
        config_manager = ConfigurableManager()
        test_config = {1: 2}
        node_id = 1
        config_manager.set_configs(test_config)
        config_manager.set_configs(test_config, node_id=node_id)

        # when
        nodes = config_manager.nodes()

        # then
        assert len(nodes) == 1
        assert node_id in nodes
Esempio n. 24
0
 def clearconfig(self, nodenum):
     ''' remove configuration values for a node
     '''
     ConfigurableManager.clearconfig(self, nodenum)
     if 0 in self.configs:
         self.configs.pop(0)
 def __init__(self, session):
     ConfigurableManager.__init__(self, session)
     self.verbose = self.session.getcfgitembool('verbose', False)
     self.default_config = XenDefaultConfig(session, objid=None)
     self.loadconfigfile()
 def clearconfig(self, nodenum):
     ''' remove configuration values for a node
     '''
     ConfigurableManager.clearconfig(self, nodenum)
     if 0 in self.configs:
         self.configs.pop(0)
Esempio n. 27
0
 def __init__(self, session):
     ConfigurableManager.__init__(self, session)
     self.verbose = self.session.getcfgitembool('verbose', False)
     self.default_config = XenDefaultConfig(session, objid=None)
     self.loadconfigfile()
Esempio n. 28
0
 def __init__(self, session):
     ConfigurableManager.__init__(self, session)
     self.reset()
     self.zonemap = {}
     for n, l in utm.ZONE_LETTERS:
         self.zonemap[l] = n
Esempio n. 29
0
 def __init__(self, session):
     ConfigurableManager.__init__(self, session)
     self.reset()
     self.zonemap = {}
     for n, l in utm.ZONE_LETTERS:
         self.zonemap[l] = n
 def __init__(self, session):
     ConfigurableManager.__init__(self, session)
     session.broker.handlers.add(self.handledistributed)
     self.reset()
Esempio n. 31
0
 def __init__(self, session):
     ConfigurableManager.__init__(self, session)
     session.broker.handlers += (self.handledistributed, )
     self.reset()