docs: updated example custom emane model to use type hinting and embedded it into the emane documentation page, daemon: adjustment to correct rj45 not being provided an iface id when deleting a link from core tlv

This commit is contained in:
Blake Harnden 2020-10-11 12:06:35 -07:00
parent 90d2d5f0dc
commit 96dddb687d
3 changed files with 88 additions and 21 deletions

View file

@ -52,6 +52,7 @@ from core.errors import CoreCommandError, CoreError
from core.location.mobility import BasicRangeModel from core.location.mobility import BasicRangeModel
from core.nodes.base import CoreNode, CoreNodeBase, NodeBase from core.nodes.base import CoreNode, CoreNodeBase, NodeBase
from core.nodes.network import WlanNode from core.nodes.network import WlanNode
from core.nodes.physical import Rj45Node
from core.services.coreservices import ServiceManager, ServiceShim from core.services.coreservices import ServiceManager, ServiceShim
@ -801,6 +802,12 @@ class CoreHandler(socketserver.BaseRequestHandler):
node1_id, node2_id, iface1_data, iface2_data, options, link_type node1_id, node2_id, iface1_data, iface2_data, options, link_type
) )
elif message.flags & MessageFlags.DELETE.value: elif message.flags & MessageFlags.DELETE.value:
node1 = self.session.get_node(node1_id, NodeBase)
node2 = self.session.get_node(node2_id, NodeBase)
if isinstance(node1, Rj45Node):
iface1_data.id = node1.iface_id
if isinstance(node2, Rj45Node):
iface2_data.id = node2.iface_id
self.session.delete_link( self.session.delete_link(
node1_id, node2_id, iface1_data.id, iface2_data.id, link_type node1_id, node2_id, iface1_data.id, iface2_data.id, link_type
) )

View file

@ -1,7 +1,9 @@
""" """
Example custom emane model. Example custom emane model.
""" """
from typing import Dict, List, Optional, Set
from core.config import Configuration
from core.emane import emanemanifest, emanemodel from core.emane import emanemanifest, emanemodel
@ -9,41 +11,45 @@ class ExampleModel(emanemodel.EmaneModel):
""" """
Custom emane model. Custom emane model.
:var str name: defines the emane model name that will show up in the GUI :cvar name: defines the emane model name that will show up in the GUI
Mac Definition: Mac Definition:
:var str mac_library: defines that mac library that the model will reference :cvar mac_library: defines that mac library that the model will reference
:var str mac_xml: defines the mac manifest file that will be parsed to obtain configuration options, :cvar mac_xml: defines the mac manifest file that will be parsed to obtain configuration options,
that will be displayed within the GUI that will be displayed within the GUI
:var dict mac_mac_defaults: allows you to override options that are maintained within the manifest file above :cvar mac_defaults: allows you to override options that are maintained within the manifest file above
:var list mac_mac_config: parses the manifest file and converts configurations into core supported formats :cvar mac_config: parses the manifest file and converts configurations into core supported formats
Phy Definition: Phy Definition:
NOTE: phy configuration will default to the universal model as seen below and the below section does not NOTE: phy configuration will default to the universal model as seen below and the below section does not
have to be included have to be included
:var str phy_library: defines that phy library that the model will reference, used if you need to :cvar phy_library: defines that phy library that the model will reference, used if you need to
provide a custom phy provide a custom phy
:var str phy_xml: defines the phy manifest file that will be parsed to obtain configuration options, :cvar phy_xml: defines the phy manifest file that will be parsed to obtain configuration options,
that will be displayed within the GUI that will be displayed within the GUI
:var dict phy_defaults: allows you to override options that are maintained within the manifest file above :cvar phy_defaults: allows you to override options that are maintained within the manifest file above
or for the default universal model or for the default universal model
:var list phy_config: parses the manifest file and converts configurations into core supported formats :cvar phy_config: parses the manifest file and converts configurations into core supported formats
Custom Override Options: Custom Override Options:
NOTE: these options default to what's seen below and do not have to be included NOTE: these options default to what's seen below and do not have to be included
:var set config_ignore: allows you to ignore options within phy/mac, used typically if you needed to add :cvar config_ignore: allows you to ignore options within phy/mac, used typically if you needed to add
a custom option for display within the gui a custom option for display within the gui
""" """
name = "emane_example" name: str = "emane_example"
mac_library = "rfpipemaclayer" mac_library: str = "rfpipemaclayer"
mac_xml = "/usr/share/emane/manifest/rfpipemaclayer.xml" mac_xml: str = "/usr/share/emane/manifest/rfpipemaclayer.xml"
mac_defaults = { mac_defaults: Dict[str, str] = {
"pcrcurveuri": "/usr/share/emane/xml/models/mac/rfpipe/rfpipepcr.xml" "pcrcurveuri": "/usr/share/emane/xml/models/mac/rfpipe/rfpipepcr.xml"
} }
mac_config = emanemanifest.parse(mac_xml, mac_defaults) mac_config: List[Configuration] = emanemanifest.parse(mac_xml, mac_defaults)
phy_library = None phy_library: Optional[str] = None
phy_xml = "/usr/share/emane/manifest/emanephy.xml" phy_xml: str = "/usr/share/emane/manifest/emanephy.xml"
phy_defaults = {"subid": "1", "propagationmodel": "2ray", "noisemode": "none"} phy_defaults: Dict[str, str] = {
phy_config = emanemanifest.parse(phy_xml, phy_defaults) "subid": "1",
config_ignore = set() "propagationmodel": "2ray",
"noisemode": "none",
}
phy_config: List[Configuration] = emanemanifest.parse(phy_xml, phy_defaults)
config_ignore: Set[str] = set()

