changes to fix emane config data leveraging emane prefix to work as intended

This commit is contained in:
Blake Harnden 2019-12-20 13:30:55 -08:00
parent 09756eb7ab
commit d4fae0d89e

View file

@ -5,6 +5,7 @@ emane.py: definition of an Emane class for implementing configuration control of
import logging import logging
import os import os
import threading import threading
from collections import OrderedDict
from core import utils from core import utils
from core.config import ConfigGroup, Configuration, ModelManager from core.config import ConfigGroup, Configuration, ModelManager
@ -40,6 +41,7 @@ EMANE_MODELS = [
EmaneTdmaModel, EmaneTdmaModel,
] ]
DEFAULT_EMANE_PREFIX = "/usr" DEFAULT_EMANE_PREFIX = "/usr"
DEFAULT_DEV = "ctrl0"
class EmaneManager(ModelManager): class EmaneManager(ModelManager):
@ -817,57 +819,61 @@ class EmaneManager(ModelManager):
return result return result
class EmaneGlobalModel(EmaneModel): class EmaneGlobalModel:
""" """
Global EMANE configuration options. Global EMANE configuration options.
""" """
_DEFAULT_DEV = "ctrl0"
name = "emane" name = "emane"
bitmap = None
emulator_xml = "/usr/share/emane/manifest/nemmanager.xml" def __init__(self, session):
emulator_defaults = { self.session = session
"eventservicedevice": _DEFAULT_DEV, self.nem_config = [
"eventservicegroup": "224.1.2.8:45703", Configuration(
"otamanagerdevice": _DEFAULT_DEV, _id="nem_id_start",
"otamanagergroup": "224.1.2.8:45702", _type=ConfigDataTypes.INT32,
} default="1",
emulator_config = emanemanifest.parse(emulator_xml, emulator_defaults) label="Starting NEM ID (core)",
emulator_config.insert( )
0, ]
Configuration( self.emulator_config = None
_id="platform_id_start", self.parse_config()
_type=ConfigDataTypes.INT32,
default="1",
label="Starting Platform ID (core)",
),
)
nem_config = [ def parse_config(self):
Configuration( emane_prefix = self.session.options.get_config(
_id="nem_id_start", "emane_prefix", default=DEFAULT_EMANE_PREFIX
_type=ConfigDataTypes.INT32, )
default="1", emulator_xml = os.path.join(emane_prefix, "share/emane/manifest/nemmanager.xml")
label="Starting NEM ID (core)", emulator_defaults = {
"eventservicedevice": DEFAULT_DEV,
"eventservicegroup": "224.1.2.8:45703",
"otamanagerdevice": DEFAULT_DEV,
"otamanagergroup": "224.1.2.8:45702",
}
self.emulator_config = emanemanifest.parse(emulator_xml, emulator_defaults)
self.emulator_config.insert(
0,
Configuration(
_id="platform_id_start",
_type=ConfigDataTypes.INT32,
default="1",
label="Starting Platform ID (core)",
),
) )
]
@classmethod def configurations(self):
def configurations(cls): return self.emulator_config + self.nem_config
return cls.emulator_config + cls.nem_config
@classmethod def config_groups(self):
def config_groups(cls): emulator_len = len(self.emulator_config)
emulator_len = len(cls.emulator_config) config_len = len(self.configurations())
config_len = len(cls.configurations())
return [ return [
ConfigGroup("Platform Attributes", 1, emulator_len), ConfigGroup("Platform Attributes", 1, emulator_len),
ConfigGroup("NEM Parameters", emulator_len + 1, config_len), ConfigGroup("NEM Parameters", emulator_len + 1, config_len),
] ]
def __init__(self, session, _id=None): def default_values(self):
super().__init__(session, _id) return OrderedDict(
[(config.id, config.default) for config in self.configurations()]
def build_xml_files(self, config, interface=None): )
raise NotImplementedError