fixed formatting in docs due

This commit is contained in:
Blake Harnden 2020-01-16 16:12:01 -08:00
parent 5490f961a6
commit b8ded52a66
23 changed files with 106 additions and 109 deletions

View file

@ -104,7 +104,7 @@ class EmaneManager(ModelManager):
:param interface: node interface
:param model_name: model to get configuration for
:return: node/interface model configuration
"""
"""
# use the network-wide config values or interface(NEM)-specific values?
if interface is None:
return self.get_configs(node_id=node_id, config_type=model_name)
@ -258,7 +258,7 @@ class EmaneManager(ModelManager):
:return: SUCCESS, NOT_NEEDED, NOT_READY in order to delay session
instantiation
"""
"""
logging.debug("emane setup")
# TODO: drive this from the session object
@ -316,7 +316,7 @@ class EmaneManager(ModelManager):
:return: SUCCESS, NOT_NEEDED, NOT_READY in order to delay session
instantiation
"""
"""
self.reset()
r = self.setup()

View file

@ -36,7 +36,7 @@ def _get_possible(config_type: str, config_regex: str) -> List[str]:
:param config_type: emane configuration type
:param config_regex: emane configuration regex
:return: a string listing comma delimited values, if needed, empty string otherwise
"""
"""
if config_type == "bool":
return ["On", "Off"]
@ -54,8 +54,7 @@ def _get_default(config_type_name: str, config_value: List[str]) -> str:
:param config_type_name: emane configuration type name
:param config_value: emane configuration value list
:return: default core config value
"""
"""
config_default = ""
if config_type_name == "bool":
@ -78,7 +77,7 @@ def parse(manifest_path: str, defaults: Dict[str, str]) -> List[Configuration]:
:param manifest_path: absolute manifest file path
:param defaults: used to override default values for configurations
:return: list of core configuration values
"""
"""
# no results when emane bindings are not present
if not manifest:

View file

@ -70,7 +70,7 @@ class EmaneModel(WirelessModel):
Returns the combination all all configurations (mac, phy, and external).
:return: all configurations
"""
"""
return cls.mac_config + cls.phy_config + cls.external_config
@classmethod
@ -79,7 +79,7 @@ class EmaneModel(WirelessModel):
Returns the defined configuration groups.
:return: list of configuration groups.
"""
"""
mac_len = len(cls.mac_config)
phy_len = len(cls.phy_config) + mac_len
config_len = len(cls.configurations())

View file

@ -91,7 +91,7 @@ class CoreEmu:
:param _id: session id for new session
:param _cls: Session class to use
:return: created session
"""
"""
if not _id:
_id = 1
while _id in self.sessions:
@ -107,7 +107,7 @@ class CoreEmu:
:param _id: session id to delete
:return: True if deleted, False otherwise
"""
"""
logging.info("deleting session: %s", _id)
session = self.sessions.pop(_id, None)
result = False

View file

