pass on updated pydocs to reflect path changes

This commit is contained in:
Blake Harnden 2019-06-07 08:59:16 -07:00
parent 89877ffe6f
commit db7bfe12bd
17 changed files with 111 additions and 137 deletions

View file

@ -96,7 +96,7 @@ class CoreBroker(object):
""" """
Creates a CoreBroker instance. Creates a CoreBroker instance.
:param core.session.Session session: session this manager is tied to :param core.emulator.session.Session session: session this manager is tied to
:return: nothing :return: nothing
""" """
@ -901,7 +901,7 @@ class CoreBroker(object):
opaque data in the link message, otherwise use the IP of the message opaque data in the link message, otherwise use the IP of the message
sender (the master server). sender (the master server).
:param coreapi.CoreLinkMessage msg: :param core.api.tlv.coreapi.CoreLinkMessage msg: link message
:param bool first_is_local: is first local :param bool first_is_local: is first local
:return: host address :return: host address
:rtype: str :rtype: str

View file

@ -243,7 +243,7 @@ class CoreTlvDataUint16List(CoreTlvData):
Retrieves a unint 16 list from a string Retrieves a unint 16 list from a string
:param str value: string representation of a uint 16 list :param str value: string representation of a uint 16 list
:return: unint 16 list :return: uint 16 list
:rtype: list :rtype: list
""" """
return tuple(int(x) for x in value.split()) return tuple(int(x) for x in value.split())
@ -274,7 +274,7 @@ class CoreTlvDataIpv4Addr(CoreTlvDataObj):
:param str value: value to get Ipv4 address from :param str value: value to get Ipv4 address from
:return: Ipv4 address :return: Ipv4 address
:rtype: core.misc.ipaddress.IpAddress :rtype: core.nodes.ipaddress.IpAddress
""" """
return IpAddress(af=socket.AF_INET, address=value) return IpAddress(af=socket.AF_INET, address=value)
@ -292,7 +292,7 @@ class CoreTlvDataIPv6Addr(CoreTlvDataObj):
""" """
Retrieve Ipv6 address value from object. Retrieve Ipv6 address value from object.
:param core.misc.ipaddress.IpAddress obj: ip address to get value from :param core.nodes.ipaddress.IpAddress obj: ip address to get value from
:return: :return:
""" """
return obj.addr return obj.addr
@ -304,7 +304,7 @@ class CoreTlvDataIPv6Addr(CoreTlvDataObj):
:param str value: value to get Ipv4 address from :param str value: value to get Ipv4 address from
:return: Ipv4 address :return: Ipv4 address
:rtype: core.misc.ipaddress.IpAddress :rtype: core.nodes.ipaddress.IpAddress
""" """
return IpAddress(af=socket.AF_INET6, address=value) return IpAddress(af=socket.AF_INET6, address=value)
@ -322,7 +322,7 @@ class CoreTlvDataMacAddr(CoreTlvDataObj):
""" """
Retrieve Ipv6 address value from object. Retrieve Ipv6 address value from object.
:param core.misc.ipaddress.MacAddress obj: mac address to get value from :param core.nodes.ipaddress.MacAddress obj: mac address to get value from
:return: :return:
""" """
# extend to 64 bits # extend to 64 bits
@ -335,7 +335,7 @@ class CoreTlvDataMacAddr(CoreTlvDataObj):
:param str value: value to get Ipv4 address from :param str value: value to get Ipv4 address from
:return: Ipv4 address :return: Ipv4 address
:rtype: core.misc.ipaddress.MacAddress :rtype: core.nodes.ipaddress.MacAddress
""" """
# only use 48 bits # only use 48 bits
return MacAddress(address=value[2:]) return MacAddress(address=value[2:])

View file

