added platform config to emane models, to replace global config, moved core specific emane global configs to session options

This commit is contained in:
Blake Harnden 2021-05-18 21:29:38 -07:00
parent e2a9f6b1f4
commit 071023b1d9
4 changed files with 81 additions and 13 deletions

View file

@ -16,6 +16,8 @@ from core.nodes.interface import CoreInterface
from core.xml import emanexml
logger = logging.getLogger(__name__)
DEFAULT_DEV: str = "ctrl0"
MANIFEST_PATH: str = "share/emane/manifest"
class EmaneModel(WirelessModel):
@ -25,6 +27,16 @@ class EmaneModel(WirelessModel):
configurable parameters. Helper functions also live here.
"""
# default platform configuration settings
platform_xml: str = "nemmanager.xml"
platform_defaults: Dict[str, str] = {
"eventservicedevice": DEFAULT_DEV,
"eventservicegroup": "224.1.2.8:45703",
"otamanagerdevice": DEFAULT_DEV,
"otamanagergroup": "224.1.2.8:45702",
}
platform_config: List[Configuration] = []
# default mac configuration settings
mac_library: Optional[str] = None
mac_xml: Optional[str] = None
@ -57,20 +69,27 @@ class EmaneModel(WirelessModel):
@classmethod
def load(cls, emane_prefix: Path) -> None:
"""
Called after being loaded within the EmaneManager. Provides configured emane_prefix for
parsing xml files.
Called after being loaded within the EmaneManager. Provides configured
emane_prefix for parsing xml files.
:param emane_prefix: configured emane prefix path
:return: nothing
"""
manifest_path = "share/emane/manifest"
cls._load_platform_config(emane_prefix)
# load mac configuration
mac_xml_path = emane_prefix / manifest_path / cls.mac_xml
mac_xml_path = emane_prefix / MANIFEST_PATH / cls.mac_xml
cls.mac_config = emanemanifest.parse(mac_xml_path, cls.mac_defaults)
# load phy configuration
phy_xml_path = emane_prefix / manifest_path / cls.phy_xml
phy_xml_path = emane_prefix / MANIFEST_PATH / cls.phy_xml
cls.phy_config = emanemanifest.parse(phy_xml_path, cls.phy_defaults)
@classmethod
def _load_platform_config(cls, emane_prefix: Path) -> None:
platform_xml_path = emane_prefix / MANIFEST_PATH / cls.platform_xml
cls.platform_config = emanemanifest.parse(
platform_xml_path, cls.platform_defaults
)
@classmethod
def configurations(cls) -> List[Configuration]:
"""
@ -78,7 +97,9 @@ class EmaneModel(WirelessModel):
:return: all configurations
"""
return cls.mac_config + cls.phy_config + cls.external_config
return (
cls.platform_config + cls.mac_config + cls.phy_config + cls.external_config
)
@classmethod
def config_groups(cls) -> List[ConfigGroup]:
@ -87,11 +108,13 @@ class EmaneModel(WirelessModel):
:return: list of configuration groups.
"""
mac_len = len(cls.mac_config)
platform_len = len(cls.platform_config)
mac_len = len(cls.mac_config) + platform_len
phy_len = len(cls.phy_config) + mac_len
config_len = len(cls.configurations())
return [
ConfigGroup("MAC Parameters", 1, mac_len),
ConfigGroup("Platform Parameters", 1, platform_len),
ConfigGroup("MAC Parameters", platform_len + 1, mac_len),
ConfigGroup("PHY Parameters", mac_len + 1, phy_len),
ConfigGroup("External Parameters", phy_len + 1, config_len),
]

View file

@ -1,6 +1,7 @@
"""
EMANE Bypass model for CORE
"""
from pathlib import Path
from typing import List, Set
from core.config import Configuration
@ -30,6 +31,5 @@ class EmaneBypassModel(emanemodel.EmaneModel):
phy_config: List[Configuration] = []
@classmethod
def load(cls, emane_prefix: str) -> None:
# ignore default logic
pass
def load(cls, emane_prefix: Path) -> None:
cls._load_platform_config(emane_prefix)

View file

@ -51,16 +51,25 @@ class EmaneCommEffectModel(emanemodel.EmaneModel):
@classmethod
def load(cls, emane_prefix: Path) -> None:
cls._load_platform_config(emane_prefix)
shim_xml_path = emane_prefix / "share/emane/manifest" / cls.shim_xml
cls.config_shim = emanemanifest.parse(shim_xml_path, cls.shim_defaults)
@classmethod
def configurations(cls) -> List[Configuration]:
return cls.config_shim
return cls.platform_config + cls.config_shim
@classmethod
def config_groups(cls) -> List[ConfigGroup]:
return [ConfigGroup("CommEffect SHIM Parameters", 1, len(cls.configurations()))]
platform_len = len(cls.platform_config)
return [
ConfigGroup("Platform Parameters", 1, platform_len),
ConfigGroup(
"CommEffect SHIM Parameters",
platform_len + 1,
len(cls.configurations()),
),
]
def build_xml_files(self, config: Dict[str, str], iface: CoreInterface) -> None:
"""

View file

@ -59,6 +59,42 @@ class SessionConfig(ConfigurableManager, ConfigurableOptions):
Configuration(
id="ovs", type=ConfigDataTypes.BOOL, default="0", label="Enable OVS"
),
Configuration(
id="platform_id_start",
type=ConfigDataTypes.INT32,
default="1",
label="EMANE Platform ID Start",
),
Configuration(
id="nem_id_start",
type=ConfigDataTypes.INT32,
default="1",
label="EMANE NEM ID Start",
),
Configuration(
id="link_enabled",
type=ConfigDataTypes.BOOL,
default="1",
label="EMANE Links?",
),
Configuration(
id="loss_threshold",
type=ConfigDataTypes.INT32,
default="30",
label="EMANE Link Loss Threshold (%)",
),
Configuration(
id="link_interval",
type=ConfigDataTypes.INT32,
default="1",
label="EMANE Link Check Interval (sec)",
),
Configuration(
id="link_timeout",
type=ConfigDataTypes.INT32,
default="4",
label="EMANE Link Timeout (sec)",
),
]
config_type: RegisterTlvs = RegisterTlvs.UTILITY