updates to get all tests working with config changes
This commit is contained in:
parent
e4aaebfefb
commit
7abf4bca16
7 changed files with 29 additions and 27 deletions
|
@ -140,6 +140,7 @@ class NewConfigurableManager(object):
|
||||||
return [node_id for node_id in self._configuration_maps.iterkeys() if node_id != self._default_node]
|
return [node_id for node_id in self._configuration_maps.iterkeys() if node_id != self._default_node]
|
||||||
|
|
||||||
def config_reset(self, node_id=None):
|
def config_reset(self, node_id=None):
|
||||||
|
logger.debug("resetting all configurations: %s", self.__class__.__name__)
|
||||||
if not node_id:
|
if not node_id:
|
||||||
self._configuration_maps.clear()
|
self._configuration_maps.clear()
|
||||||
elif node_id in self._configuration_maps:
|
elif node_id in self._configuration_maps:
|
||||||
|
@ -152,9 +153,8 @@ class NewConfigurableManager(object):
|
||||||
|
|
||||||
def set_configs(self, config, node_id=_default_node, config_type=_default_type):
|
def set_configs(self, config, node_id=_default_node, config_type=_default_type):
|
||||||
logger.debug("setting config for node(%s) type(%s): %s", node_id, config_type, config)
|
logger.debug("setting config for node(%s) type(%s): %s", node_id, config_type, config)
|
||||||
node_type_map = self.get_configs(node_id, config_type)
|
node_configs = self.get_config_types(node_id)
|
||||||
node_type_map.clear()
|
node_configs[config_type] = config
|
||||||
node_type_map.update(config)
|
|
||||||
|
|
||||||
def get_config(self, _id, node_id=_default_node, config_type=_default_type):
|
def get_config(self, _id, node_id=_default_node, config_type=_default_type):
|
||||||
logger.debug("getting config for node(%s) type(%s): %s", node_id, config_type, _id)
|
logger.debug("getting config for node(%s) type(%s): %s", node_id, config_type, _id)
|
||||||
|
@ -163,8 +163,9 @@ class NewConfigurableManager(object):
|
||||||
|
|
||||||
def get_configs(self, node_id=_default_node, config_type=_default_type):
|
def get_configs(self, node_id=_default_node, config_type=_default_type):
|
||||||
logger.debug("getting configs for node(%s) type(%s)", node_id, config_type)
|
logger.debug("getting configs for node(%s) type(%s)", node_id, config_type)
|
||||||
node_map = self._configuration_maps.setdefault(node_id, {})
|
node_map = self.get_config_types(node_id)
|
||||||
return node_map.setdefault(config_type, {})
|
return node_map.setdefault(config_type, {})
|
||||||
|
|
||||||
def get_config_types(self, node_id=_default_node):
|
def get_config_types(self, node_id=_default_node):
|
||||||
return self._configuration_maps.get(node_id, {})
|
logger.debug("getting all configs for node(%s)", node_id)
|
||||||
|
return self._configuration_maps.setdefault(node_id, {})
|
||||||
|
|
|
@ -47,7 +47,7 @@ class EmaneTdmaModel(emanemodel.EmaneModel):
|
||||||
:return: nothing
|
:return: nothing
|
||||||
"""
|
"""
|
||||||
# get configured schedule
|
# get configured schedule
|
||||||
config = emane_manager.get_configs()
|
config = emane_manager.get_configs(self.object_id, self.name)
|
||||||
if not config:
|
if not config:
|
||||||
return
|
return
|
||||||
schedule = config[self.schedule_name]
|
schedule = config[self.schedule_name]
|
||||||
|
|
|
@ -812,8 +812,8 @@ class EmuSession(Session):
|
||||||
:param emane_model: emane model to set
|
:param emane_model: emane model to set
|
||||||
:return: nothing
|
:return: nothing
|
||||||
"""
|
"""
|
||||||
values = list(emane_model.getdefaultvalues())
|
config = emane_model.default_values()
|
||||||
self.emane.setconfig(emane_node.objid, emane_model.name, values)
|
self.emane.set_configs(config, emane_node.objid, emane_model.name)
|
||||||
|
|
||||||
def set_wireless_model(self, node, model):
|
def set_wireless_model(self, node, model):
|
||||||
"""
|
"""
|
||||||
|
@ -823,8 +823,8 @@ class EmuSession(Session):
|
||||||
:param core.mobility.WirelessModel model: wireless model to set node to
|
:param core.mobility.WirelessModel model: wireless model to set node to
|
||||||
:return: nothing
|
:return: nothing
|
||||||
"""
|
"""
|
||||||
values = list(model.getdefaultvalues())
|
config = model.default_values()
|
||||||
node.setmodel(model, values)
|
node.setmodel(model, config)
|
||||||
|
|
||||||
def wireless_link_all(self, network, nodes):
|
def wireless_link_all(self, network, nodes):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -104,11 +104,11 @@ class MobilityManager(NewConfigurableManager):
|
||||||
for model_name in node_configs.iterkeys():
|
for model_name in node_configs.iterkeys():
|
||||||
try:
|
try:
|
||||||
clazz = self._modelclsmap[model_name]
|
clazz = self._modelclsmap[model_name]
|
||||||
model_config = self.get_config(node_id, model_name)
|
model_config = self.get_configs(node_id, model_name)
|
||||||
logger.info("setting mobility model(%s) to node: %s", model_name, model_config)
|
logger.info("setting mobility model(%s) to node: %s", model_name, model_config)
|
||||||
node.setmodel(clazz, model_config)
|
node.setmodel(clazz, model_config)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
logger.warn("skipping mobility configuration for unknown model: %s", model_name)
|
logger.error("skipping mobility configuration for unknown model: %s", model_name)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if self.session.master:
|
if self.session.master:
|
||||||
|
@ -145,7 +145,6 @@ class MobilityManager(NewConfigurableManager):
|
||||||
if self.session.state == EventTypes.RUNTIME_STATE.value:
|
if self.session.state == EventTypes.RUNTIME_STATE.value:
|
||||||
try:
|
try:
|
||||||
node = self.session.get_object(node_id)
|
node = self.session.get_object(node_id)
|
||||||
# TODO: this need to be updated
|
|
||||||
node.updatemodel(config_type, config)
|
node.updatemodel(config_type, config)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
logger.exception("skipping mobility configuration for unknown node %s", node_id)
|
logger.exception("skipping mobility configuration for unknown node %s", node_id)
|
||||||
|
@ -409,10 +408,10 @@ class BasicRangeModel(WirelessModel):
|
||||||
self.wlan = session.get_object(object_id)
|
self.wlan = session.get_object(object_id)
|
||||||
self._netifs = {}
|
self._netifs = {}
|
||||||
self._netifslock = threading.Lock()
|
self._netifslock = threading.Lock()
|
||||||
if not values:
|
|
||||||
values = self.default_values()
|
|
||||||
|
|
||||||
# TODO: can this be handled in a better spot
|
# TODO: can this be handled in a better spot
|
||||||
|
if not values:
|
||||||
|
values = self.default_values()
|
||||||
self.session.mobility.set_configs(values, node_id=object_id, config_type=self.name)
|
self.session.mobility.set_configs(values, node_id=object_id, config_type=self.name)
|
||||||
|
|
||||||
self.range = None
|
self.range = None
|
||||||
|
|
|
@ -382,7 +382,7 @@ class WlanNode(LxBrNet):
|
||||||
Sets the mobility and wireless model.
|
Sets the mobility and wireless model.
|
||||||
|
|
||||||
:param core.mobility.WirelessModel.cls model: wireless model to set to
|
:param core.mobility.WirelessModel.cls model: wireless model to set to
|
||||||
:param config: model configuration
|
:param dict config: model configuration
|
||||||
:return: nothing
|
:return: nothing
|
||||||
"""
|
"""
|
||||||
logger.info("adding model: %s", model.name)
|
logger.info("adding model: %s", model.name)
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"level": "INFO",
|
"level": "DEBUG",
|
||||||
"handlers": ["console"]
|
"handlers": ["console"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,10 +10,10 @@ from xml.etree import ElementTree
|
||||||
import pytest
|
import pytest
|
||||||
from mock import MagicMock
|
from mock import MagicMock
|
||||||
|
|
||||||
from core.data import ConfigData
|
|
||||||
from core.emulator.emudata import NodeOptions
|
from core.emulator.emudata import NodeOptions
|
||||||
from core.enumerations import MessageFlags, NodeTypes
|
from core.enumerations import MessageFlags, NodeTypes
|
||||||
from core.mobility import BasicRangeModel
|
from core.mobility import BasicRangeModel
|
||||||
|
from core.mobility import Ns2ScriptedMobility
|
||||||
from core.netns.vnodeclient import VnodeClient
|
from core.netns.vnodeclient import VnodeClient
|
||||||
from core.service import ServiceManager
|
from core.service import ServiceManager
|
||||||
|
|
||||||
|
@ -306,15 +306,17 @@ class TestCore:
|
||||||
session.wireless_link_all(wlan_node, [node_one, node_two])
|
session.wireless_link_all(wlan_node, [node_one, node_two])
|
||||||
|
|
||||||
# configure mobility script for session
|
# configure mobility script for session
|
||||||
config = ConfigData(
|
config = {
|
||||||
node=wlan_node.objid,
|
"file": _MOBILITY_FILE,
|
||||||
object="ns2script",
|
"refresh_ms": "50",
|
||||||
type=0,
|
"loop": "1",
|
||||||
data_types=(10, 3, 11, 10, 10, 10, 10, 10, 0),
|
"autostart": "0.0",
|
||||||
data_values="file=%s|refresh_ms=50|loop=1|autostart=0.0|"
|
"map": "",
|
||||||
"map=|script_start=|script_pause=|script_stop=" % _MOBILITY_FILE
|
"script_start": "",
|
||||||
)
|
"script_pause": "",
|
||||||
session.config_object(config)
|
"script_stop": "",
|
||||||
|
}
|
||||||
|
session.mobility.set_configs(config, wlan_node.objid, Ns2ScriptedMobility.name)
|
||||||
|
|
||||||
# add handler for receiving node updates
|
# add handler for receiving node updates
|
||||||
event = threading.Event()
|
event = threading.Event()
|
||||||
|
|
Loading…
Reference in a new issue