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

@ -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
@ -11,9 +11,10 @@ import signal
import socket
import string
import threading
from builtins import range
from socket import AF_INET, AF_INET6
from builtins import range
from core import CoreCommandError, utils
from core import constants
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.interface import TunTap, CoreInterface
from core.nodes.interface import Veth
from core.nodes.ipaddress import MacAddress
_DEFAULT_MTU = 1500
@ -39,7 +39,7 @@ class NodeBase(object):
"""
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 str name: object name
:param bool start: start value
@ -226,7 +226,7 @@ class CoreNodeBase(NodeBase):
"""
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 str name: object name
:param bool start: boolean for starting
@ -417,14 +417,6 @@ class CoreNodeBase(NodeBase):
class CoreNode(CoreNodeBase):
"""
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
valid_address_types = {"inet", "inet6", "inet6link"}
@ -433,7 +425,7 @@ class CoreNode(CoreNodeBase):
"""
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 str name: object name
:param str nodedir: node directory
@ -646,7 +638,7 @@ class CoreNode(CoreNodeBase):
:param int ifindex: index 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
"""
with self.lock:
@ -736,7 +728,7 @@ class CoreNode(CoreNodeBase):
Set hardware addres for an interface.
: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
:raises CoreCommandError: when a non-zero exit status occurs
"""
@ -819,9 +811,9 @@ class CoreNode(CoreNodeBase):
"""
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 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 str ifname: name for interface
:return: interface index
@ -864,7 +856,7 @@ class CoreNode(CoreNodeBase):
Connect a node.
: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
:return: nothing
"""
@ -970,9 +962,9 @@ class CoreNetworkBase(NodeBase):
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 str name: object name
:param bool start: should object start

View file

@ -1,8 +1,7 @@
"""
client.py: implementation of the VnodeClient class for issuing commands
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
by invoking the vcmd shell command.
The control channel can be accessed via calls using the vcmd shell.
"""
import logging
@ -124,8 +123,6 @@ class VnodeClient(object):
"""
self._verify_connection()
args = utils.split_args(args)
# if isinstance(args, list):
# args = " ".join(args)
cmd = self._cmd_args() + args
logging.info("popen: %s", cmd)
p = Popen(cmd, stdout=PIPE, stderr=PIPE, stdin=PIPE)

View file

@ -24,7 +24,7 @@ class CoreInterface(object):
"""
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 mtu: mtu value
"""
@ -67,7 +67,7 @@ class CoreInterface(object):
"""
Attach network.
:param core.coreobj.PyCoreNet net: network to attach
:param core.nodes.base.CoreNetworkBase net: network to attach
:return: nothing
"""
if self.net:
@ -109,7 +109,7 @@ class CoreInterface(object):
"""
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
"""
self.hwaddr = addr
@ -199,7 +199,7 @@ class Veth(CoreInterface):
"""
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 localname: interface local name
:param mtu: interface mtu
@ -260,11 +260,11 @@ class TunTap(CoreInterface):
"""
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 localname: local interface name
:param mtu: interface mtu
:param net: related network
:param core.nodes.base.CoreNetworkBase net: related network
:param bool start: start flag
"""
CoreInterface.__init__(self, node=node, name=name, mtu=mtu)
@ -420,9 +420,9 @@ class GreTap(CoreInterface):
"""
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 core.session.Session session: core session instance
:param core.emulator.session.Session session: core session instance
:param mtu: interface mtu
:param str remoteip: remote address
:param int _id: object id
@ -493,6 +493,6 @@ class GreTap(CoreInterface):
:param flags: link flags
:return: link data
:rtype: list[core.data.LinkData]
:rtype: list[core.emulator.data.LinkData]
"""
return []

View file

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

View file