@ -213,7 +213,7 @@ class CoreHandler(socketserver.BaseRequestHandler):
""" """
Callback to handle an event broadcast out from a session. Callback to handle an event broadcast out from a session.
:param core.data.EventData event_data: event data to handle :param core.emulator.data.EventData event_data: event data to handle
:return: nothing :return: nothing
""" """
logging.debug("handling broadcast event: %s", event_data) logging.debug("handling broadcast event: %s", event_data)
@ -237,7 +237,7 @@ class CoreHandler(socketserver.BaseRequestHandler):
""" """
Callback to handle a file broadcast out from a session. Callback to handle a file broadcast out from a session.
:param core.data.FileData file_data: file data to handle :param core.emulator.data.FileData file_data: file data to handle
:return: nothing :return: nothing
""" """
logging.debug("handling broadcast file: %s", file_data) logging.debug("handling broadcast file: %s", file_data)
@ -264,7 +264,7 @@ class CoreHandler(socketserver.BaseRequestHandler):
""" """
Callback to handle a config broadcast out from a session. Callback to handle a config broadcast out from a session.
:param core.data.ConfigData config_data: config data to handle :param core.emulator.data.ConfigData config_data: config data to handle
:return: nothing :return: nothing
""" """
logging.debug("handling broadcast config: %s", config_data) logging.debug("handling broadcast config: %s", config_data)
@ -278,7 +278,7 @@ class CoreHandler(socketserver.BaseRequestHandler):
""" """
Callback to handle an exception broadcast out from a session. Callback to handle an exception broadcast out from a session.
:param core.data.ExceptionData exception_data: exception data to handle :param core.emulator.data.ExceptionData exception_data: exception data to handle
:return: nothing :return: nothing
""" """
logging.debug("handling broadcast exception: %s", exception_data) logging.debug("handling broadcast exception: %s", exception_data)
@ -301,7 +301,7 @@ class CoreHandler(socketserver.BaseRequestHandler):
""" """
Callback to handle an node broadcast out from a session. Callback to handle an node broadcast out from a session.
:param core.data.NodeData node_data: node data to handle :param core.emulator.data.NodeData node_data: node data to handle
:return: nothing :return: nothing
""" """
logging.debug("handling broadcast node: %s", node_data) logging.debug("handling broadcast node: %s", node_data)
@ -315,7 +315,7 @@ class CoreHandler(socketserver.BaseRequestHandler):
""" """
Callback to handle an link broadcast out from a session. Callback to handle an link broadcast out from a session.
:param core.data.LinkData link_data: link data to handle :param core.emulator.data.LinkData link_data: link data to handle
:return: nothing :return: nothing
""" """
logging.debug("handling broadcast link: %s", link_data) logging.debug("handling broadcast link: %s", link_data)
@ -407,7 +407,7 @@ class CoreHandler(socketserver.BaseRequestHandler):
Receive data and return a CORE API message object. Receive data and return a CORE API message object.
:return: received message :return: received message
:rtype: coreapi.CoreMessage :rtype: core.api.tlv.coreapi.CoreMessage
""" """
try: try:
header = self.request.recv(coreapi.CoreMessage.header_len) header = self.request.recv(coreapi.CoreMessage.header_len)
@ -586,7 +586,7 @@ class CoreHandler(socketserver.BaseRequestHandler):
""" """
Sends an exception for display within the GUI. Sends an exception for display within the GUI.
:param core.enumerations.ExceptionLevel level: level for exception :param core.emulator.enumerations.ExceptionLevel level: level for exception
:param str source: source where exception came from :param str source: source where exception came from
:param str text: details about exception :param str text: details about exception
:param int node: node id, if related to a specific node :param int node: node id, if related to a specific node
@ -624,7 +624,7 @@ class CoreHandler(socketserver.BaseRequestHandler):
""" """
Node Message handler Node Message handler
:param coreapi.CoreNodeMessage message: node message :param core.api.coreapi.CoreNodeMessage message: node message
:return: replies to node message :return: replies to node message
""" """
replies = [] replies = []
@ -696,7 +696,7 @@ class CoreHandler(socketserver.BaseRequestHandler):
""" """
Link Message handler Link Message handler
:param coreapi.CoreLinkMessage message: link message to handle :param core.api.tlv.coreapi.CoreLinkMessage message: link message to handle
:return: link message replies :return: link message replies
""" """
node_one_id = message.get_tlv(LinkTlvs.N1_NUMBER.value) node_one_id = message.get_tlv(LinkTlvs.N1_NUMBER.value)
@ -756,7 +756,7 @@ class CoreHandler(socketserver.BaseRequestHandler):
""" """
Execute Message handler Execute Message handler
:param coreapi.CoreExecMessage message: execute message to handle :param core.api.tlv.coreapi.CoreExecMessage message: execute message to handle
:return: reply messages :return: reply messages
""" """
node_num = message.get_tlv(ExecuteTlvs.NODE.value) node_num = message.get_tlv(ExecuteTlvs.NODE.value)
@ -831,7 +831,7 @@ class CoreHandler(socketserver.BaseRequestHandler):
""" """
Register Message Handler Register Message Handler
:param coreapi.CoreRegMessage message: register message to handle :param core.api.tlv.coreapi.CoreRegMessage message: register message to handle
:return: reply messages :return: reply messages
""" """
replies = [] replies = []
@ -923,7 +923,7 @@ class CoreHandler(socketserver.BaseRequestHandler):
""" """
Configuration Message handler Configuration Message handler
:param coreapi.CoreConfMessage message: configuration message to handle :param core.api.tlv.coreapi.CoreConfMessage message: configuration message to handle
:return: reply messages :return: reply messages
""" """
# convert config message to standard config data object # convert config message to standard config data object
@ -1341,7 +1341,7 @@ class CoreHandler(socketserver.BaseRequestHandler):
""" """
File Message handler File Message handler
:param coreapi.CoreFileMessage message: file message to handle :param core.api.tlv.coreapi.CoreFileMessage message: file message to handle
:return: reply messages :return: reply messages
""" """
if message.flags & MessageFlags.ADD.value: if message.flags & MessageFlags.ADD.value:
@ -1405,7 +1405,7 @@ class CoreHandler(socketserver.BaseRequestHandler):
""" """
Event Message handler Event Message handler
:param coreapi.CoreEventMessage message: event message to handle :param core.api.tlv.coreapi.CoreEventMessage message: event message to handle
:return: reply messages :return: reply messages
""" """
event_data = EventData( event_data = EventData(
@ -1508,7 +1508,7 @@ class CoreHandler(socketserver.BaseRequestHandler):
Handle an Event Message used to start, stop, restart, or validate Handle an Event Message used to start, stop, restart, or validate
a service on a given node. a service on a given node.
:param EventData event_data: event data to handle :param core.emulator.enumerations.EventData event_data: event data to handle
:return: nothing :return: nothing
""" """
event_type = event_data.event_type event_type = event_data.event_type
@ -1573,7 +1573,7 @@ class CoreHandler(socketserver.BaseRequestHandler):
""" """
Session Message handler Session Message handler
:param coreapi.CoreSessionMessage message: session message to handle :param core.api.tlv.coreapi.CoreSessionMessage message: session message to handle
:return: reply messages :return: reply messages
""" """
session_id_str = message.get_tlv(SessionTlvs.NUMBER.value) session_id_str = message.get_tlv(SessionTlvs.NUMBER.value)

View file

@ -11,7 +11,7 @@ def convert_node(node_data):
""" """
Convenience method for converting NodeData to a packed TLV message. Convenience method for converting NodeData to a packed TLV message.
:param core.data.NodeData node_data: node data to convert :param core.emulator.data.NodeData node_data: node data to convert
:return: packed node message :return: packed node message
""" """
tlv_data = structutils.pack_values(coreapi.CoreNodeTlv, [ tlv_data = structutils.pack_values(coreapi.CoreNodeTlv, [
@ -43,7 +43,7 @@ def convert_config(config_data):
""" """
Convenience method for converting ConfigData to a packed TLV message. Convenience method for converting ConfigData to a packed TLV message.
:param core.data.ConfigData config_data: config data to convert :param core.emulator.data.ConfigData config_data: config data to convert
:return: packed message :return: packed message
""" """
tlv_data = structutils.pack_values(coreapi.CoreConfigTlv, [ tlv_data = structutils.pack_values(coreapi.CoreConfigTlv, [

View file

@ -147,7 +147,7 @@ class EmaneModel(WirelessModel):
""" """
Invoked when a Link Message is received. Default is unimplemented. Invoked when a Link Message is received. Default is unimplemented.
:param core.netns.vif.Veth netif: interface one :param core.nodes.interface.Veth netif: interface one
:param bw: bandwidth to set to :param bw: bandwidth to set to
:param delay: packet delay to set to :param delay: packet delay to set to
:param loss: packet loss to set to :param loss: packet loss to set to

View file

@ -41,7 +41,7 @@ class MobilityManager(ModelManager):
""" """
Creates a MobilityManager instance. Creates a MobilityManager instance.
:param core.session.Session session: session this manager is tied to :param core.emulator.session.Session session: session this manager is tied to
""" """
super(MobilityManager, self).__init__() super(MobilityManager, self).__init__()
self.session = session self.session = session
@ -468,8 +468,6 @@ class BasicRangeModel(WirelessModel):
with self.wlan._linked_lock: with self.wlan._linked_lock:
linked = self.wlan.linked(a, b) linked = self.wlan.linked(a, b)
logging.debug("checking range netif1(%s) netif2(%s): linked(%s) actual(%s) > config(%s)",
a.name, b.name, linked, d, self.range)
if d > self.range: if d > self.range:
if linked: if linked:
logging.debug("was linked, unlinking") logging.debug("was linked, unlinking")
@ -533,8 +531,8 @@ class BasicRangeModel(WirelessModel):
""" """
Send a wireless link/unlink API message to the GUI. Send a wireless link/unlink API message to the GUI.
:param core.coreobj.PyCoreNetIf netif: interface one :param core.nodes.interface.CoreInterface netif: interface one
:param core.coreobj.PyCoreNetIf netif2: interface two :param core.nodes.interface.CoreInterface netif2: interface two
:param bool unlink: unlink or not :param bool unlink: unlink or not
:return: nothing :return: nothing
""" """
@ -702,7 +700,7 @@ class WayPointMobility(WirelessModel):
Calculate next node location and update its coordinates. Calculate next node location and update its coordinates.
Returns True if the node's position has changed. Returns True if the node's position has changed.
:param core.netns.vnode.CoreNode node: node to move :param core.nodes.base.CoreNode node: node to move
:param dt: move factor :param dt: move factor
:return: True if node was moved, False otherwise :return: True if node was moved, False otherwise
:rtype: bool :rtype: bool
@ -929,9 +927,8 @@ class Ns2ScriptedMobility(WayPointMobility):
""" """
Creates a Ns2ScriptedMobility instance. Creates a Ns2ScriptedMobility instance.
:param core.session.Session session: CORE session instance :param core.emulator.session.Session session: CORE session instance
:param int _id: object id :param int _id: object id
:param config: values
""" """
super(Ns2ScriptedMobility, self).__init__(session=session, _id=_id) super(Ns2ScriptedMobility, self).__init__(session=session, _id=_id)
self._netifs = {} self._netifs = {}

View file

@ -1,5 +1,5 @@
""" """
PyCoreNode and LxcNode classes that implement the network namespac virtual node. Defines the base logic for nodes used within core.
""" """
import errno import errno
@ -11,9 +11,10 @@ import signal
import socket import socket
import string import string
import threading import threading
from builtins import range
from socket import AF_INET, AF_INET6 from socket import AF_INET, AF_INET6
from builtins import range
from core import CoreCommandError, utils from core import CoreCommandError, utils
from core import constants from core import constants
from core.emulator.data import NodeData, LinkData from core.emulator.data import NodeData, LinkData
@ -21,7 +22,6 @@ from core.emulator.enumerations import NodeTypes, LinkTypes
from core.nodes import client, nodeutils, ipaddress from core.nodes import client, nodeutils, ipaddress
from core.nodes.interface import TunTap, CoreInterface from core.nodes.interface import TunTap, CoreInterface
from core.nodes.interface import Veth from core.nodes.interface import Veth
from core.nodes.ipaddress import MacAddress
_DEFAULT_MTU = 1500 _DEFAULT_MTU = 1500
@ -39,7 +39,7 @@ class NodeBase(object):
""" """
Creates a PyCoreObj instance. Creates a PyCoreObj instance.
:param core.session.Session session: CORE session object :param core.emulator.session.Session session: CORE session object
:param int _id: id :param int _id: id
:param str name: object name :param str name: object name
:param bool start: start value :param bool start: start value
@ -226,7 +226,7 @@ class CoreNodeBase(NodeBase):
""" """
Create a CoreNodeBase instance. Create a CoreNodeBase instance.
:param core.session.Session session: CORE session object :param core.emulator.session.Session session: CORE session object
:param int _id: object id :param int _id: object id
:param str name: object name :param str name: object name
:param bool start: boolean for starting :param bool start: boolean for starting
@ -417,14 +417,6 @@ class CoreNodeBase(NodeBase):
class CoreNode(CoreNodeBase): class CoreNode(CoreNodeBase):
""" """
Provides standard core node logic. Provides standard core node logic.
:var nodedir: str
:var ctrlchnlname: str
:var client: core.netns.vnodeclient.VnodeClient
:var pid: int
:var up: bool
:var lock: threading.RLock
:var _mounts: list[tuple[str, str]]
""" """
apitype = NodeTypes.DEFAULT.value apitype = NodeTypes.DEFAULT.value
valid_address_types = {"inet", "inet6", "inet6link"} valid_address_types = {"inet", "inet6", "inet6link"}
@ -433,7 +425,7 @@ class CoreNode(CoreNodeBase):
""" """
Create a CoreNode instance. Create a CoreNode instance.
:param core.session.Session session: core session instance :param core.emulator.session.Session session: core session instance
:param int _id: object id :param int _id: object id
:param str name: object name :param str name: object name
:param str nodedir: node directory :param str nodedir: node directory
@ -646,7 +638,7 @@ class CoreNode(CoreNodeBase):
:param int ifindex: index for the new interface :param int ifindex: index for the new interface
:param str ifname: name for the new interface :param str ifname: name for the new interface
:param net: network to associate interface with :param core.nodes.base.CoreNetworkBase net: network to associate interface with
:return: nothing :return: nothing
""" """
with self.lock: with self.lock:
@ -736,7 +728,7 @@ class CoreNode(CoreNodeBase):
Set hardware addres for an interface. Set hardware addres for an interface.
:param int ifindex: index of interface to set hardware address for :param int ifindex: index of interface to set hardware address for
:param core.misc.ipaddress.MacAddress addr: hardware address to set :param core.nodes.ipaddress.MacAddress addr: hardware address to set
:return: nothing :return: nothing
:raises CoreCommandError: when a non-zero exit status occurs :raises CoreCommandError: when a non-zero exit status occurs
""" """
@ -819,9 +811,9 @@ class CoreNode(CoreNodeBase):
""" """
Create a new network interface. Create a new network interface.
:param net: network to associate with :param core.nodes.base.CoreNetworkBase net: network to associate with
:param list addrlist: addresses to add on the interface :param list addrlist: addresses to add on the interface
:param core.misc.ipaddress.MacAddress hwaddr: hardware address to set for interface :param core.nodes.ipaddress.MacAddress hwaddr: hardware address to set for interface
:param int ifindex: index of interface to create :param int ifindex: index of interface to create
:param str ifname: name for interface :param str ifname: name for interface
:return: interface index :return: interface index
@ -864,7 +856,7 @@ class CoreNode(CoreNodeBase):
Connect a node. Connect a node.
:param str ifname: name of interface to connect :param str ifname: name of interface to connect
:param core.netns.nodes.LxcNode othernode: node to connect to :param core.nodes.CoreNodeBase othernode: node to connect to
:param str otherifname: interface name to connect to :param str otherifname: interface name to connect to
:return: nothing :return: nothing
""" """
@ -970,9 +962,9 @@ class CoreNetworkBase(NodeBase):
def __init__(self, session, _id, name, start=True): def __init__(self, session, _id, name, start=True):
""" """
Create a PyCoreNet instance. Create a CoreNetworkBase instance.
:param core.session.Session session: CORE session object :param core.emulator.session.Session session: CORE session object
:param int _id: object id :param int _id: object id
:param str name: object name :param str name: object name
:param bool start: should object start :param bool start: should object start

View file

@ -1,8 +1,7 @@
""" """
client.py: implementation of the VnodeClient class for issuing commands client.py: implementation of the VnodeClient class for issuing commands
over a control channel to the vnoded process running in a network namespace. over a control channel to the vnoded process running in a network namespace.
The control channel can be accessed via calls to the vcmd Python module or The control channel can be accessed via calls using the vcmd shell.
by invoking the vcmd shell command.
""" """
import logging import logging
@ -124,8 +123,6 @@ class VnodeClient(object):
""" """
self._verify_connection() self._verify_connection()
args = utils.split_args(args) args = utils.split_args(args)
# if isinstance(args, list):
# args = " ".join(args)
cmd = self._cmd_args() + args cmd = self._cmd_args() + args
logging.info("popen: %s", cmd) logging.info("popen: %s", cmd)
p = Popen(cmd, stdout=PIPE, stderr=PIPE, stdin=PIPE) p = Popen(cmd, stdout=PIPE, stderr=PIPE, stdin=PIPE)

View file

@ -24,7 +24,7 @@ class CoreInterface(object):
""" """
Creates a PyCoreNetIf instance. Creates a PyCoreNetIf instance.
:param core.coreobj.PyCoreNode node: node for interface :param core.nodes.base.CoreNode node: node for interface
:param str name: interface name :param str name: interface name
:param mtu: mtu value :param mtu: mtu value
""" """
@ -67,7 +67,7 @@ class CoreInterface(object):
""" """
Attach network. Attach network.
:param core.coreobj.PyCoreNet net: network to attach :param core.nodes.base.CoreNetworkBase net: network to attach
:return: nothing :return: nothing
""" """
if self.net: if self.net:
@ -109,7 +109,7 @@ class CoreInterface(object):
""" """
Set hardware address. Set hardware address.
:param core.misc.ipaddress.MacAddress addr: hardware address to set to. :param core.nodes.ipaddress.MacAddress addr: hardware address to set to.
:return: nothing :return: nothing
""" """
self.hwaddr = addr self.hwaddr = addr
@ -199,7 +199,7 @@ class Veth(CoreInterface):
""" """
Creates a VEth instance. Creates a VEth instance.
:param core.netns.vnode.SimpleLxcNode node: related core node :param core.nodes.base.CoreNode node: related core node
:param str name: interface name :param str name: interface name
:param str localname: interface local name :param str localname: interface local name
:param mtu: interface mtu :param mtu: interface mtu
@ -260,11 +260,11 @@ class TunTap(CoreInterface):
""" """
Create a TunTap instance. Create a TunTap instance.
:param core.netns.vnode.SimpleLxcNode node: related core node :param core.nodes.base.CoreNode node: related core node
:param str name: interface name :param str name: interface name
:param str localname: local interface name :param str localname: local interface name
:param mtu: interface mtu :param mtu: interface mtu
:param net: related network :param core.nodes.base.CoreNetworkBase net: related network
:param bool start: start flag :param bool start: start flag
""" """
CoreInterface.__init__(self, node=node, name=name, mtu=mtu) CoreInterface.__init__(self, node=node, name=name, mtu=mtu)
@ -420,9 +420,9 @@ class GreTap(CoreInterface):
""" """
Creates a GreTap instance. Creates a GreTap instance.
:param core.netns.vnode.SimpleLxcNode node: related core node :param core.nodes.base.CoreNode node: related core node
:param str name: interface name :param str name: interface name
:param core.session.Session session: core session instance :param core.emulator.session.Session session: core session instance
:param mtu: interface mtu :param mtu: interface mtu
:param str remoteip: remote address :param str remoteip: remote address
:param int _id: object id :param int _id: object id
@ -493,6 +493,6 @@ class GreTap(CoreInterface):
:param flags: link flags :param flags: link flags
:return: link data :return: link data
:rtype: list[core.data.LinkData] :rtype: list[core.emulator.data.LinkData]
""" """
return [] return []

View file

@ -215,7 +215,7 @@ class IpPrefix(object):
Create a IpPrefix instance. Create a IpPrefix instance.
:param int af: address family for ip prefix :param int af: address family for ip prefix
:param prefixstr: ip prefix string :param str prefixstr: ip prefix string
""" """
# prefixstr format: address/prefixlen # prefixstr format: address/prefixlen
tmp = prefixstr.split("/") tmp = prefixstr.split("/")

View file

@ -1,6 +1,5 @@
""" """
PyCoreNet and LxBrNet classes that implement virtual networks using Defines network nodes used within core.
Linux Ethernet bridging and ebtables rules.
""" """
import logging import logging
@ -343,7 +342,7 @@ class CoreNetwork(CoreNetworkBase):
""" """
Detach a network interface. Detach a network interface.
:param core.netns.vif.Veth netif: network interface to detach :param core.nodes.interface.Veth netif: network interface to detach
:return: nothing :return: nothing
""" """
if self.up: if self.up:
@ -355,8 +354,8 @@ class CoreNetwork(CoreNetworkBase):
""" """
Determine if the provided network interfaces are linked. Determine if the provided network interfaces are linked.
:param core.netns.vif.Veth netif1: interface one :param core.nodes.interface.CoreInterface netif1: interface one
:param core.netns.vif.Veth netif2: interface two :param core.nodes.interface.CoreInterface netif2: interface two
:return: True if interfaces are linked, False otherwise :return: True if interfaces are linked, False otherwise
:rtype: bool :rtype: bool
""" """
@ -385,8 +384,8 @@ class CoreNetwork(CoreNetworkBase):
Unlink two PyCoreNetIfs, resulting in adding or removing ebtables Unlink two PyCoreNetIfs, resulting in adding or removing ebtables
filtering rules. filtering rules.
:param core.netns.vif.Veth netif1: interface one :param core.nodes.interface.CoreInterface netif1: interface one
:param core.netns.vif.Veth netif2: interface two :param core.nodes.interface.CoreInterface netif2: interface two
:return: nothing :return: nothing
""" """
with self._linked_lock: with self._linked_lock:
@ -401,8 +400,8 @@ class CoreNetwork(CoreNetworkBase):
Link two PyCoreNetIfs together, resulting in adding or removing Link two PyCoreNetIfs together, resulting in adding or removing
ebtables filtering rules. ebtables filtering rules.
:param core.netns.vif.Veth netif1: interface one :param core.nodes.interface.CoreInterface netif1: interface one
:param core.netns.vif.Veth netif2: interface two :param core.nodes.interface.CoreInterface netif2: interface two
:return: nothing :return: nothing
""" """
with self._linked_lock: with self._linked_lock:
@ -417,7 +416,7 @@ class CoreNetwork(CoreNetworkBase):
""" """
Configure link parameters by applying tc queuing disciplines on the interface. Configure link parameters by applying tc queuing disciplines on the interface.
:param core.netns.vif.Veth netif: interface one :param core.nodes.interface.Veth netif: interface one
:param bw: bandwidth to set to :param bw: bandwidth to set to
:param delay: packet delay to set to :param delay: packet delay to set to
:param loss: packet loss to set to :param loss: packet loss to set to
@ -549,9 +548,9 @@ class CoreNetwork(CoreNetworkBase):
Return the interface of that links this net with another net Return the interface of that links this net with another net
(that were linked using linknet()). (that were linked using linknet()).
:param core.netns.vnet.LxBrNet net: interface to get link for :param core.nodes.base.CoreNetworkBase net: interface to get link for
:return: interface the provided network is linked to :return: interface the provided network is linked to
:rtype: core.netns.vnet.LxBrNet :rtype: core.nodes.interface.CoreInterface
""" """
for netif in self.netifs(): for netif in self.netifs():
if hasattr(netif, "othernet") and netif.othernet == net: if hasattr(netif, "othernet") and netif.othernet == net:
@ -584,7 +583,7 @@ class GreTapBridge(CoreNetwork):
""" """
Create a GreTapBridge instance. Create a GreTapBridge instance.
:param core.session.Session session: core session instance :param core.emulator.session.Session session: core session instance
:param str remoteip: remote address :param str remoteip: remote address
:param int _id: object id :param int _id: object id
:param str name: object name :param str name: object name
@ -593,7 +592,6 @@ class GreTapBridge(CoreNetwork):
:param ttl: ttl value :param ttl: ttl value
:param key: gre tap key :param key: gre tap key
:param bool start: start flag :param bool start: start flag
:return:
""" """
CoreNetwork.__init__(self, session=session, _id=_id, name=name, policy=policy, start=False) CoreNetwork.__init__(self, session=session, _id=_id, name=name, policy=policy, start=False)
self.grekey = key self.grekey = key
@ -685,7 +683,7 @@ class CtrlNet(CoreNetwork):
""" """
Creates a CtrlNet instance. Creates a CtrlNet instance.
:param core.session.Session session: core session instance :param core.emulator.session.Session session: core session instance
:param int _id: node id :param int _id: node id
:param str name: node namee :param str name: node namee
:param prefix: control network ipv4 prefix :param prefix: control network ipv4 prefix
@ -740,7 +738,7 @@ class CtrlNet(CoreNetwork):
def detectoldbridge(self): def detectoldbridge(self):
""" """
Occassionally, control net bridges from previously closed sessions are not cleaned up. Occasionally, control net bridges from previously closed sessions are not cleaned up.
Check if there are old control net bridges and delete them Check if there are old control net bridges and delete them
:return: True if an old bridge was detected, False otherwise :return: True if an old bridge was detected, False otherwise
@ -825,7 +823,7 @@ class PtpNet(CoreNetwork):
:param float lon: longitude :param float lon: longitude
:param float alt: altitude :param float alt: altitude
:return: node data object :return: node data object
:rtype: core.data.NodeData :rtype: core.emulator.data.NodeData
""" """
return None return None
@ -836,7 +834,7 @@ class PtpNet(CoreNetwork):
:param flags: message flags :param flags: message flags
:return: list of link data :return: list of link data
:rtype: list[core.data.LinkData] :rtype: list[core.emulator.data.LinkData]
""" """
all_links = [] all_links = []
@ -997,7 +995,7 @@ class WlanNode(CoreNetwork):
""" """
Attach a network interface. Attach a network interface.
:param core.netns.vif.VEth netif: network interface :param core.nodes.interface.CoreInterface netif: network interface
:return: nothing :return: nothing
""" """
CoreNetwork.attach(self, netif) CoreNetwork.attach(self, netif)
@ -1013,7 +1011,7 @@ class WlanNode(CoreNetwork):
""" """
Sets the mobility and wireless model. Sets the mobility and wireless model.
:param core.mobility.WirelessModel.cls model: wireless model to set to :param core.location.mobility.WirelessModel.cls model: wireless model to set to
:param dict config: configuration for model being set :param dict config: configuration for model being set
:return: nothing :return: nothing
""" """
@ -1056,7 +1054,7 @@ class WlanNode(CoreNetwork):
:param flags: message flags :param flags: message flags
:return: list of link data :return: list of link data
:rtype: list[core.data.LinkData] :rtype: list[core.emulator.data.LinkData]
""" """
all_links = CoreNetwork.all_link_data(self, flags) all_links = CoreNetwork.all_link_data(self, flags)

View file

@ -23,7 +23,7 @@ def _convert_map(x, y):
:param dict x: dictionary to reduce node items into :param dict x: dictionary to reduce node items into
:param tuple y: current node item :param tuple y: current node item
:return: :return: human readable name mapping of the node map
""" """
x[y[0].name] = y[1] x[y[0].name] = y[1]
return x return x
@ -33,7 +33,6 @@ def update_node_map(node_map):
""" """
Update the current node map with the provided node map values. Update the current node map with the provided node map values.
:param dict node_map: node map to update with :param dict node_map: node map to update with
""" """
global _NODE_MAP global _NODE_MAP
@ -70,7 +69,7 @@ def get_node_type(node_class):
:param class node_class: node class to get type for :param class node_class: node class to get type for
:return: node type :return: node type
:rtype: core.enumerations.NodeTypes :rtype: core.emulator.enumerations.NodeTypes
""" """
global _NODE_MAP global _NODE_MAP
node_type_map = {_NODE_MAP[x]: x for x in _NODE_MAP} node_type_map = {_NODE_MAP[x]: x for x in _NODE_MAP}

View file

@ -53,12 +53,11 @@ class OvsNet(CoreNetworkBase):
""" """
Creates an OvsNet instance. Creates an OvsNet instance.
:param core.session.Session session: session this object is a part of :param core.emulator.session.Session session: session this object is a part of
:param _id: :param int _id: object id
:param name: :param str name: object name
:param start: :param bool start: start flag
:param policy: :param policy: network policy
:return:
""" """
CoreNetworkBase.__init__(self, session, _id, name, start) CoreNetworkBase.__init__(self, session, _id, name, start)
@ -173,7 +172,7 @@ class OvsNet(CoreNetworkBase):
def link(self, interface_one, interface_two): def link(self, interface_one, interface_two):
""" """
Link two PyCoreNetIfs together, resulting in adding or removing Link two interfaces together, resulting in adding or removing
ebtables filtering rules. ebtables filtering rules.
""" """
with self._linked_lock: with self._linked_lock:
@ -299,19 +298,11 @@ class OvsNet(CoreNetworkBase):
interface = Veth(node=None, name=name, localname=localname, mtu=1500, net=self, start=self.up) interface = Veth(node=None, name=name, localname=localname, mtu=1500, net=self, start=self.up)
self.attach(interface) self.attach(interface)
if network.up: if network.up:
# this is similar to net.attach() but uses netif.name instead # this is similar to net.attach() but uses netif.name instead of localname
# of localname
utils.check_cmd([constants.OVS_BIN, "add-port", network.bridge_name, interface.name]) utils.check_cmd([constants.OVS_BIN, "add-port", network.bridge_name, interface.name])
utils.check_cmd([constants.IP_BIN, "link", "set", interface.name, "up"]) utils.check_cmd([constants.IP_BIN, "link", "set", interface.name, "up"])
# TODO: is there a native method for this? see if this causes issues
# i = network.newifindex()
# network._netif[i] = interface
# with network._linked_lock:
# network._linked[interface] = {}
# this method call is equal to the above, with a interface.netifi = call
network.attach(interface) network.attach(interface)
interface.net = self interface.net = self
interface.othernet = network interface.othernet = network
return interface return interface

View file

@ -99,7 +99,7 @@ class PhysicalNode(CoreNodeBase):
def sethwaddr(self, ifindex, addr): def sethwaddr(self, ifindex, addr):
""" """
same as SimpleLxcNode.sethwaddr() Set hardware address for an interface.
""" """
self._netif[ifindex].sethwaddr(addr) self._netif[ifindex].sethwaddr(addr)
ifname = self.ifname(ifindex) ifname = self.ifname(ifindex)
@ -108,7 +108,7 @@ class PhysicalNode(CoreNodeBase):
def addaddr(self, ifindex, addr): def addaddr(self, ifindex, addr):
""" """
same as SimpleLxcNode.addaddr() Add an address to an interface.
""" """
if self.up: if self.up:
self.check_cmd([constants.IP_BIN, "addr", "add", str(addr), "dev", self.ifname(ifindex)]) self.check_cmd([constants.IP_BIN, "addr", "add", str(addr), "dev", self.ifname(ifindex)])
@ -117,7 +117,7 @@ class PhysicalNode(CoreNodeBase):
def deladdr(self, ifindex, addr): def deladdr(self, ifindex, addr):
""" """
same as SimpleLxcNode.deladdr() Delete an address from an interface.
""" """
try: try:
self._netif[ifindex].deladdr(addr) self._netif[ifindex].deladdr(addr)
@ -258,7 +258,7 @@ class Rj45Node(CoreNodeBase, CoreInterface):
""" """
Create an RJ45Node instance. Create an RJ45Node instance.
:param core.session.Session session: core session instance :param core.emulator.session.Session session: core session instance
:param int _id: node id :param int _id: node id
:param str name: node name :param str name: node name
:param mtu: rj45 mtu :param mtu: rj45 mtu
@ -336,7 +336,7 @@ class Rj45Node(CoreNodeBase, CoreInterface):
represents an interface, we do not create another object here, represents an interface, we do not create another object here,
but attach ourselves to the given network. but attach ourselves to the given network.
:param core.coreobj.PyCoreNet net: new network instance :param core.nodes.base.CoreNetworkBase net: new network instance
:param list[str] addrlist: address list :param list[str] addrlist: address list
:param str hwaddr: hardware address :param str hwaddr: hardware address
:param int ifindex: interface index :param int ifindex: interface index
@ -392,7 +392,7 @@ class Rj45Node(CoreNodeBase, CoreInterface):
:param int ifindex: interface index to retrieve :param int ifindex: interface index to retrieve
:param net: network to retrieve :param net: network to retrieve
:return: a network interface :return: a network interface
:rtype: core.coreobj.PyCoreNetIf :rtype: core.nodes.interface,CoreInterface
""" """
if net is not None and net == self.net: if net is not None and net == self.net:
return self return self
@ -409,7 +409,7 @@ class Rj45Node(CoreNodeBase, CoreInterface):
""" """
Retrieve network interface index. Retrieve network interface index.
:param core.coreobj.PyCoreNetIf netif: network interface to retrieve index for :param core.nodes.interface.CoreInterface netif: network interface to retrieve index for
:return: interface index, None otherwise :return: interface index, None otherwise
:rtype: int :rtype: int
""" """

View file

@ -61,7 +61,7 @@ class Sdt(object):
""" """
Creates a Sdt instance. Creates a Sdt instance.
:param core.session.Session session: session this manager is tied to :param core.emulator.session.Session session: session this manager is tied to
""" """
self.session = session self.session = session
self.sock = None self.sock = None
@ -83,7 +83,7 @@ class Sdt(object):
""" """
Handler for node updates, specifically for updating their location. Handler for node updates, specifically for updating their location.
:param core.data.NodeData node_data: node data being updated :param core.emulator.data.NodeData node_data: node data being updated
:return: nothing :return: nothing
""" """
x = node_data.x_position x = node_data.x_position
@ -103,7 +103,7 @@ class Sdt(object):
""" """
Handler for link updates, checking for wireless link/unlink messages. Handler for link updates, checking for wireless link/unlink messages.
:param core.data.LinkData link_data: link data being updated :param core.emulator.data.LinkData link_data: link data being updated
:return: nothing :return: nothing
""" """
if link_data.link_type == LinkTypes.WIRELESS.value: if link_data.link_type == LinkTypes.WIRELESS.value:

View file

@ -125,7 +125,7 @@ class ServiceShim(object):
Convert service properties into a string list of key=value pairs, Convert service properties into a string list of key=value pairs,
separated by "|". separated by "|".
:param core.netns.vnode.CoreNode node: node to get value list for :param core.nodes.base.CoreNode node: node to get value list for
:param CoreService service: service to get value list for :param CoreService service: service to get value list for
:return: value list string :return: value list string
:rtype: str :rtype: str
@ -441,7 +441,7 @@ class CoreServices(object):
""" """
Start all service boot paths found, based on dependencies. Start all service boot paths found, based on dependencies.
:param core.netns.vnode.LxcNode node: node to start services on :param core.nodes.base.CoreNode node: node to start services on
:param list[CoreService] boot_path: service to start in dependent order :param list[CoreService] boot_path: service to start in dependent order
:return: nothing :return: nothing
""" """
@ -458,7 +458,7 @@ class CoreServices(object):
Start a service on a node. Create private dirs, generate config Start a service on a node. Create private dirs, generate config
files, and execute startup commands. files, and execute startup commands.
:param core.netns.vnode.LxcNode node: node to boot services on :param core.nodes.base.CoreNode node: node to boot services on
:param CoreService service: service to start :param CoreService service: service to start
:return: nothing :return: nothing
""" """
@ -511,7 +511,7 @@ class CoreServices(object):
config references an existing file that should be copied. config references an existing file that should be copied.
Returns True for local files, False for generated. Returns True for local files, False for generated.
:param core.netns.vnode.LxcNode node: node to copy service for :param core.nodes.base.CoreNode node: node to copy service for
:param str filename: file name for a configured service :param str filename: file name for a configured service
:param str cfg: configuration string :param str cfg: configuration string
:return: True if successful, False otherwise :return: True if successful, False otherwise
@ -530,7 +530,7 @@ class CoreServices(object):
""" """
Run the validation command(s) for a service. Run the validation command(s) for a service.
:param core.netns.vnode.LxcNode node: node to validate service for :param core.nodes.base.CoreNode node: node to validate service for
:param CoreService service: service to validate :param CoreService service: service to validate
:return: service validation status :return: service validation status
:rtype: int :rtype: int
@ -567,7 +567,7 @@ class CoreServices(object):
""" """
Stop a service on a node. Stop a service on a node.
:param core.netns.vnode.LxcNode node: node to stop a service on :param core.nodes.base.CoreNode node: node to stop a service on
:param CoreService service: service to stop :param CoreService service: service to stop
:return: status for stopping the services :return: status for stopping the services
:rtype: str :rtype: str
@ -586,7 +586,7 @@ class CoreServices(object):
Send a File Message when the GUI has requested a service file. Send a File Message when the GUI has requested a service file.
The file data is either auto-generated or comes from an existing config. The file data is either auto-generated or comes from an existing config.
:param core.netns.vnode.LxcNode node: node to get service file from :param core.nodes.base.CoreNode node: node to get service file from
:param str service_name: service to get file from :param str service_name: service to get file from
:param str filename: file name to retrieve :param str filename: file name to retrieve
:return: file message for node :return: file message for node
@ -655,7 +655,7 @@ class CoreServices(object):
""" """
Startup a node service. Startup a node service.
:param PyCoreNode node: node to reconfigure service for :param core.nodes.base.CoreNode node: node to reconfigure service for
:param CoreService service: service to reconfigure :param CoreService service: service to reconfigure
:param bool wait: determines if we should wait to validate startup :param bool wait: determines if we should wait to validate startup
:return: status of startup :return: status of startup
@ -682,7 +682,7 @@ class CoreServices(object):
""" """
Creates node service files. Creates node service files.
:param PyCoreNode node: node to reconfigure service for :param core.nodes.base.CoreNode node: node to reconfigure service for
:param CoreService service: service to reconfigure :param CoreService service: service to reconfigure
:return: nothing :return: nothing
""" """
@ -715,7 +715,7 @@ class CoreServices(object):
""" """
Reconfigure a node service. Reconfigure a node service.
:param PyCoreNode node: node to reconfigure service for :param core.nodes.base.CoreNode node: node to reconfigure service for
:param CoreService service: service to reconfigure :param CoreService service: service to reconfigure
:return: nothing :return: nothing
""" """
@ -805,7 +805,7 @@ class CoreService(object):
returns the cls._configs tuple, but this method may be overriden to returns the cls._configs tuple, but this method may be overriden to
provide node-specific filenames that may be based on other services. provide node-specific filenames that may be based on other services.
:param core.netns.vnode.LxcNode node: node to generate config for :param core.nodes.base.CoreNode node: node to generate config for
:return: configuration files :return: configuration files
:rtype: tuple :rtype: tuple
""" """
@ -819,7 +819,7 @@ class CoreService(object):
Return the configuration string to be written to a file or sent Return the configuration string to be written to a file or sent
to the GUI for customization. to the GUI for customization.
:param core.netns.vnode.LxcNode node: node to generate config for :param core.nodes.base.CoreNode node: node to generate config for
:param str filename: file name to generate config for :param str filename: file name to generate config for
:return: nothing :return: nothing
""" """
@ -833,7 +833,7 @@ class CoreService(object):
overridden to provide node-specific commands that may be overridden to provide node-specific commands that may be
based on other services. based on other services.
:param core.netns.vnode.LxcNode node: node to get startup for :param core.nodes.base.CoreNode node: node to get startup for
:return: startup commands :return: startup commands
:rtype: tuple :rtype: tuple
""" """
@ -847,7 +847,7 @@ class CoreService(object):
overridden to provide node-specific commands that may be overridden to provide node-specific commands that may be
based on other services. based on other services.
:param core.netns.vnode.LxcNode node: node to validate :param core.nodes.base.CoreNode node: node to validate
:return: validation commands :return: validation commands
:rtype: tuple :rtype: tuple
""" """

View file

@ -313,8 +313,8 @@ def expand_corepath(pathname, session=None, node=None):
Expand a file path given session information. Expand a file path given session information.
:param str pathname: file path to expand :param str pathname: file path to expand
:param core.session.Session session: core session object to expand path with :param core.emulator.session.Session session: core session object to expand path with
:param core.netns.LxcNode node: node to expand path with :param core.nodes.base.CoreNode node: node to expand path with
:return: expanded path :return: expanded path
:rtype: str :rtype: str
""" """