View file

@ -116,7 +116,61 @@ placed within the path defined by **emane_models_dir** in the CORE
configuration file. This path cannot end in **/emane**. configuration file. This path cannot end in **/emane**.
Here is an example model with documentation describing functionality: Here is an example model with documentation describing functionality:
[Example Model](../daemon/examples/myemane/examplemodel.py) ```python
"""
Example custom emane model.
"""
from typing import Dict, List, Optional, Set
from core.config import Configuration
from core.emane import emanemanifest, emanemodel
class ExampleModel(emanemodel.EmaneModel):
"""
Custom emane model.
:cvar name: defines the emane model name that will show up in the GUI
Mac Definition:
:cvar mac_library: defines that mac library that the model will reference
:cvar mac_xml: defines the mac manifest file that will be parsed to obtain configuration options,
that will be displayed within the GUI
:cvar mac_defaults: allows you to override options that are maintained within the manifest file above
:cvar mac_config: parses the manifest file and converts configurations into core supported formats
Phy Definition:
NOTE: phy configuration will default to the universal model as seen below and the below section does not
have to be included
:cvar phy_library: defines that phy library that the model will reference, used if you need to
provide a custom phy
:cvar phy_xml: defines the phy manifest file that will be parsed to obtain configuration options,
that will be displayed within the GUI
:cvar phy_defaults: allows you to override options that are maintained within the manifest file above
or for the default universal model
:cvar phy_config: parses the manifest file and converts configurations into core supported formats
Custom Override Options:
NOTE: these options default to what's seen below and do not have to be included
:cvar config_ignore: allows you to ignore options within phy/mac, used typically if you needed to add
a custom option for display within the gui
"""
name: str = "emane_example"
mac_library: str = "rfpipemaclayer"
mac_xml: str = "/usr/share/emane/manifest/rfpipemaclayer.xml"
mac_defaults: Dict[str, str] = {
"pcrcurveuri": "/usr/share/emane/xml/models/mac/rfpipe/rfpipepcr.xml"
}
mac_config: List[Configuration] = emanemanifest.parse(mac_xml, mac_defaults)
phy_library: Optional[str] = None
phy_xml: str = "/usr/share/emane/manifest/emanephy.xml"
phy_defaults: Dict[str, str] = {
"subid": "1", "propagationmodel": "2ray", "noisemode": "none"
}
phy_config: List[Configuration] = emanemanifest.parse(phy_xml, phy_defaults)
config_ignore: Set[str] = set()
```
## Single PC with EMANE ## Single PC with EMANE