@ -1,6 +1,5 @@
"""
PyCoreNet and LxBrNet classes that implement virtual networks using
Linux Ethernet bridging and ebtables rules.
Defines network nodes used within core.
"""
import logging
@ -343,7 +342,7 @@ class CoreNetwork(CoreNetworkBase):
"""
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
"""
if self.up:
@ -355,8 +354,8 @@ class CoreNetwork(CoreNetworkBase):
"""
Determine if the provided network interfaces are linked.
:param core.netns.vif.Veth netif1: interface one
:param core.netns.vif.Veth netif2: interface two
:param core.nodes.interface.CoreInterface netif1: interface one
:param core.nodes.interface.CoreInterface netif2: interface two
:return: True if interfaces are linked, False otherwise
:rtype: bool
"""
@ -385,8 +384,8 @@ class CoreNetwork(CoreNetworkBase):
Unlink two PyCoreNetIfs, resulting in adding or removing ebtables
filtering rules.
:param core.netns.vif.Veth netif1: interface one
:param core.netns.vif.Veth netif2: interface two
:param core.nodes.interface.CoreInterface netif1: interface one
:param core.nodes.interface.CoreInterface netif2: interface two
:return: nothing
"""
with self._linked_lock:
@ -401,8 +400,8 @@ class CoreNetwork(CoreNetworkBase):
Link two PyCoreNetIfs together, resulting in adding or removing
ebtables filtering rules.
:param core.netns.vif.Veth netif1: interface one
:param core.netns.vif.Veth netif2: interface two
:param core.nodes.interface.CoreInterface netif1: interface one
:param core.nodes.interface.CoreInterface netif2: interface two
:return: nothing
"""
with self._linked_lock:
@ -417,7 +416,7 @@ class CoreNetwork(CoreNetworkBase):
"""
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 delay: packet delay 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
(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
:rtype: core.netns.vnet.LxBrNet
:rtype: core.nodes.interface.CoreInterface
"""
for netif in self.netifs():
if hasattr(netif, "othernet") and netif.othernet == net:
@ -584,7 +583,7 @@ class GreTapBridge(CoreNetwork):
"""
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 int _id: object id
:param str name: object name
@ -593,7 +592,6 @@ class GreTapBridge(CoreNetwork):
:param ttl: ttl value
:param key: gre tap key
:param bool start: start flag
:return:
"""
CoreNetwork.__init__(self, session=session, _id=_id, name=name, policy=policy, start=False)
self.grekey = key
@ -685,7 +683,7 @@ class CtrlNet(CoreNetwork):
"""
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 str name: node namee
:param prefix: control network ipv4 prefix
@ -740,7 +738,7 @@ class CtrlNet(CoreNetwork):
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
:return: True if an old bridge was detected, False otherwise
@ -825,7 +823,7 @@ class PtpNet(CoreNetwork):
:param float lon: longitude
:param float alt: altitude
:return: node data object
:rtype: core.data.NodeData
:rtype: core.emulator.data.NodeData
"""
return None
@ -836,7 +834,7 @@ class PtpNet(CoreNetwork):
:param flags: message flags
:return: list of link data
:rtype: list[core.data.LinkData]
:rtype: list[core.emulator.data.LinkData]
"""
all_links = []
@ -997,7 +995,7 @@ class WlanNode(CoreNetwork):
"""
Attach a network interface.
:param core.netns.vif.VEth netif: network interface
:param core.nodes.interface.CoreInterface netif: network interface
:return: nothing
"""
CoreNetwork.attach(self, netif)
@ -1013,7 +1011,7 @@ class WlanNode(CoreNetwork):
"""
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
:return: nothing
"""
@ -1056,7 +1054,7 @@ class WlanNode(CoreNetwork):
:param flags: message flags
:return: list of link data
:rtype: list[core.data.LinkData]
:rtype: list[core.emulator.data.LinkData]
"""
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 tuple y: current node item
:return:
:return: human readable name mapping of the node map
"""
x[y[0].name] = y[1]
return x
@ -33,7 +33,6 @@ def update_node_map(node_map):
"""
Update the current node map with the provided node map values.
:param dict node_map: node map to update with
"""
global _NODE_MAP
@ -70,7 +69,7 @@ def get_node_type(node_class):
:param class node_class: node class to get type for
:return: node type
:rtype: core.enumerations.NodeTypes
:rtype: core.emulator.enumerations.NodeTypes
"""
global _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.
:param core.session.Session session: session this object is a part of
:param _id:
:param name:
:param start:
:param policy:
:return:
:param core.emulator.session.Session session: session this object is a part of
:param int _id: object id
:param str name: object name
:param bool start: start flag
:param policy: network policy
"""
CoreNetworkBase.__init__(self, session, _id, name, start)
@ -173,7 +172,7 @@ class OvsNet(CoreNetworkBase):
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.
"""
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)
self.attach(interface)
if network.up:
# this is similar to net.attach() but uses netif.name instead
# of localname
# this is similar to net.attach() but uses netif.name instead of localname
utils.check_cmd([constants.OVS_BIN, "add-port", network.bridge_name, interface.name])
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)
interface.net = self
interface.othernet = network
return interface

View file

@ -99,7 +99,7 @@ class PhysicalNode(CoreNodeBase):
def sethwaddr(self, ifindex, addr):
"""
same as SimpleLxcNode.sethwaddr()
Set hardware address for an interface.
"""
self._netif[ifindex].sethwaddr(addr)
ifname = self.ifname(ifindex)
@ -108,7 +108,7 @@ class PhysicalNode(CoreNodeBase):
def addaddr(self, ifindex, addr):
"""
same as SimpleLxcNode.addaddr()
Add an address to an interface.
"""
if self.up:
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):
"""
same as SimpleLxcNode.deladdr()
Delete an address from an interface.
"""
try:
self._netif[ifindex].deladdr(addr)
@ -258,7 +258,7 @@ class Rj45Node(CoreNodeBase, CoreInterface):
"""
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 str name: node name
:param mtu: rj45 mtu
@ -336,7 +336,7 @@ class Rj45Node(CoreNodeBase, CoreInterface):
represents an interface, we do not create another object here,
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 str hwaddr: hardware address
:param int ifindex: interface index
@ -392,7 +392,7 @@ class Rj45Node(CoreNodeBase, CoreInterface):
:param int ifindex: interface index to retrieve
:param net: network to retrieve
:return: a network interface
:rtype: core.coreobj.PyCoreNetIf
:rtype: core.nodes.interface,CoreInterface
"""
if net is not None and net == self.net:
return self
@ -409,7 +409,7 @@ class Rj45Node(CoreNodeBase, CoreInterface):
"""
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
:rtype: int
"""