updates to allow configuration of installed emane_prefix for default models, requires small tweaks to custom models
This commit is contained in:
parent
2825ce423b
commit
6672fd0f7a
10 changed files with 98 additions and 34 deletions
|
@ -29,6 +29,11 @@ class EmaneBypassModel(emanemodel.EmaneModel):
|
|||
phy_library = "bypassphylayer"
|
||||
phy_config = []
|
||||
|
||||
@classmethod
|
||||
def load(cls, emane_prefix):
|
||||
# ignore default logic
|
||||
pass
|
||||
|
||||
# override config groups
|
||||
@classmethod
|
||||
def config_groups(cls):
|
||||
|
|
|
@ -37,13 +37,18 @@ class EmaneCommEffectModel(emanemodel.EmaneModel):
|
|||
name = "emane_commeffect"
|
||||
|
||||
shim_library = "commeffectshim"
|
||||
shim_xml = "/usr/share/emane/manifest/commeffectshim.xml"
|
||||
shim_xml = "commeffectshim.xml"
|
||||
shim_defaults = {}
|
||||
config_shim = emanemanifest.parse(shim_xml, shim_defaults)
|
||||
config_shim = []
|
||||
|
||||
# comm effect does not need the default phy and external configurations
|
||||
phy_config = ()
|
||||
external_config = ()
|
||||
phy_config = []
|
||||
external_config = []
|
||||
|
||||
@classmethod
|
||||
def load(cls, emane_prefix):
|
||||
shim_xml_path = os.path.join(emane_prefix, "share/emane/manifest", cls.shim_xml)
|
||||
cls.config_shim = emanemanifest.parse(shim_xml_path, cls.shim_defaults)
|
||||
|
||||
@classmethod
|
||||
def configurations(cls):
|
||||
|
|
|
@ -51,6 +51,7 @@ EMANE_MODELS = [
|
|||
EmaneBypassModel,
|
||||
EmaneTdmaModel
|
||||
]
|
||||
DEFAULT_EMANE_PREFIX = "/usr"
|
||||
|
||||
|
||||
class EmaneManager(ModelManager):
|
||||
|
@ -212,6 +213,8 @@ class EmaneManager(ModelManager):
|
|||
"""
|
||||
for emane_model in emane_models:
|
||||
logging.info("loading emane model: %s", emane_model.__name__)
|
||||
emane_prefix = self.session.options.get_config("emane_prefix", default=DEFAULT_EMANE_PREFIX)
|
||||
emane_model.load(emane_prefix)
|
||||
self.models[emane_model.name] = emane_model
|
||||
|
||||
def add_node(self, emane_node):
|
||||
|
|
|
@ -26,13 +26,13 @@ class EmaneModel(WirelessModel):
|
|||
|
||||
# default phy configuration settings, using the universal model
|
||||
phy_library = None
|
||||
phy_xml = "/usr/share/emane/manifest/emanephy.xml"
|
||||
phy_xml = "emanephy.xml"
|
||||
phy_defaults = {
|
||||
"subid": "1",
|
||||
"propagationmodel": "2ray",
|
||||
"noisemode": "none"
|
||||
}
|
||||
phy_config = emanemanifest.parse(phy_xml, phy_defaults)
|
||||
phy_config = []
|
||||
|
||||
# support for external configurations
|
||||
external_config = [
|
||||
|
@ -43,12 +43,42 @@ class EmaneModel(WirelessModel):
|
|||
|
||||
config_ignore = set()
|
||||
|
||||
@classmethod
|
||||
def load(cls, emane_prefix):
|
||||
"""
|
||||
Called after being loaded within the EmaneManager. Provides configured emane_prefix for
|
||||
parsing xml files.
|
||||
|
||||
:param str emane_prefix: configured emane prefix path
|
||||
:return: nothing
|
||||
"""
|
||||
manifest_path = "share/emane/manifest"
|
||||
# load mac configuration
|
||||
mac_xml_path = os.path.join(emane_prefix, manifest_path, cls.mac_xml)
|
||||
cls.mac_config = emanemanifest.parse(mac_xml_path, cls.mac_defaults)
|
||||
|
||||
# load phy configuration
|
||||
phy_xml_path = os.path.join(emane_prefix, manifest_path, cls.phy_xml)
|
||||
cls.phy_config = emanemanifest.parse(phy_xml_path, cls.phy_defaults)
|
||||
|
||||
@classmethod
|
||||
def configurations(cls):
|
||||
"""
|
||||
Returns the combination all all configurations (mac, phy, and external).
|
||||
|
||||
:return: all configurations
|
||||
:rtype: list[Configuration]
|
||||
"""
|
||||
return cls.mac_config + cls.phy_config + cls.external_config
|
||||
|
||||
@classmethod
|
||||
def config_groups(cls):
|
||||
"""
|
||||
Returns the defined configuration groups.
|
||||
|
||||
:return: list of configuration groups.
|
||||
:rtype: list[ConfigGroup]
|
||||
"""
|
||||
mac_len = len(cls.mac_config)
|
||||
phy_len = len(cls.phy_config) + mac_len
|
||||
config_len = len(cls.configurations())
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
"""
|
||||
ieee80211abg.py: EMANE IEEE 802.11abg model for CORE
|
||||
"""
|
||||
import os
|
||||
|
||||
from core.emane import emanemanifest
|
||||
from core.emane import emanemodel
|
||||
|
||||
|
||||
|
@ -12,8 +12,12 @@ class EmaneIeee80211abgModel(emanemodel.EmaneModel):
|
|||
|
||||
# mac configuration
|
||||
mac_library = "ieee80211abgmaclayer"
|
||||
mac_xml = "/usr/share/emane/manifest/ieee80211abgmaclayer.xml"
|
||||
mac_defaults = {
|
||||
"pcrcurveuri": "/usr/share/emane/xml/models/mac/ieee80211abg/ieee80211pcr.xml",
|
||||
}
|
||||
mac_config = emanemanifest.parse(mac_xml, mac_defaults)
|
||||
mac_xml = "ieee80211abgmaclayer.xml"
|
||||
|
||||
@classmethod
|
||||
def load(cls, emane_prefix):
|
||||
cls.mac_defaults["pcrcurveuri"] = os.path.join(
|
||||
emane_prefix,
|
||||
"share/emane/xml/models/mac/ieee80211abg/ieee80211pcr.xml"
|
||||
)
|
||||
super(EmaneIeee80211abgModel, cls).load(emane_prefix)
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
"""
|
||||
rfpipe.py: EMANE RF-PIPE model for CORE
|
||||
"""
|
||||
import os
|
||||
|
||||
from core.emane import emanemanifest
|
||||
from core.emane import emanemodel
|
||||
|
||||
|
||||
|
@ -12,8 +12,12 @@ class EmaneRfPipeModel(emanemodel.EmaneModel):
|
|||
|
||||
# mac configuration
|
||||
mac_library = "rfpipemaclayer"
|
||||
mac_xml = "/usr/share/emane/manifest/rfpipemaclayer.xml"
|
||||
mac_defaults = {
|
||||
"pcrcurveuri": "/usr/share/emane/xml/models/mac/rfpipe/rfpipepcr.xml",
|
||||
}
|
||||
mac_config = emanemanifest.parse(mac_xml, mac_defaults)
|
||||
mac_xml = "rfpipemaclayer.xml"
|
||||
|
||||
@classmethod
|
||||
def load(cls, emane_prefix):
|
||||
cls.mac_defaults["pcrcurveuri"] = os.path.join(
|
||||
emane_prefix,
|
||||
"share/emane/xml/models/mac/rfpipe/rfpipepcr.xml"
|
||||
)
|
||||
super(EmaneRfPipeModel, cls).load(emane_prefix)
|
||||
|
|
|
@ -7,7 +7,6 @@ import os
|
|||
|
||||
from core import constants
|
||||
from core.conf import Configuration
|
||||
from core.emane import emanemanifest
|
||||
from core.emane import emanemodel
|
||||
from core.enumerations import ConfigDataTypes
|
||||
from core.misc import utils
|
||||
|
@ -19,26 +18,30 @@ class EmaneTdmaModel(emanemodel.EmaneModel):
|
|||
|
||||
# mac configuration
|
||||
mac_library = "tdmaeventschedulerradiomodel"
|
||||
mac_xml = "/usr/share/emane/manifest/tdmaeventschedulerradiomodel.xml"
|
||||
mac_defaults = {
|
||||
"pcrcurveuri": "/usr/share/emane/xml/models/mac/tdmaeventscheduler/tdmabasemodelpcr.xml",
|
||||
}
|
||||
mac_config = emanemanifest.parse(mac_xml, mac_defaults)
|
||||
mac_xml = "tdmaeventschedulerradiomodel.xml"
|
||||
|
||||
# add custom schedule options and ignore it when writing emane xml
|
||||
schedule_name = "schedule"
|
||||
default_schedule = os.path.join(constants.CORE_DATA_DIR, "examples", "tdma", "schedule.xml")
|
||||
mac_config.insert(
|
||||
0,
|
||||
Configuration(
|
||||
_id=schedule_name,
|
||||
_type=ConfigDataTypes.STRING,
|
||||
default=default_schedule,
|
||||
label="TDMA schedule file (core)"
|
||||
)
|
||||
)
|
||||
config_ignore = {schedule_name}
|
||||
|
||||
@classmethod
|
||||
def load(cls, emane_prefix):
|
||||
cls.mac_defaults["pcrcurveuri"] = os.path.join(
|
||||
emane_prefix,
|
||||
"share/emane/xml/models/mac/tdmaeventscheduler/tdmabasemodelpcr.xml"
|
||||
)
|
||||
super(EmaneTdmaModel, cls).load(emane_prefix)
|
||||
cls.mac_config.insert(
|
||||
0,
|
||||
Configuration(
|
||||
_id=cls.schedule_name,
|
||||
_type=ConfigDataTypes.STRING,
|
||||
default=cls.default_schedule,
|
||||
label="TDMA schedule file (core)"
|
||||
)
|
||||
)
|
||||
|
||||
def post_startup(self):
|
||||
"""
|
||||
Logic to execute after the emane manager is finished with startup.
|
||||
|
|
|
@ -55,3 +55,5 @@ emane_event_monitor = False
|
|||
# EMANE log level range [0,4] default: 2
|
||||
#emane_log_level = 2
|
||||
emane_realtime = True
|
||||
# prefix used for emane installation
|
||||
# emane_prefix = /usr
|
||||
|
|
|
@ -224,7 +224,7 @@ def grpc_server():
|
|||
@pytest.fixture
|
||||
def session():
|
||||
# use coreemu and create a session
|
||||
coreemu = CoreEmu()
|
||||
coreemu = CoreEmu(config={"emane_prefix": "/usr"})
|
||||
session_fixture = coreemu.create_session()
|
||||
session_fixture.set_state(EventTypes.CONFIGURATION_STATE)
|
||||
assert os.path.exists(session_fixture.session_dir)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
"""
|
||||
Unit tests for testing CORE EMANE networks.
|
||||
"""
|
||||
import os
|
||||
|
||||
import pytest
|
||||
|
||||
|
@ -19,6 +20,7 @@ _EMANE_MODELS = [
|
|||
EmaneCommEffectModel,
|
||||
EmaneTdmaModel,
|
||||
]
|
||||
_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
|
||||
class TestEmane:
|
||||
|
@ -39,6 +41,12 @@ class TestEmane:
|
|||
)
|
||||
emane_network.setposition(x=80, y=50)
|
||||
|
||||
# configure tdma
|
||||
if model == EmaneTdmaModel:
|
||||
session.emane.set_model_config(emane_network.objid, EmaneTdmaModel.name, {
|
||||
"schedule": os.path.join(_DIR, "../examples/tdma/schedule.xml")
|
||||
})
|
||||
|
||||
# create nodes
|
||||
node_options = NodeOptions()
|
||||
node_options.set_position(150, 150)
|
||||
|
|
Loading…
Reference in a new issue