@ -200,7 +200,7 @@ class DistributedController:
:param server: server to create
tunnel for
:return: local and remote gre taps created for tunnel
"""
"""
host = server.host
key = self.tunnel_key(node.id, netaddr.IPAddress(host).value)
tunnel = self.tunnels.get(key)
@ -237,7 +237,7 @@ class DistributedController:
:param n1_id: node one id
:param n2_id: node two id
:return: tunnel key for the node pair
"""
"""
logging.debug("creating tunnel key for: %s, %s", n1_id, n2_id)
key = (
(self.session.id << 16) ^ utils.hashkey(n1_id) ^ (utils.hashkey(n2_id) << 8)

View file

@ -217,7 +217,7 @@ class InterfaceData:
Returns a list of ip4 and ip6 address when present.
:return: list of addresses
"""
"""
ip4 = self.ip4_address()
ip6 = self.ip6_address()
return [i for i in [ip4, ip6] if i]
@ -252,7 +252,7 @@ class IpPrefixes:
:param node: node to get IP4 address for
:return: IP4 address or None
"""
"""
if not self.ip4:
raise ValueError("ip4 prefixes have not been set")
return str(self.ip4[node.id])
@ -263,7 +263,7 @@ class IpPrefixes:
:param node: node to get IP6 address for
:return: IP4 address or None
"""
"""
if not self.ip6:
raise ValueError("ip6 prefixes have not been set")
return str(self.ip6[node.id])
@ -280,7 +280,7 @@ class IpPrefixes:
:param mac: mac address to use for this interface, default is random
generation
:return: new interface data for the provided node
"""
"""
# interface id
inteface_id = node.newifindex()

View file

@ -199,7 +199,7 @@ class Session:
:param node_one_id: node one id
:param node_two_id: node two id
:return: nodes, network nodes if present, and tunnel if present
"""
"""
logging.debug(
"link message between node1(%s) and node2(%s)", node_one_id, node_two_id
)
@ -1254,7 +1254,7 @@ class Session:
:param state: flag to determine if session state should be included
:return: environment variables
"""
"""
env = os.environ.copy()
env["SESSION"] = str(self.id)
env["SESSION_SHORT"] = self.short_session_id()
@ -1374,7 +1374,7 @@ class Session:
:param _id: id of node to delete
:return: True if node deleted, False otherwise
"""
"""
# delete node and check for session shutdown if a node was removed
logging.info("deleting node(%s)", _id)
node = None
@ -1610,7 +1610,7 @@ class Session:
request flag.
:return: service boot exceptions
"""
"""
with self._nodes_lock:
funcs = []
start = time.monotonic()
@ -1631,7 +1631,7 @@ class Session:
Retrieve control net prefixes.
:return: control net prefix list
"""
"""
p = self.options.get_config("controlnet")
p0 = self.options.get_config("controlnet0")
p1 = self.options.get_config("controlnet1")
@ -1646,7 +1646,7 @@ class Session:
Retrieve control net server interfaces.
:return: list of control net server interfaces
"""
"""
d0 = self.options.get_config("controlnetif0")
if d0:
logging.error("controlnet0 cannot be assigned with a host interface")
@ -1661,7 +1661,7 @@ class Session:
:param dev: device to get control net index for
:return: control net index, -1 otherwise
"""
"""
if dev[0:4] == "ctrl" and int(dev[4]) in [0, 1, 2, 3]:
index = int(dev[4])
if index == 0:
@ -1696,7 +1696,7 @@ class Session:
:param remove: flag to check if it should be removed
:param conf_required: flag to check if conf is required
:return: control net node
"""
"""
logging.debug(
"add/remove control net: index(%s) remove(%s) conf_required(%s)",
net_index,

View file

@ -100,7 +100,7 @@ class CoreLocation:
:param y: y value
:param z: z value
:return: lat, lon, alt values for provided coordinates
"""
"""
# shift (x,y,z) over to reference point (x,y,z)
x -= self.refxyz[0]
y = -(y - self.refxyz[1])
@ -142,7 +142,7 @@ class CoreLocation:
:param lon: longitude
:param alt: altitude
:return: converted x, y, z coordinates
"""
"""
# convert lat/lon to UTM coordinates in meters
e, n, zonen, zonel = utm.from_latlon(lat, lon)
_rlat, _rlon, ralt = self.refgeo
@ -249,7 +249,7 @@ class CoreLocation:
:param e: easting value
:param n: northing value
:return: modified easting, northing, and zone values
"""
"""
zone = self.refutm[0]
rlat, rlon, _ralt = self.refgeo
if e > 834000 or e < 166000:

View file

@ -51,7 +51,7 @@ class Timer(threading.Thread):
the timer was already running.
:return: True if canceled, False otherwise
"""
"""
locked = self._running.acquire(False)
if locked:
self.finished.set()
@ -222,7 +222,7 @@ class EventLoop:
:param args: event arguments
:param kwds: event keyword arguments
:return: created event
"""
"""
with self.lock:
eventnum = self.eventnum
self.eventnum += 1

View file

@ -233,7 +233,7 @@ class WirelessModel(ConfigurableOptions):
:param flags: link data flags
:return: link data
"""
"""
return []
def update(self, moved: bool, moved_netifs: List[CoreInterface]) -> None:
@ -473,7 +473,7 @@ class BasicRangeModel(WirelessModel):
:param p1: point one
:param p2: point two
:return: distance petween the points
"""
"""
a = p1[0] - p2[0]
b = p1[1] - p2[1]
c = 0
@ -502,7 +502,7 @@ class BasicRangeModel(WirelessModel):
:param interface2: interface two
:param message_type: link message type
:return: link data
"""
"""
return LinkData(
message_type=message_type,
node1_id=interface1.node.id,
@ -536,7 +536,7 @@ class BasicRangeModel(WirelessModel):
:param flags: link flags
:return: all link data
"""
"""
all_links = []
with self.wlan._linked_lock:
for a in self.wlan._linked:
@ -690,7 +690,7 @@ class WayPointMobility(WirelessModel):
:param node: node to move
:param dt: move factor
:return: True if node was moved, False otherwise
"""
"""
if node.id not in self.points:
return False
x1, y1, z1 = node.getposition()
@ -1058,7 +1058,7 @@ class Ns2ScriptedMobility(WayPointMobility):
:param file_name: file name to find
:return: absolute path to the file
"""
"""
if os.path.exists(file_name):
return file_name
@ -1103,7 +1103,7 @@ class Ns2ScriptedMobility(WayPointMobility):
:param nodenum: node id to map
:return: mapped value or the node id itself
"""
"""
nodenum = int(nodenum)
return self.nodemap.get(nodenum, nodenum)

View file

@ -123,7 +123,7 @@ class NodeBase:
:param y: y position
:param z: z position
:return: True if position changed, False otherwise
"""
"""
return self.position.set(x=x, y=y, z=z)
def getposition(self) -> Tuple[float, float, float]:
@ -131,7 +131,7 @@ class NodeBase:
Return an (x,y,z) tuple representing this object's position.
:return: x,y,z position tuple
"""
"""
return self.position.get()
def ifname(self, ifindex: int) -> str:
@ -140,7 +140,7 @@ class NodeBase:
:param ifindex: interface index
:return: interface name
"""
"""
return self._netif[ifindex].name
def netifs(self, sort: bool = False) -> List[CoreInterface]:
@ -149,7 +149,7 @@ class NodeBase:
:param sort: boolean used to determine if interfaces should be sorted
:return: network interfaces
"""
"""
if sort:
return [self._netif[x] for x in sorted(self._netif)]
else:
@ -160,7 +160,7 @@ class NodeBase:
Return the attached interface count.
:return: number of network interfaces
"""
"""
return len(self._netif)
def getifindex(self, netif: CoreInterface) -> int:
@ -169,7 +169,7 @@ class NodeBase:
:param netif: interface to get index for
:return: interface index if found, -1 otherwise
"""
"""
for ifindex in self._netif:
if self._netif[ifindex] is netif:
return ifindex
@ -180,7 +180,7 @@ class NodeBase:
Create a new interface index.
:return: interface index
"""
"""
while self.ifindex in self._netif:
self.ifindex += 1
ifindex = self.ifindex
@ -204,7 +204,7 @@ class NodeBase:
:param alt: altitude
:param source: source of node data
:return: node data object
"""
"""
if self.apitype is None:
return None
@ -248,7 +248,7 @@ class NodeBase:
:param flags: message flags
:return: list of link data
"""
"""
return []
@ -338,7 +338,7 @@ class CoreNodeBase(NodeBase):
:param ifindex: index of interface to retrieve
:return: network interface, or None if not found
"""
"""
if ifindex in self._netif:
return self._netif[ifindex]
else:
@ -392,7 +392,7 @@ class CoreNodeBase(NodeBase):
:param obj: object to get common network with
:param want_ctrl: flag set to determine if control network are wanted
:return: tuples of common networks
"""
"""
common = []
for netif1 in self.netifs():
if not want_ctrl and hasattr(netif1, "control"):
@ -487,7 +487,7 @@ class CoreNode(CoreNodeBase):
Check if the node is alive.
:return: True if node is alive, False otherwise
"""
"""
try:
self.host_cmd(f"kill -0 {self.pid}")
except CoreCommandError:
@ -647,7 +647,7 @@ class CoreNode(CoreNodeBase):
Retrieve a new interface index.
:return: new interface index
"""
"""
with self.lock:
return super().newifindex()
@ -715,7 +715,7 @@ class CoreNode(CoreNodeBase):
:param ifindex: interface index
:param ifname: interface name
:return: interface index
"""
"""
with self.lock:
if ifindex is None:
ifindex = self.newifindex()
@ -817,7 +817,7 @@ class CoreNode(CoreNodeBase):
:param ifindex: index of interface to create
:param ifname: name for interface
:return: interface index
"""
"""
if not addrlist:
addrlist = []
@ -984,7 +984,7 @@ class CoreNetworkBase(NodeBase):
:param net: network to link with
:return: created interface
"""
"""
pass
def getlinknetif(self, net: "CoreNetworkBase") -> CoreInterface:
@ -993,7 +993,7 @@ class CoreNetworkBase(NodeBase):
:param net: interface to get link for
:return: interface the provided network is linked to
"""
"""
for netif in self.netifs():
if hasattr(netif, "othernet") and netif.othernet == net:
return netif
@ -1031,7 +1031,7 @@ class CoreNetworkBase(NodeBase):
:param flags: message type
:return: list of link data
"""
"""
all_links = []
# build a link message from this network node to each node having a
@ -1142,7 +1142,7 @@ class Position:
:param y: y position
:param z: z position
:return: True if position changed, False otherwise
"""
"""
if self.x == x and self.y == y and self.z == z:
return False
self.x = x
@ -1155,5 +1155,5 @@ class Position:
Retrieve x,y,z position.
:return: x,y,z position tuple
"""
"""
return self.x, self.y, self.z

View file

@ -38,7 +38,7 @@ class VnodeClient:
Check if node is connected or not.
:return: True if connected, False otherwise
"""
"""
return True
def close(self) -> None:

View file

@ -118,7 +118,7 @@ class DockerNode(CoreNode):
Check if the node is alive.
:return: True if node is alive, False otherwise
"""
"""
return self.client.is_alive()
def startup(self) -> None:

View file

@ -226,7 +226,7 @@ class CoreInterface:
:param other: other interface
:return: true if less than, false otherwise
"""
"""
return id(self) < id(other)
@ -374,7 +374,7 @@ class TunTap(CoreInterface):
:param attempts: number of attempts to wait for a zero result
:param maxretrydelay: maximum retry delay
:return: True if wait succeeded, False otherwise
"""
"""
delay = 0.01
result = False
for i in range(1, attempts + 1):
@ -402,7 +402,7 @@ class TunTap(CoreInterface):
appear right away waits
:return: wait for device local response
"""
"""
logging.debug("waiting for device local: %s", self.localname)
def localdevexists():
@ -560,5 +560,5 @@ class GreTap(CoreInterface):
:param flags: link flags
:return: link data
"""
"""
return []

View file

@ -102,7 +102,7 @@ class LxcNode(CoreNode):
Check if the node is alive.
:return: True if node is alive, False otherwise
"""
"""
return self.client.is_alive()
def startup(self) -> None:

View file

@ -73,7 +73,7 @@ class LinuxNetClient:
:param device: device to get information for
:return: device information
"""
"""
return self.run(f"{IP_BIN} link show {device}")
def get_mac(self, device: str) -> str:
@ -82,7 +82,7 @@ class LinuxNetClient:
:param device: device to get mac for
:return: MAC address
"""
"""
return self.run(f"cat /sys/class/net/{device}/address")
def get_ifindex(self, device: str) -> str:
@ -91,7 +91,7 @@ class LinuxNetClient:
:param device: device to get ifindex for
:return: ifindex
"""
"""
return self.run(f"cat /sys/class/net/{device}/ifindex")
def device_ns(self, device: str, namespace: str) -> None:

View file

@ -102,7 +102,7 @@ class EbtablesQueue:
:param cmd: ebtable command
:return: ebtable atomic command
"""
"""
return f"{EBTABLES_BIN} --atomic-file {self.atomic_file} {cmd}"
def lastupdate(self, wlan: "CoreNetwork") -> float:
@ -111,7 +111,7 @@ class EbtablesQueue:
:param wlan: wlan entity
:return: elpased time
"""
"""
try:
elapsed = time.monotonic() - self.last_update_time[wlan]
except KeyError:
@ -387,7 +387,7 @@ class CoreNetwork(CoreNetworkBase):
:param netif1: interface one
:param netif2: interface two
:return: True if interfaces are linked, False otherwise
"""
"""
# check if the network interfaces are attached to this network
if self._netif[netif1.netifi] != netif1:
raise ValueError(f"inconsistency for netif {netif1.name}")
@ -544,7 +544,7 @@ class CoreNetwork(CoreNetworkBase):
:param net: network to link with
:return: created interface
"""
"""
sessionid = self.session.short_session_id()
try:
_id = f"{self.id:x}"
@ -584,7 +584,7 @@ class CoreNetwork(CoreNetworkBase):
:param net: interface to get link for
:return: interface the provided network is linked to
"""
"""
for netif in self.netifs():
if hasattr(netif, "othernet") and netif.othernet == net:
return netif
@ -855,7 +855,7 @@ class CtrlNet(CoreNetwork):
:param flags: message flags
:return: list of link data
"""
"""
return []
@ -897,7 +897,7 @@ class PtpNet(CoreNetwork):
:param alt: altitude
:param source: source of node data
:return: node data object
"""
"""
return None
def all_link_data(self, flags: int) -> List[LinkData]:
@ -907,8 +907,7 @@ class PtpNet(CoreNetwork):
:param flags: message flags
:return: list of link data
"""
"""
all_links = []
if len(self._netif) != 2:
@ -1130,7 +1129,7 @@ class WlanNode(CoreNetwork):
:param flags: message flags
:return: list of link data
"""
"""
all_links = super().all_link_data(flags)
if self.model:
all_links.extend(self.model.all_link_data(flags))

View file

@ -424,7 +424,7 @@ class Rj45Node(CoreNodeBase, CoreInterface):
:param ifindex: interface index to retrieve
:param net: network to retrieve
:return: a network interface
"""
"""
if net is not None and net == self.net:
return self
@ -443,7 +443,7 @@ class Rj45Node(CoreNodeBase, CoreInterface):
:param netif: network interface to retrieve
index for
:return: interface index, None otherwise
"""
"""
if netif != self:
return None
return self.ifindex
@ -526,7 +526,7 @@ class Rj45Node(CoreNodeBase, CoreInterface):
:param y: y position
:param z: z position
:return: True if position changed, False otherwise
"""
"""
result = CoreNodeBase.setposition(self, x, y, z)
CoreInterface.setposition(self, x, y, z)
return result

View file

@ -134,7 +134,7 @@ class Sdt:
the option is missing.
:return: True if enabled, False otherwise
"""
"""
return self.session.options.get_config("enablesdt") == "1"
def seturl(self) -> None:
@ -156,7 +156,7 @@ class Sdt:
Connect to the SDT address/port if enabled.
:return: True if connected, False otherwise
"""
"""
if not self.is_enabled():
return False
if self.connected:
@ -194,7 +194,7 @@ class Sdt:
the virtual globe.
:return: initialize command status
"""
"""
if not self.cmd(f'path "{CORE_DATA_DIR}/icons/normal"'):
return False
# send node type to icon mappings
@ -238,7 +238,7 @@ class Sdt:
:param cmdstr: command to send
:return: True if command was successful, False otherwise
"""
"""
if self.sock is None:
return False
try:
@ -507,7 +507,7 @@ class Sdt:
:param nodenum: node id to check
:return: True if node is wlan or emane, False otherwise
"""
"""
if nodenum in self.remotes:
node_type = self.remotes[nodenum].type
if node_type in ("wlan", "emane"):

View file

@ -16,5 +16,5 @@ def load():
Loads all services from the modules that reside under core.services.
:return: list of services that failed to load
"""
"""
return ServiceManager.add_services(_PATH)

View file

@ -60,7 +60,7 @@ class ServiceDependencies:
Generates the boot paths for the services provided to the class.
:return: list of services to boot, in order
"""
"""
paths = []
for name in self.node_services:
service = self.node_services[name]
@ -151,7 +151,7 @@ class ServiceShim:
:param node: node to get value list for
:param service: service to get value list for
:return: value list string
"""
"""
start_time = 0
start_index = 0
valmap = [
@ -229,7 +229,7 @@ class ServiceShim:
:param opaque: opaque data string
:return: services
"""
"""
servicesstring = opaque.split(":")
if servicesstring[0] != "service":
return []
@ -280,7 +280,7 @@ class ServiceManager:
:param name: name of the service to retrieve
:return: service if it exists, None otherwise
"""
"""
return cls.services.get(name)
@classmethod
@ -290,7 +290,7 @@ class ServiceManager:
:param path: path to retrieve services from
:return: list of core services that failed to load
"""
"""
service_errors = []
services = utils.load_classes(path, CoreService)
for service in services:
@ -342,7 +342,7 @@ class CoreServices:
:param node_type: node type to get default services for
:return: default services
"""
"""
logging.debug("getting default services for type: %s", node_type)
results = []
defaults = self.default_services.get(node_type, [])
@ -426,7 +426,7 @@ class CoreServices:
to a session or opening XML.
:return: list of tuples of node ids and services
"""
"""
configs = []
for node_id in self.custom_services:
custom_services = self.custom_services[node_id]
@ -442,7 +442,7 @@ class CoreServices:
:param service: service to get files for
:return: list of all custom service files
"""
"""
files = []
if not service.custom:
return files
@ -566,7 +566,7 @@ class CoreServices:
:param filename: file name for a configured service
:param cfg: configuration string
:return: True if successful, False otherwise
"""
"""
if cfg[:7] == "file://":
src = cfg[7:]
src = src.split("\n")[0]
@ -583,7 +583,7 @@ class CoreServices:
:param node: node to validate service for
:param service: service to validate
:return: service validation status
"""
"""
logging.debug("validating node(%s) service(%s)", node.name, service.name)
cmds = service.validate
if not service.custom:
@ -723,8 +723,7 @@ class CoreServices:
:param service: service to reconfigure
:param wait: determines if we should wait to validate startup
:return: status of startup
"""
"""
cmds = service.startup
if not service.custom:
cmds = service.get_startup(node)
@ -869,7 +868,7 @@ class CoreService:
:param node: node to generate config for
:return: configuration files
"""
"""
return cls.configs
@classmethod
@ -896,7 +895,7 @@ class CoreService:
:param node: node to get startup for
:return: startup commands
"""
"""
return cls.startup
@classmethod
@ -909,5 +908,5 @@ class CoreService:
:param node: node to validate
:return: validation commands
"""
"""
return cls.validate

View file

@ -12,7 +12,7 @@ class NrlService(CoreService):
"""
Parent class for NRL services. Defines properties and methods
common to NRL's routing daemons.
""" ""
"""
name = None
group = "ProtoSvc"

View file

@ -26,7 +26,7 @@ def is_external(config: Dict[str, str]) -> bool:
:param config: configuration to check
:return: True if external, False otherwise
"""
"""
return config.get("external") == "1"
@ -144,7 +144,7 @@ def build_node_platform_xml(
:param nem_id: nem id to use for interfaces for this node
:param platform_xmls: stores platform xml elements to append nem entries to
:return: the next nem id that can be used for creating platform xml files
"""
"""
logging.debug(
"building emane platform xml for node(%s) nem_id(%s): %s",
node,
@ -500,7 +500,7 @@ def _basename(emane_model: "EmaneModel", interface: CoreInterface = None) -> str
:param emane_model: emane model to create name for
:param interface: interface for this model
:return: basename used for file creation
"""
"""
name = f"n{emane_model.id}"
if interface:
@ -518,7 +518,7 @@ def nem_file_name(emane_model: "EmaneModel", interface: CoreInterface = None) ->
:param emane_model: emane model to create file
:param interface: interface for this model
:return: nem xml filename
"""
"""
basename = _basename(emane_model, interface)
append = ""
if interface and interface.transport_type == "raw":
@ -533,7 +533,7 @@ def shim_file_name(emane_model: "EmaneModel", interface: CoreInterface = None) -
:param emane_model: emane model to create file
:param interface: interface for this model
:return: shim xml filename
"""
"""
name = _basename(emane_model, interface)
return f"{name}shim.xml"
@ -545,7 +545,7 @@ def mac_file_name(emane_model: "EmaneModel", interface: CoreInterface = None) ->
:param emane_model: emane model to create file
:param interface: interface for this model
:return: mac xml filename
"""
"""
name = _basename(emane_model, interface)
return f"{name}mac.xml"
@ -557,6 +557,6 @@ def phy_file_name(emane_model: "EmaneModel", interface: CoreInterface = None) ->
:param emane_model: emane model to create file
:param interface: interface for this model
:return: phy xml filename
"""
"""
name = _basename(emane_model, interface)
return f"{name}phy.xml"