changes to fix emane config data leveraging emane prefix to work as intended
This commit is contained in:
parent
09756eb7ab
commit
d4fae0d89e
1 changed files with 45 additions and 39 deletions
|
@ -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,24 +819,40 @@ 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):
|
||||||
|
self.session = session
|
||||||
|
self.nem_config = [
|
||||||
|
Configuration(
|
||||||
|
_id="nem_id_start",
|
||||||
|
_type=ConfigDataTypes.INT32,
|
||||||
|
default="1",
|
||||||
|
label="Starting NEM ID (core)",
|
||||||
|
)
|
||||||
|
]
|
||||||
|
self.emulator_config = None
|
||||||
|
self.parse_config()
|
||||||
|
|
||||||
|
def parse_config(self):
|
||||||
|
emane_prefix = self.session.options.get_config(
|
||||||
|
"emane_prefix", default=DEFAULT_EMANE_PREFIX
|
||||||
|
)
|
||||||
|
emulator_xml = os.path.join(emane_prefix, "share/emane/manifest/nemmanager.xml")
|
||||||
emulator_defaults = {
|
emulator_defaults = {
|
||||||
"eventservicedevice": _DEFAULT_DEV,
|
"eventservicedevice": DEFAULT_DEV,
|
||||||
"eventservicegroup": "224.1.2.8:45703",
|
"eventservicegroup": "224.1.2.8:45703",
|
||||||
"otamanagerdevice": _DEFAULT_DEV,
|
"otamanagerdevice": DEFAULT_DEV,
|
||||||
"otamanagergroup": "224.1.2.8:45702",
|
"otamanagergroup": "224.1.2.8:45702",
|
||||||
}
|
}
|
||||||
emulator_config = emanemanifest.parse(emulator_xml, emulator_defaults)
|
self.emulator_config = emanemanifest.parse(emulator_xml, emulator_defaults)
|
||||||
emulator_config.insert(
|
self.emulator_config.insert(
|
||||||
0,
|
0,
|
||||||
Configuration(
|
Configuration(
|
||||||
_id="platform_id_start",
|
_id="platform_id_start",
|
||||||
|
@ -844,30 +862,18 @@ class EmaneGlobalModel(EmaneModel):
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
nem_config = [
|
def configurations(self):
|
||||||
Configuration(
|
return self.emulator_config + self.nem_config
|
||||||
_id="nem_id_start",
|
|
||||||
_type=ConfigDataTypes.INT32,
|
|
||||||
default="1",
|
|
||||||
label="Starting NEM ID (core)",
|
|
||||||
)
|
|
||||||
]
|
|
||||||
|
|
||||||
@classmethod
|
def config_groups(self):
|
||||||
def configurations(cls):
|
emulator_len = len(self.emulator_config)
|
||||||
return cls.emulator_config + cls.nem_config
|
config_len = len(self.configurations())
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def config_groups(cls):
|
|
||||||
emulator_len = len(cls.emulator_config)
|
|
||||||
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
|
|
||||||
|
|
Loading…
Reference in a new issue