updates to get all tests working with config changes

This commit is contained in:
Blake J. Harnden 2018-06-07 12:57:32 -07:00
parent e4aaebfefb
commit 7abf4bca16
7 changed files with 29 additions and 27 deletions

View file

@ -140,6 +140,7 @@ class NewConfigurableManager(object):
return [node_id for node_id in self._configuration_maps.iterkeys() if node_id != self._default_node]
def config_reset(self, node_id=None):
logger.debug("resetting all configurations: %s", self.__class__.__name__)
if not node_id:
self._configuration_maps.clear()
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):
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_type_map.clear()
node_type_map.update(config)
node_configs = self.get_config_types(node_id)
node_configs[config_type] = config
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)
@ -163,8 +163,9 @@ class NewConfigurableManager(object):
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)
node_map = self._configuration_maps.setdefault(node_id, {})
node_map = self.get_config_types(node_id)
return node_map.setdefault(config_type, {})
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, {})

View file

@ -47,7 +47,7 @@ class EmaneTdmaModel(emanemodel.EmaneModel):
:return: nothing
"""
# get configured schedule
config = emane_manager.get_configs()
config = emane_manager.get_configs(self.object_id, self.name)
if not config:
return
schedule = config[self.schedule_name]

View file

@ -812,8 +812,8 @@ class EmuSession(Session):
:param emane_model: emane model to set
:return: nothing
"""
values = list(emane_model.getdefaultvalues())
self.emane.setconfig(emane_node.objid, emane_model.name, values)
config = emane_model.default_values()
self.emane.set_configs(config, emane_node.objid, emane_model.name)
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
:return: nothing
"""
values = list(model.getdefaultvalues())
node.setmodel(model, values)
config = model.default_values()
node.setmodel(model, config)
def wireless_link_all(self, network, nodes):
"""

View file

@ -104,11 +104,11 @@ class MobilityManager(NewConfigurableManager):
for model_name in node_configs.iterkeys():
try:
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)
node.setmodel(clazz, model_config)
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
if self.session.master:
@ -145,7 +145,6 @@ class MobilityManager(NewConfigurableManager):
if self.session.state == EventTypes.RUNTIME_STATE.value:
try:
node = self.session.get_object(node_id)
# TODO: this need to be updated
node.updatemodel(config_type, config)
except KeyError:
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._netifs = {}
self._netifslock = threading.Lock()
if not values:
values = self.default_values()
# 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.range = None

View file

@ -382,7 +382,7 @@ class WlanNode(LxBrNet):
Sets the mobility and wireless model.
:param core.mobility.WirelessModel.cls model: wireless model to set to
:param config: model configuration
:param dict config: model configuration
:return: nothing
"""
logger.info("adding model: %s", model.name)

View file

@ -14,7 +14,7 @@
}
},
"root": {
"level": "INFO",
"level": "DEBUG",
"handlers": ["console"]
}
}

View file

@ -10,10 +10,10 @@ from xml.etree import ElementTree
import pytest
from mock import MagicMock
from core.data import ConfigData
from core.emulator.emudata import NodeOptions
from core.enumerations import MessageFlags, NodeTypes
from core.mobility import BasicRangeModel
from core.mobility import Ns2ScriptedMobility
from core.netns.vnodeclient import VnodeClient
from core.service import ServiceManager
@ -306,15 +306,17 @@ class TestCore:
session.wireless_link_all(wlan_node, [node_one, node_two])
# configure mobility script for session
config = ConfigData(
node=wlan_node.objid,
object="ns2script",
type=0,
data_types=(10, 3, 11, 10, 10, 10, 10, 10, 0),
data_values="file=%s|refresh_ms=50|loop=1|autostart=0.0|"
"map=|script_start=|script_pause=|script_stop=" % _MOBILITY_FILE
)
session.config_object(config)
config = {
"file": _MOBILITY_FILE,
"refresh_ms": "50",
"loop": "1",
"autostart": "0.0",
"map": "",
"script_start": "",
"script_pause": "",
"script_stop": "",
}
session.mobility.set_configs(config, wlan_node.objid, Ns2ScriptedMobility.name)
# add handler for receiving node updates
event = threading.Event()