initial refactor for all variables named objid

This commit is contained in:
bharnden 2019-04-26 22:07:51 -07:00
parent f283c747cc
commit 9517740704
46 changed files with 346 additions and 353 deletions

View file

@ -413,15 +413,14 @@ class CoreBroker(object):
if key in self.tunnels.keys():
logging.warn("tunnel with key %s (%s-%s) already exists!", key, n1num, n2num)
else:
objid = key & ((1 << 16) - 1)
_id = key & ((1 << 16) - 1)
logging.info("adding tunnel for %s-%s to %s with key %s", n1num, n2num, remoteip, key)
if localnum in self.physical_nodes:
# no bridge is needed on physical nodes; use the GreTap directly
gt = GreTap(node=None, name=None, session=self.session,
remoteip=remoteip, key=key)
else:
gt = self.session.add_object(cls=GreTapBridge, objid=objid,
policy="ACCEPT", remoteip=remoteip, key=key)
gt = self.session.add_object(cls=GreTapBridge, _id=_id, policy="ACCEPT", remoteip=remoteip, key=key)
gt.localnum = localnum
gt.remotenum = remotenum
self.tunnels[key] = gt
@ -518,7 +517,7 @@ class CoreBroker(object):
except KeyError:
gt = None
if gt:
self.session.delete_object(gt.objid)
self.session.delete_object(gt.id)
del gt
def gettunnel(self, n1num, n2num):

View file

@ -369,9 +369,9 @@ class ModelManager(ConfigurableManager):
:param dict config: model configuration, None for default configuration
:return: nothing
"""
logging.info("setting mobility model(%s) for node(%s): %s", model_class.name, node.objid, config)
self.set_model_config(node.objid, model_class.name, config)
config = self.get_model_config(node.objid, model_class.name)
logging.info("setting mobility model(%s) for node(%s): %s", model_class.name, node.id, config)
self.set_model_config(node.id, model_class.name, config)
config = self.get_model_config(node.id, model_class.name)
node.setmodel(model_class, config)
def get_models(self, node):
@ -383,7 +383,7 @@ class ModelManager(ConfigurableManager):
:return: list of model and values tuples for the network node
:rtype: list
"""
all_configs = self.get_all_configs(node.objid)
all_configs = self.get_all_configs(node.id)
if not all_configs:
all_configs = {}
@ -394,5 +394,5 @@ class ModelManager(ConfigurableManager):
model_class = self.models[model_name]
models.append((model_class, config))
logging.debug("models for node(%s): %s", node.objid, models)
logging.debug("models for node(%s): %s", node.id, models)
return models

View file

@ -670,10 +670,10 @@ class CoreHandler(SocketServer.BaseRequestHandler):
node = self.session.add_node(node_type, node_id, node_options)
if node:
if message.flags & MessageFlags.STRING.value:
self.node_status_request[node.objid] = True
self.node_status_request[node.id] = True
if self.session.state == EventTypes.RUNTIME_STATE.value:
self.send_node_emulation_id(node.objid)
self.send_node_emulation_id(node.id)
elif message.flags & MessageFlags.DELETE.value:
with self._shutdown_lock:
result = self.session.delete_node(node_id)
@ -1424,7 +1424,7 @@ class CoreHandler(SocketServer.BaseRequestHandler):
# configure mobility models for WLAN added during runtime
if event_type == EventTypes.INSTANTIATION_STATE and nodeutils.is_node(node, NodeTypes.WIRELESS_LAN):
self.session.start_mobility(node_ids=(node.objid,))
self.session.start_mobility(node_ids=(node.id,))
return ()
logging.warn("dropping unhandled Event message with node number")
@ -1442,8 +1442,8 @@ class CoreHandler(SocketServer.BaseRequestHandler):
self.session.instantiate()
# after booting nodes attempt to send emulation id for nodes waiting on status
for obj in self.session.objects.itervalues():
self.send_node_emulation_id(obj.objid)
for _id in self.session.objects:
self.send_node_emulation_id(_id)
elif event_type == EventTypes.RUNTIME_STATE:
if self.session.master:
logging.warn("Unexpected event message: RUNTIME state received at session master")

View file

@ -67,23 +67,23 @@ class PyCoreObj(object):
apitype = None
# TODO: appears start has no usage, verify and remove
def __init__(self, session, objid=None, name=None, start=True):
def __init__(self, session, _id=None, name=None, start=True):
"""
Creates a PyCoreObj instance.
:param core.session.Session session: CORE session object
:param int objid: object id
:param int _id: id
:param str name: object name
:param bool start: start value
:return:
"""
self.session = session
if objid is None:
objid = session.get_object_id()
self.objid = objid
if _id is None:
_id = session.get_node_id()
self.id = _id
if name is None:
name = "o%s" % self.objid
name = "o%s" % self.id
self.name = name
self.type = None
self.server = None
@ -217,10 +217,10 @@ class PyCoreObj(object):
node_data = NodeData(
message_type=message_type,
id=self.objid,
id=self.id,
node_type=self.apitype,
name=self.name,
emulation_id=self.objid,
emulation_id=self.id,
canvas=self.canvas,
icon=self.icon,
opaque=self.opaque,
@ -254,16 +254,16 @@ class PyCoreNode(PyCoreObj):
Base class for CORE nodes.
"""
def __init__(self, session, objid=None, name=None, start=True):
def __init__(self, session, _id=None, name=None, start=True):
"""
Create a PyCoreNode instance.
:param core.session.Session session: CORE session object
:param int objid: object id
:param int _id: object id
:param str name: object name
:param bool start: boolean for starting
"""
super(PyCoreNode, self).__init__(session, objid, name, start=start)
super(PyCoreNode, self).__init__(session, _id, name, start=start)
self.services = []
self.nodedir = None
self.tmpnodedir = False
@ -452,16 +452,16 @@ class PyCoreNet(PyCoreObj):
"""
linktype = LinkTypes.WIRED.value
def __init__(self, session, objid, name, start=True):
def __init__(self, session, _id, name, start=True):
"""
Create a PyCoreNet instance.
:param core.session.Session session: CORE session object
:param int objid: object id
:param int _id: object id
:param str name: object name
:param bool start: should object start
"""
super(PyCoreNet, self).__init__(session, objid, name, start=start)
super(PyCoreNet, self).__init__(session, _id, name, start=start)
self._linked = {}
self._linked_lock = threading.Lock()
@ -518,14 +518,14 @@ class PyCoreNet(PyCoreObj):
for netif in self.netifs(sort=True):
if not hasattr(netif, "node"):
continue
otherobj = netif.node
linked_node = netif.node
uni = False
if otherobj is None:
if linked_node is None:
# two layer-2 switches/hubs linked together via linknet()
if not hasattr(netif, "othernet"):
continue
otherobj = netif.othernet
if otherobj.objid == self.objid:
linked_node = netif.othernet
if linked_node.id == self.id:
continue
netif.swapparams('_params_up')
upstream_params = netif.getparams()
@ -557,11 +557,11 @@ class PyCoreNet(PyCoreObj):
link_data = LinkData(
message_type=flags,
node1_id=self.objid,
node2_id=otherobj.objid,
node1_id=self.id,
node2_id=linked_node.id,
link_type=self.linktype,
unidirectional=unidirectional,
interface2_id=otherobj.getifindex(netif),
interface2_id=linked_node.getifindex(netif),
interface2_mac=netif.hwaddr,
interface2_ip4=interface2_ip4,
interface2_ip4_mask=interface2_ip4_mask,
@ -582,8 +582,8 @@ class PyCoreNet(PyCoreObj):
netif.swapparams('_params_up')
link_data = LinkData(
message_type=0,
node1_id=otherobj.objid,
node2_id=self.objid,
node1_id=linked_node.id,
node2_id=self.id,
unidirectional=1,
delay=netif.getparam("delay"),
bandwidth=netif.getparam("bw"),

View file

@ -109,14 +109,14 @@ class EmaneManager(ModelManager):
return self.get_configs(node_id=node_id, config_type=model_name)
else:
# don"t use default values when interface config is the same as net
# note here that using ifc.node.objid as key allows for only one type
# note here that using ifc.node.id as key allows for only one type
# of each model per node;
# TODO: use both node and interface as key
# Adamson change: first check for iface config keyed by "node:ifc.name"
# (so that nodes w/ multiple interfaces of same conftype can have
# different configs for each separate interface)
key = 1000 * interface.node.objid
key = 1000 * interface.node.id
if interface.netindex is not None:
key += interface.netindex
@ -125,7 +125,7 @@ class EmaneManager(ModelManager):
# otherwise retrieve the interfaces node configuration, avoid using defaults
if not config:
config = self.get_configs(node_id=interface.node.objid, config_type=model_name)
config = self.get_configs(node_id=interface.node.id, config_type=model_name)
# get non interface config, when none found
if not config:
@ -225,9 +225,9 @@ class EmaneManager(ModelManager):
:return: nothing
"""
with self._emane_node_lock:
if emane_node.objid in self._emane_nodes:
raise KeyError("non-unique EMANE object id %s for %s" % (emane_node.objid, emane_node))
self._emane_nodes[emane_node.objid] = emane_node
if emane_node.id in self._emane_nodes:
raise KeyError("non-unique EMANE object id %s for %s" % (emane_node.id, emane_node))
self._emane_nodes[emane_node.id] = emane_node
def getnodes(self):
"""
@ -254,7 +254,7 @@ class EmaneManager(ModelManager):
with self.session._objects_lock:
for node in self.session.objects.itervalues():
if nodeutils.is_node(node, NodeTypes.EMANE):
logging.debug("adding emane node: id(%s) name(%s)", node.objid, node.name)
logging.debug("adding emane node: id(%s) name(%s)", node.id, node.name)
self.add_node(node)
if not self._emane_nodes:
@ -345,7 +345,7 @@ class EmaneManager(ModelManager):
with self._emane_node_lock:
for key in sorted(self._emane_nodes.keys()):
emane_node = self._emane_nodes[key]
logging.debug("post startup for emane node: %s - %s", emane_node.objid, emane_node.name)
logging.debug("post startup for emane node: %s - %s", emane_node.id, emane_node.name)
emane_node.model.post_startup()
for netif in emane_node.netifs():
x, y, z = netif.node.position.get()
@ -517,7 +517,7 @@ class EmaneManager(ModelManager):
# skip nodes that already have a model set
if emane_node.model:
logging.debug("node(%s) already has model(%s)", emane_node.objid, emane_node.model.name)
logging.debug("node(%s) already has model(%s)", emane_node.id, emane_node.model.name)
continue
# set model configured for node, due to legacy messaging configuration before nodes exist
@ -644,7 +644,7 @@ class EmaneManager(ModelManager):
run_emane_on_host = True
continue
path = self.session.session_dir
n = node.objid
n = node.id
# control network not yet started here
self.session.add_remove_control_interface(node, 0, remove=False, conf_required=False)
@ -828,7 +828,7 @@ class EmaneManager(ModelManager):
logging.info("location event for unknown NEM %s", nemid)
return False
n = netif.node.objid
n = netif.node.id
# convert from lat/long/alt to x,y,z coordinates
x, y, z = self.session.location.getxyz(lat, lon, alt)
x = int(x)

View file

@ -37,8 +37,8 @@ class EmaneNode(EmaneNet):
Emane controller object that exists in a session.
"""
def __init__(self, session, objid=None, name=None, start=True):
super(EmaneNode, self).__init__(session, objid, name, start)
def __init__(self, session, _id=None, name=None, start=True):
super(EmaneNode, self).__init__(session, _id, name, start)
self.conf = ""
self.up = False
self.nemidmap = {}
@ -68,9 +68,9 @@ class EmaneNode(EmaneNet):
def updatemodel(self, config):
if not self.model:
raise ValueError("no model set to update for node(%s)", self.objid)
logging.info("node(%s) updating model(%s): %s", self.objid, self.model.name, config)
self.model.set_configs(config, node_id=self.objid)
raise ValueError("no model set to update for node(%s)", self.id)
logging.info("node(%s) updating model(%s): %s", self.id, self.model.name, config)
self.model.set_configs(config, node_id=self.id)
def setmodel(self, model, config):
"""
@ -80,10 +80,10 @@ class EmaneNode(EmaneNet):
if model.config_type == RegisterTlvs.WIRELESS.value:
# EmaneModel really uses values from ConfigurableManager
# when buildnemxml() is called, not during init()
self.model = model(session=self.session, object_id=self.objid)
self.model = model(session=self.session, object_id=self.id)
self.model.update_config(config)
elif model.config_type == RegisterTlvs.MOBILITY.value:
self.mobility = model(session=self.session, object_id=self.objid)
self.mobility = model(session=self.session, object_id=self.id)
self.mobility.update_config(config)
def setnemid(self, netif, nemid):
@ -116,7 +116,7 @@ class EmaneNode(EmaneNet):
"""
Retrieve list of linked interfaces sorted by node number.
"""
return sorted(self._netif.values(), key=lambda ifc: ifc.node.objid)
return sorted(self._netif.values(), key=lambda ifc: ifc.node.id)
def installnetifs(self):
"""
@ -130,7 +130,7 @@ class EmaneNode(EmaneNet):
logging.error(warntxt)
for netif in self.netifs():
external = self.session.emane.get_config("external", self.objid, self.model.name)
external = self.session.emane.get_config("external", self.id, self.model.name)
if external == "0":
netif.setaddrs()

View file

@ -366,7 +366,7 @@ class EmuSession(Session):
interface_one.detachnet()
interface_two.detachnet()
if net_one.numnetif() == 0:
self.delete_object(net_one.objid)
self.delete_object(net_one.id)
node_one.delnetif(interface_one.netindex)
node_two.delnetif(interface_two.netindex)
finally:
@ -493,7 +493,7 @@ class EmuSession(Session):
# create node
logging.info("creating node(%s) id(%s) name(%s) start(%s)", node_class.__name__, _id, name, start)
node = self.add_object(cls=node_class, objid=_id, name=name, start=start)
node = self.add_object(cls=node_class, _id=_id, name=name, start=start)
# set node attributes
node.icon = node_options.icon
@ -599,7 +599,7 @@ class EmuSession(Session):
"""
node_data = NodeData(
message_type=0,
id=node.objid,
id=node.id,
x_position=node.position.x,
y_position=node.position.y
)

View file

@ -117,7 +117,7 @@ class IpPrefixes(object):
"""
if not self.ip4:
raise ValueError("ip4 prefixes have not been set")
return str(self.ip4.addr(node.objid))
return str(self.ip4.addr(node.id))
def ip6_address(self, node):
"""
@ -129,7 +129,7 @@ class IpPrefixes(object):
"""
if not self.ip6:
raise ValueError("ip6 prefixes have not been set")
return str(self.ip6.addr(node.objid))
return str(self.ip6.addr(node.id))
def create_interface(self, node, name=None, mac=None):
"""
@ -149,14 +149,14 @@ class IpPrefixes(object):
ip4 = None
ip4_mask = None
if self.ip4:
ip4 = str(self.ip4.addr(node.objid))
ip4 = str(self.ip4.addr(node.id))
ip4_mask = self.ip4.prefixlen
# generate ip6 data
ip6 = None
ip6_mask = None
if self.ip6:
ip6 = str(self.ip6.addr(node.objid))
ip6 = str(self.ip6.addr(node.id))
ip6_mask = self.ip6.prefixlen
# random mac

View file

@ -235,7 +235,7 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
nodes = []
for node_id in session.objects:
node = session.objects[node_id]
if not isinstance(node.objid, int):
if not isinstance(node.id, int):
continue
node_type = nodeutils.get_node_type(node.__class__).value
@ -252,7 +252,7 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
emane_model = node.model.name
node_proto = core_pb2.Node(
id=node.objid, name=node.name, emane=emane_model, model=model,
id=node.id, name=node.name, emane=emane_model, model=model,
type=node_type, position=position, services=services)
nodes.append(node_proto)
@ -457,7 +457,7 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
if emane_model:
session.emane.set_model_config(node_id, emane_model)
return core_pb2.AddNodeResponse(id=node.objid)
return core_pb2.AddNodeResponse(id=node.id)
def GetNode(self, request, context):
logging.debug("get node: %s", request)
@ -468,7 +468,7 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
for interface_id, interface in node._netif.iteritems():
net_id = None
if interface.net:
net_id = interface.net.objid
net_id = interface.net.id
interface_proto = core_pb2.Interface(
id=interface_id, netid=net_id, name=interface.name, mac=str(interface.hwaddr),
mtu=interface.mtu, flowid=interface.flow_id)
@ -482,7 +482,7 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
position = core_pb2.Position(x=node.position.x, y=node.position.y, z=node.position.z)
node_type = nodeutils.get_node_type(node.__class__).value
node = core_pb2.Node(
id=node.objid, name=node.name, type=node_type, emane=emane_model, model=node.type, position=position,
id=node.id, name=node.name, type=node_type, emane=emane_model, model=node.type, position=position,
services=services)
return core_pb2.GetNodeResponse(node=node, interfaces=interfaces)

View file

@ -324,7 +324,7 @@ def expand_corepath(pathname, session=None, node=None):
pathname = pathname.replace("%SESSION_USER%", session.user)
if node is not None:
pathname = pathname.replace("%NODE%", str(node.objid))
pathname = pathname.replace("%NODE%", str(node.id))
pathname = pathname.replace("%NODENAME%", node.name)
return pathname

View file

@ -187,7 +187,7 @@ class MobilityManager(ModelManager):
:param core.coreobj.PyCoreNode node: node to add physical network to
:return: nothing
"""
node_id = node.objid
node_id = node.id
self.phys[node_id] = node
if netnum not in self.physnets:
self.physnets[netnum] = [node_id, ]
@ -213,7 +213,7 @@ class MobilityManager(ModelManager):
return
if nn[1] in self.session.broker.physical_nodes:
# record the fact that this PhysicalNode is linked to a net
dummy = PyCoreNode(session=self.session, objid=nn[1], name="n%d" % nn[1], start=False)
dummy = PyCoreNode(session=self.session, _id=nn[1], name="n%d" % nn[1], start=False)
self.addphys(nn[0], dummy)
# TODO: remove need to handling old style messages
@ -243,13 +243,13 @@ class MobilityManager(ModelManager):
:param net: network to install
:return: nothing
"""
nodenums = self.physnets.get(net.objid, [])
for nodenum in nodenums:
node = self.phys[nodenum]
node_ids = self.physnets.get(net.id, [])
for node_id in node_ids:
node = self.phys[node_id]
# TODO: fix this bad logic, relating to depending on a break to get a valid server
for server in self.session.broker.getserversbynode(nodenum):
for server in self.session.broker.getserversbynode(node_id):
break
netif = self.session.broker.gettunnel(net.objid, IpAddress.to_int(server.host))
netif = self.session.broker.gettunnel(net.id, IpAddress.to_int(server.host))
node.addnetif(netif, 0)
netif.node = node
x, y, z = netif.node.position.get()
@ -357,7 +357,7 @@ class BasicRangeModel(WirelessModel):
:return: nothing
"""
self.range = float(config["range"])
logging.info("basic range model configured for WLAN %d using range %d", self.wlan.objid, self.range)
logging.info("basic range model configured for WLAN %d using range %d", self.wlan.id, self.range)
self.bw = int(config["bandwidth"])
if self.bw == 0.0:
self.bw = None
@ -521,9 +521,9 @@ class BasicRangeModel(WirelessModel):
"""
return LinkData(
message_type=message_type,
node1_id=interface1.node.objid,
node2_id=interface2.node.objid,
network_id=self.wlan.objid,
node1_id=interface1.node.id,
node2_id=interface2.node.id,
network_id=self.wlan.id,
link_type=LinkTypes.WIRELESS.value
)
@ -705,15 +705,15 @@ class WayPointMobility(WirelessModel):
:return: True if node was moved, False otherwise
:rtype: bool
"""
if node.objid not in self.points:
if node.id not in self.points:
return False
x1, y1, z1 = node.getposition()
x2, y2, z2 = self.points[node.objid].coords
speed = self.points[node.objid].speed
x2, y2, z2 = self.points[node.id].coords
speed = self.points[node.id].speed
# instantaneous move (prevents dx/dy == 0.0 below)
if speed == 0:
self.setnodeposition(node, x2, y2, z2)
del self.points[node.objid]
del self.points[node.id]
return True
# speed can be a velocity vector (ns3 mobility) or speed value
if isinstance(speed, (float, int)):
@ -739,7 +739,7 @@ class WayPointMobility(WirelessModel):
# the last node to reach the last waypoint determines this
# script's endtime
self.endtime = self.lasttime - self.timezero
del self.points[node.objid]
del self.points[node.id]
return False
if (x1 + dx) < 0.0:
dx = 0.0 - x1
@ -758,9 +758,9 @@ class WayPointMobility(WirelessModel):
moved_netifs = []
for netif in self.wlan.netifs():
node = netif.node
if node.objid not in self.initial:
if node.id not in self.initial:
continue
x, y, z = self.initial[node.objid].coords
x, y, z = self.initial[node.id].coords
self.setnodeposition(node, x, y, z)
moved.append(node)
moved_netifs.append(netif)

View file

@ -39,14 +39,14 @@ class CtrlNet(LxBrNet):
"172.19.0.0/24 172.19.1.0/24 172.19.2.0/24 172.19.3.0/24 172.19.4.0/24"
]
def __init__(self, session, objid="ctrlnet", name=None, prefix=None,
def __init__(self, session, _id="ctrlnet", name=None, prefix=None,
hostid=None, start=True, assign_address=True,
updown_script=None, serverintf=None):
"""
Creates a CtrlNet instance.
:param core.session.Session session: core session instance
:param int objid: node id
:param int _id: node id
:param str name: node namee
:param prefix: control network ipv4 prefix
:param hostid: host id
@ -61,7 +61,7 @@ class CtrlNet(LxBrNet):
self.assign_address = assign_address
self.updown_script = updown_script
self.serverintf = serverintf
LxBrNet.__init__(self, session, objid=objid, name=name, start=start)
LxBrNet.__init__(self, session, _id=_id, name=name, start=start)
def startup(self):
"""
@ -116,7 +116,7 @@ class CtrlNet(LxBrNet):
oldbr = cols[0]
flds = cols[0].split(".")
if len(flds) == 3:
if flds[0] == "b" and flds[1] == self.objid:
if flds[0] == "b" and flds[1] == self.id:
logging.error(
"error: An active control net bridge (%s) found. "
"An older session might still be running. "
@ -255,8 +255,8 @@ class PtpNet(LxBrNet):
link_data = LinkData(
message_type=flags,
node1_id=if1.node.objid,
node2_id=if2.node.objid,
node1_id=if1.node.id,
node2_id=if2.node.id,
link_type=self.linktype,
unidirectional=unidirectional,
delay=if1.getparam("delay"),
@ -284,8 +284,8 @@ class PtpNet(LxBrNet):
if unidirectional:
link_data = LinkData(
message_type=0,
node1_id=if2.node.objid,
node2_id=if1.node.objid,
node1_id=if2.node.id,
node2_id=if1.node.id,
delay=if1.getparam("delay"),
bandwidth=if1.getparam("bw"),
dup=if1.getparam("duplicate"),
@ -317,17 +317,17 @@ class HubNode(LxBrNet):
policy = "ACCEPT"
type = "hub"
def __init__(self, session, objid=None, name=None, start=True):
def __init__(self, session, _id=None, name=None, start=True):
"""
Creates a HubNode instance.
:param core.session.Session session: core session instance
:param int objid: node id
:param int _id: node id
:param str name: node namee
:param bool start: start flag
:raises CoreCommandError: when there is a command exception
"""
LxBrNet.__init__(self, session, objid, name, start)
LxBrNet.__init__(self, session, _id, name, start)
# TODO: move to startup method
if start:
@ -343,17 +343,17 @@ class WlanNode(LxBrNet):
policy = "DROP"
type = "wlan"
def __init__(self, session, objid=None, name=None, start=True, policy=None):
def __init__(self, session, _id=None, name=None, start=True, policy=None):
"""
Create a WlanNode instance.
:param core.session.Session session: core session instance
:param int objid: node id
:param int _id: node id
:param str name: node name
:param bool start: start flag
:param policy: wlan policy
"""
LxBrNet.__init__(self, session, objid, name, start, policy)
LxBrNet.__init__(self, session, _id, name, start, policy)
# wireless model such as basic range
self.model = None
# mobility model such as scripted
@ -385,7 +385,7 @@ class WlanNode(LxBrNet):
"""
logging.info("adding model: %s", model.name)
if model.config_type == RegisterTlvs.WIRELESS.value:
self.model = model(session=self.session, object_id=self.objid)
self.model = model(session=self.session, object_id=self.id)
self.model.update_config(config)
if self.model.position_callback:
for netif in self.netifs():
@ -395,19 +395,19 @@ class WlanNode(LxBrNet):
netif.poshook(netif, x, y, z)
self.model.setlinkparams()
elif model.config_type == RegisterTlvs.MOBILITY.value:
self.mobility = model(session=self.session, object_id=self.objid)
self.mobility = model(session=self.session, object_id=self.id)
self.mobility.update_config(config)
def update_mobility(self, config):
if not self.mobility:
raise ValueError("no mobility set to update for node(%s)", self.objid)
self.mobility.set_configs(config, node_id=self.objid)
raise ValueError("no mobility set to update for node(%s)", self.id)
self.mobility.set_configs(config, node_id=self.id)
def updatemodel(self, config):
if not self.model:
raise ValueError("no model set to update for node(%s)", self.objid)
logging.info("node(%s) updating model(%s): %s", self.objid, self.model.name, config)
self.model.set_configs(config, node_id=self.objid)
raise ValueError("no model set to update for node(%s)", self.id)
logging.info("node(%s) updating model(%s): %s", self.id, self.model.name, config)
self.model.set_configs(config, node_id=self.id)
if self.model.position_callback:
for netif in self.netifs():
netif.poshook = self.model.position_callback
@ -440,18 +440,18 @@ class RJ45Node(PyCoreNode, PyCoreNetIf):
apitype = NodeTypes.RJ45.value
type = "rj45"
def __init__(self, session, objid=None, name=None, mtu=1500, start=True):
def __init__(self, session, _id=None, name=None, mtu=1500, start=True):
"""
Create an RJ45Node instance.
:param core.session.Session session: core session instance
:param int objid: node id
:param int _id: node id
:param str name: node name
:param mtu: rj45 mtu
:param bool start: start flag
:return:
"""
PyCoreNode.__init__(self, session, objid, name, start=start)
PyCoreNode.__init__(self, session, _id, name, start=start)
PyCoreNetIf.__init__(self, node=self, name=name, mtu=mtu)
self.up = False
self.lock = threading.RLock()

View file

@ -50,19 +50,19 @@ class OvsNet(PyCoreNet):
policy = "DROP"
def __init__(self, session, objid=None, name=None, start=True, policy=None):
def __init__(self, session, _id=None, name=None, start=True, policy=None):
"""
Creates an OvsNet instance.
:param core.session.Session session: session this object is a part of
:param objid:
:param _id:
:param name:
:param start:
:param policy:
:return:
"""
PyCoreNet.__init__(self, session, objid, name, start)
PyCoreNet.__init__(self, session, _id, name, start)
if policy:
self.policy = policy
@ -70,7 +70,7 @@ class OvsNet(PyCoreNet):
self.policy = self.__class__.policy
session_id = self.session.short_session_id()
self.bridge_name = "b.%s.%s" % (str(self.objid), session_id)
self.bridge_name = "b.%s.%s" % (str(self.id), session_id)
self.up = False
if start:
@ -279,21 +279,21 @@ class OvsNet(PyCoreNet):
session_id = self.session.short_session_id()
try:
self_objid = "%x" % self.objid
_id = "%x" % self.id
except TypeError:
self_objid = "%s" % self.objid
_id = "%s" % self.id
try:
net_objid = "%x" % network.objid
network_id = "%x" % network.id
except TypeError:
net_objid = "%s" % network.objid
network_id = "%s" % network.id
localname = "veth%s.%s.%s" % (self_objid, net_objid, session_id)
localname = "veth%s.%s.%s" % (_id, network_id, session_id)
if len(localname) >= 16:
raise ValueError("interface local name %s too long" % localname)
name = "veth%s.%s.%s" % (net_objid, self_objid, session_id)
name = "veth%s.%s.%s" % (network_id, _id, session_id)
if len(name) >= 16:
raise ValueError("interface name %s too long" % name)
@ -349,14 +349,14 @@ class OvsCtrlNet(OvsNet):
"172.19.0.0/24 172.19.1.0/24 172.19.2.0/24 172.19.3.0/24 172.19.4.0/24"
]
def __init__(self, session, objid="ctrlnet", name=None, prefix=None, hostid=None,
def __init__(self, session, _id="ctrlnet", name=None, prefix=None, hostid=None,
start=True, assign_address=True, updown_script=None, serverintf=None):
self.prefix = ipaddress.Ipv4Prefix(prefix)
self.hostid = hostid
self.assign_address = assign_address
self.updown_script = updown_script
self.serverintf = serverintf
OvsNet.__init__(self, session, objid=objid, name=name, start=start)
OvsNet.__init__(self, session, _id=_id, name=name, start=start)
def startup(self):
if self.detectoldbridge():
@ -394,7 +394,7 @@ class OvsCtrlNet(OvsNet):
if output:
for line in output.split("\n"):
bride_name = line.split(".")
if bride_name[0] == "b" and bride_name[1] == self.objid:
if bride_name[0] == "b" and bride_name[1] == self.id:
logging.error("older session may still be running with conflicting id for bridge: %s", line)
return True
@ -495,8 +495,8 @@ class OvsPtpNet(OvsNet):
# loss=netif.getparam("loss")
link_data = LinkData(
message_type=flags,
node1_id=if1.node.objid,
node2_id=if2.node.objid,
node1_id=if1.node.id,
node2_id=if2.node.id,
link_type=self.linktype,
unidirectional=unidirectional,
delay=if1.getparam("delay"),
@ -524,8 +524,8 @@ class OvsPtpNet(OvsNet):
if unidirectional:
link_data = LinkData(
message_type=0,
node1_id=if2.node.objid,
node2_id=if1.node.objid,
node1_id=if2.node.id,
node2_id=if1.node.id,
delay=if1.getparam("delay"),
bandwidth=if1.getparam("bw"),
dup=if1.getparam("duplicate"),
@ -550,12 +550,12 @@ class OvsHubNode(OvsNet):
policy = "ACCEPT"
type = "hub"
def __init__(self, session, objid=None, name=None, start=True):
def __init__(self, session, _id=None, name=None, start=True):
"""
the Hub node forwards packets to all bridge ports by turning off
the MAC address learning
"""
OvsNet.__init__(self, session, objid, name, start)
OvsNet.__init__(self, session, _id, name, start)
if start:
# TODO: verify that the below flow accomplishes what is desired for a "HUB"
@ -569,8 +569,8 @@ class OvsWlanNode(OvsNet):
policy = "DROP"
type = "wlan"
def __init__(self, session, objid=None, name=None, start=True, policy=None):
OvsNet.__init__(self, session, objid, name, start, policy)
def __init__(self, session, _id=None, name=None, start=True, policy=None):
OvsNet.__init__(self, session, _id, name, start, policy)
# wireless model such as basic range
self.model = None
@ -598,7 +598,7 @@ class OvsWlanNode(OvsNet):
logging.info("adding model %s", model.name)
if model.type == RegisterTlvs.WIRELESS.value:
self.model = model(session=self.session, object_id=self.objid, config=config)
self.model = model(session=self.session, object_id=self.id, config=config)
if self.model.position_callback:
for interface in self.netifs():
interface.poshook = self.model.position_callback
@ -607,13 +607,13 @@ class OvsWlanNode(OvsNet):
interface.poshook(interface, x, y, z)
self.model.setlinkparams()
elif model.type == RegisterTlvs.MOBILITY.value:
self.mobility = model(session=self.session, object_id=self.objid, config=config)
self.mobility = model(session=self.session, object_id=self.id, config=config)
def updatemodel(self, config):
if not self.model:
raise ValueError("no model set to update for node(%s)", self.objid)
logging.info("node(%s) updating model(%s): %s", self.objid, self.model.name, config)
self.model.set_configs(config, node_id=self.objid)
raise ValueError("no model set to update for node(%s)", self.id)
logging.info("node(%s) updating model(%s): %s", self.id, self.model.name, config)
self.model.set_configs(config, node_id=self.id)
if self.model.position_callback:
for netif in self.netifs():
netif.poshook = self.model.position_callback
@ -643,12 +643,12 @@ class OvsGreTapBridge(OvsNet):
another system.
"""
def __init__(self, session, remoteip=None, objid=None, name=None, policy="ACCEPT",
def __init__(self, session, remoteip=None, _id=None, name=None, policy="ACCEPT",
localip=None, ttl=255, key=None, start=True):
OvsNet.__init__(self, session=session, objid=objid, name=name, policy=policy, start=False)
OvsNet.__init__(self, session=session, _id=_id, name=name, policy=policy, start=False)
self.grekey = key
if self.grekey is None:
self.grekey = self.session.id ^ self.objid
self.grekey = self.session.id ^ self.id
self.localnum = None
self.remotenum = None

View file

@ -241,7 +241,7 @@ class GreTap(PyCoreNetIf):
"""
def __init__(self, node=None, name=None, session=None, mtu=1458,
remoteip=None, objid=None, localip=None, ttl=255,
remoteip=None, _id=None, localip=None, ttl=255,
key=None, start=True):
"""
Creates a GreTap instance.
@ -251,7 +251,7 @@ class GreTap(PyCoreNetIf):
:param core.session.Session session: core session instance
:param mtu: interface mtu
:param str remoteip: remote address
:param int objid: object id
:param int _id: object id
:param str localip: local address
:param ttl: ttl value
:param key: gre tap key
@ -260,13 +260,13 @@ class GreTap(PyCoreNetIf):
"""
PyCoreNetIf.__init__(self, node=node, name=name, mtu=mtu)
self.session = session
if objid is None:
if _id is None:
# from PyCoreObj
objid = ((id(self) >> 16) ^ (id(self) & 0xffff)) & 0xffff
self.objid = objid
_id = ((id(self) >> 16) ^ (id(self) & 0xffff)) & 0xffff
self.id = _id
sessionid = self.session.short_session_id()
# interface name on the local host machine
self.localname = "gt.%s.%s" % (self.objid, sessionid)
self.localname = "gt.%s.%s" % (self.id, sessionid)
self.transport_type = "raw"
if not start:
self.up = False

View file

@ -242,24 +242,24 @@ class LxBrNet(PyCoreNet):
"""
policy = "DROP"
def __init__(self, session, objid=None, name=None, start=True, policy=None):
def __init__(self, session, _id=None, name=None, start=True, policy=None):
"""
Creates a LxBrNet instance.
:param core.session.Session session: core session instance
:param int objid: object id
:param int _id: object id
:param str name: object name
:param bool start: start flag
:param policy: network policy
"""
PyCoreNet.__init__(self, session, objid, name, start)
PyCoreNet.__init__(self, session, _id, name, start)
if name is None:
name = str(self.objid)
name = str(self.id)
if policy is not None:
self.policy = policy
self.name = name
sessionid = self.session.short_session_id()
self.brname = "b.%s.%s" % (str(self.objid), sessionid)
self.brname = "b.%s.%s" % (str(self.id), sessionid)
self.up = False
if start:
self.startup()
@ -503,20 +503,20 @@ class LxBrNet(PyCoreNet):
"""
sessionid = self.session.short_session_id()
try:
self_objid = "%x" % self.objid
_id = "%x" % self.id
except TypeError:
self_objid = "%s" % self.objid
_id = "%s" % self.id
try:
net_objid = "%x" % net.objid
net_id = "%x" % net.id
except TypeError:
net_objid = "%s" % net.objid
net_id = "%s" % net.id
localname = "veth%s.%s.%s" % (self_objid, net_objid, sessionid)
localname = "veth%s.%s.%s" % (_id, net_id, sessionid)
if len(localname) >= 16:
raise ValueError("interface local name %s too long" % localname)
name = "veth%s.%s.%s" % (net_objid, self_objid, sessionid)
name = "veth%s.%s.%s" % (net_id, _id, sessionid)
if len(name) >= 16:
raise ValueError("interface name %s too long" % name)
@ -570,14 +570,14 @@ class GreTapBridge(LxBrNet):
another system.
"""
def __init__(self, session, remoteip=None, objid=None, name=None,
def __init__(self, session, remoteip=None, _id=None, name=None,
policy="ACCEPT", localip=None, ttl=255, key=None, start=True):
"""
Create a GreTapBridge instance.
:param core.session.Session session: core session instance
:param str remoteip: remote address
:param int objid: object id
:param int _id: object id
:param str name: object name
:param policy: network policy
:param str localip: local address
@ -586,10 +586,10 @@ class GreTapBridge(LxBrNet):
:param bool start: start flag
:return:
"""
LxBrNet.__init__(self, session=session, objid=objid, name=name, policy=policy, start=False)
LxBrNet.__init__(self, session=session, _id=_id, name=name, policy=policy, start=False)
self.grekey = key
if self.grekey is None:
self.grekey = self.session.id ^ self.objid
self.grekey = self.session.id ^ self.id
self.localnum = None
self.remotenum = None
self.remoteip = remoteip

View file

@ -42,17 +42,17 @@ class SimpleLxcNode(PyCoreNode):
"""
valid_address_types = {"inet", "inet6", "inet6link"}
def __init__(self, session, objid=None, name=None, nodedir=None, start=True):
def __init__(self, session, _id=None, name=None, nodedir=None, start=True):
"""
Create a SimpleLxcNode instance.
:param core.session.Session session: core session instance
:param int objid: object id
:param int _id: object id
:param str name: object name
:param str nodedir: node directory
:param bool start: start flag
"""
PyCoreNode.__init__(self, session, objid, name, start=start)
PyCoreNode.__init__(self, session, _id, name, start=start)
self.nodedir = nodedir
self.ctrlchnlname = os.path.abspath(os.path.join(self.session.session_dir, self.name))
self.client = None
@ -97,7 +97,7 @@ class SimpleLxcNode(PyCoreNode):
if self.nodedir:
vnoded += ["-C", self.nodedir]
env = self.session.get_environment(state=False)
env["NODE_NUMBER"] = str(self.objid)
env["NODE_NUMBER"] = str(self.id)
env["NODE_NAME"] = str(self.name)
output = utils.check_cmd(vnoded, env=env)
@ -243,9 +243,9 @@ class SimpleLxcNode(PyCoreNode):
sessionid = self.session.short_session_id()
try:
suffix = "%x.%s.%s" % (self.objid, ifindex, sessionid)
suffix = "%x.%s.%s" % (self.id, ifindex, sessionid)
except TypeError:
suffix = "%s.%s.%s" % (self.objid, ifindex, sessionid)
suffix = "%s.%s.%s" % (self.id, ifindex, sessionid)
localname = "veth" + suffix
if len(localname) >= 16:
@ -301,7 +301,7 @@ class SimpleLxcNode(PyCoreNode):
ifname = "eth%d" % ifindex
sessionid = self.session.short_session_id()
localname = "tap%s.%s.%s" % (self.objid, ifindex, sessionid)
localname = "tap%s.%s.%s" % (self.id, ifindex, sessionid)
name = ifname
tuntap = TunTap(node=self, name=name, localname=localname, net=net, start=self.up)
@ -489,18 +489,18 @@ class LxcNode(SimpleLxcNode):
Provides lcx node functionality for core nodes.
"""
def __init__(self, session, objid=None, name=None, nodedir=None, bootsh="boot.sh", start=True):
def __init__(self, session, _id=None, name=None, nodedir=None, bootsh="boot.sh", start=True):
"""
Create a LxcNode instance.
:param core.session.Session session: core session instance
:param int objid: object id
:param int _id: object id
:param str name: object name
:param str nodedir: node directory
:param bootsh: boot shell
:param bool start: start flag
"""
super(LxcNode, self).__init__(session=session, objid=objid, name=name, nodedir=nodedir, start=start)
super(LxcNode, self).__init__(session=session, _id=_id, name=name, nodedir=nodedir, start=start)
self.bootsh = bootsh
if start:
self.startup()

View file

@ -16,8 +16,8 @@ from core.netns.vnet import LxBrNet
class PhysicalNode(PyCoreNode):
def __init__(self, session, objid=None, name=None, nodedir=None, start=True):
PyCoreNode.__init__(self, session, objid, name, start=start)
def __init__(self, session, _id=None, name=None, nodedir=None, start=True):
PyCoreNode.__init__(self, session, _id, name, start=start)
self.nodedir = nodedir
self.up = start
self.lock = threading.RLock()
@ -185,7 +185,7 @@ class PhysicalNode(PyCoreNode):
if self.up:
# this is reached when this node is linked to a network node
# tunnel to net not built yet, so build it now and adopt it
gt = self.session.broker.addnettunnel(net.objid)
gt = self.session.broker.addnettunnel(net.id)
if gt is None or len(gt) != 1:
raise ValueError("error building tunnel from adding a new network interface: %s" % gt)
gt = gt[0]

View file

@ -330,7 +330,7 @@ class Sdt(object):
(x, y, z) = obj.getposition()
if x is None or y is None:
continue
self.updatenode(obj.objid, MessageFlags.ADD.value, x, y, z,
self.updatenode(obj.id, MessageFlags.ADD.value, x, y, z,
obj.name, obj.type, obj.icon)
for nodenum in sorted(self.remotes.keys()):
r = self.remotes[nodenum]
@ -343,7 +343,7 @@ class Sdt(object):
for link_data in all_links:
is_wireless = nodeutils.is_node(net, (NodeTypes.WIRELESS_LAN, NodeTypes.EMANE))
wireless_link = link_data.message_type == LinkTypes.WIRELESS.value
if is_wireless and link_data.node1_id == net.objid:
if is_wireless and link_data.node1_id == net.id:
continue
self.updatelink(
@ -385,7 +385,7 @@ class Sdt(object):
# enabled prior to starting the session
if not self.is_enabled():
return False
# node.(objid, type, icon, name) are used.
# node.(_id, type, icon, name) are used.
nodenum = msg.get_tlv(NodeTlvs.NUMBER.value)
if not nodenum:
return
@ -415,7 +415,7 @@ class Sdt(object):
except KeyError:
node = None
if node:
self.updatenode(node.objid, msg.flags, x, y, z, node.name, node.type, node.icon)
self.updatenode(node.id, msg.flags, x, y, z, node.name, node.type, node.icon)
else:
if nodenum in self.remotes:
remote = self.remotes[nodenum]
@ -426,7 +426,7 @@ class Sdt(object):
if icon is None:
icon = remote.icon
else:
remote = Bunch(objid=nodenum, type=nodetype, icon=icon, name=name, net=net, links=set())
remote = Bunch(_id=nodenum, type=nodetype, icon=icon, name=name, net=net, links=set())
self.remotes[nodenum] = remote
remote.pos = (x, y, z)
self.updatenode(nodenum, msg.flags, x, y, z, name, nodetype, icon)

View file

@ -374,7 +374,7 @@ class CoreServices(object):
logging.info("setting services for node(%s): %s", node.name, services)
for service_name in services:
service = self.get_service(node.objid, service_name, default_service=True)
service = self.get_service(node.id, service_name, default_service=True)
if not service:
logging.warn("unknown service(%s) for node(%s)", service_name, node.name)
continue
@ -591,7 +591,7 @@ class CoreServices(object):
:return: file message for node
"""
# get service to get file from
service = self.get_service(node.objid, service_name, default_service=True)
service = self.get_service(node.id, service_name, default_service=True)
if not service:
raise ValueError("invalid service: %s", service_name)
@ -614,7 +614,7 @@ class CoreServices(object):
filetypestr = "service:%s" % service.name
return FileData(
message_type=MessageFlags.ADD.value,
node=node.objid,
node=node.id,
name=filename,
type=filetypestr,
data=data

View file

@ -21,9 +21,9 @@ class EmaneTransportService(CoreService):
if filename == cls.configs[0]:
transport_commands = []
for interface in node.netifs(sort=True):
network_node = node.session.get_object(interface.net.objid)
network_node = node.session.get_object(interface.net.id)
if nodeutils.is_node(network_node, NodeTypes.EMANE):
config = node.session.emane.get_configs(network_node.objid, network_node.model.name)
config = node.session.emane.get_configs(network_node.id, network_node.model.name)
if config and emanexml.is_external(config):
nem_id = network_node.getnemid(interface)
command = "emanetransportd -r -l 0 -d ../transportdaemon%s.xml" % nem_id
@ -32,6 +32,6 @@ class EmaneTransportService(CoreService):
return """
emanegentransportxml -o ../ ../platform%s.xml
%s
""" % (node.objid, transport_commands)
""" % (node.id, transport_commands)
else:
raise ValueError

View file

@ -525,7 +525,7 @@ class FRRBgp(FrrService):
cfg = "!\n! BGP configuration\n!\n"
cfg += "! You should configure the AS number below,\n"
cfg += "! along with this router's peers.\n!\n"
cfg += "router bgp %s\n" % node.objid
cfg += "router bgp %s\n" % node.id
rtrid = cls.routerid(node)
cfg += " bgp router-id %s\n" % rtrid
cfg += " redistribute connected\n"

View file

@ -474,7 +474,7 @@ class Bgp(QuaggaService):
cfg = "!\n! BGP configuration\n!\n"
cfg += "! You should configure the AS number below,\n"
cfg += "! along with this router's peers.\n!\n"
cfg += "router bgp %s\n" % node.objid
cfg += "router bgp %s\n" % node.id
rtrid = cls.routerid(node)
cfg += " bgp router-id %s\n" % rtrid
cfg += " redistribute connected\n"

View file

@ -460,12 +460,10 @@ class Session(object):
self.user = user
def get_object_id(self):
def get_node_id(self):
"""
Return a unique, new random object id.
Return a unique, new node id.
"""
object_id = None
with self._objects_lock:
while True:
object_id = random.randint(1, 0xFFFF)
@ -476,24 +474,22 @@ class Session(object):
def add_object(self, cls, *clsargs, **clskwds):
"""
Add an emulation object.
Create an emulation node.
:param class cls: object class to add
:param list clsargs: list of arguments for the class to create
:param dict clskwds: dictionary of arguments for the class to create
:return: the created class instance
"""
obj = cls(self, *clsargs, **clskwds)
node = cls(self, *clsargs, **clskwds)
self._objects_lock.acquire()
if obj.objid in self.objects:
self._objects_lock.release()
obj.shutdown()
raise KeyError("duplicate object id %s for %s" % (obj.objid, obj))
self.objects[obj.objid] = obj
self._objects_lock.release()
with self._objects_lock:
if node.id in self.objects:
node.shutdown()
raise KeyError("duplicate node id %s for %s" % (node.id, node.name))
self.objects[node.id] = node
return obj
return node
def get_object(self, object_id):
"""
@ -827,7 +823,7 @@ class Session(object):
control_net = self.get_control_net_object(net_index)
if remove:
self.delete_object(control_net.objid)
self.delete_object(control_net.id)
return None
return control_net
@ -891,7 +887,7 @@ class Session(object):
prefix = prefixes[0]
control_net_class = nodeutils.get_node_class(NodeTypes.CONTROL_NET)
control_net = self.add_object(cls=control_net_class, objid=object_id, prefix=prefix,
control_net = self.add_object(cls=control_net_class, _id=object_id, prefix=prefix,
assign_address=assign_address,
updown_script=updown_script, serverintf=server_interface)
@ -929,12 +925,12 @@ class Session(object):
if node.netif(control_net.CTRLIF_IDX_BASE + net_index):
return
control_ip = node.objid
control_ip = node.id
try:
addrlist = ["%s/%s" % (control_net.prefix.addr(control_ip), control_net.prefix.prefixlen)]
except ValueError:
msg = "Control interface not added to node %s. " % node.objid
msg = "Control interface not added to node %s. " % node.id
msg += "Invalid control network prefix (%s). " % control_net.prefix
msg += "A longer prefix length may be required for this many nodes."
logging.exception(msg)

View file

@ -103,7 +103,7 @@ class NodeElement(object):
self.session = session
self.node = node
self.element = etree.Element(element_name)
add_attribute(self.element, "id", node.objid)
add_attribute(self.element, "id", node.id)
add_attribute(self.element, "name", node.name)
add_attribute(self.element, "icon", node.icon)
add_attribute(self.element, "canvas", node.canvas)
@ -399,7 +399,7 @@ class CoreXmlWriter(object):
if nodeutils.is_node(node, (NodeTypes.SWITCH, NodeTypes.HUB)):
for netif in node.netifs(sort=True):
othernet = getattr(netif, "othernet", None)
if othernet and othernet.objid != node.objid:
if othernet and othernet.id != node.id:
logging.info("writer ignoring node(%s) othernet(%s)", node.name, othernet.name)
return

View file

@ -135,7 +135,7 @@ def build_node_platform_xml(emane_manager, control_net, node, nem_id, platform_x
if not transport_type:
logging.info("warning: %s interface type unsupported!", netif.name)
transport_type = "raw"
transport_file = transport_file_name(node.objid, transport_type)
transport_file = transport_file_name(node.id, transport_type)
transport_element = etree.SubElement(nem_element, "transport", definition=transport_file)
# add transport parameter
@ -145,7 +145,7 @@ def build_node_platform_xml(emane_manager, control_net, node, nem_id, platform_x
nem_entries[netif] = nem_element
# merging code
key = netif.node.objid
key = netif.node.id
if netif.transport_type == "raw":
key = "host"
otadev = control_net.brname
@ -267,7 +267,7 @@ def build_transport_xml(emane_manager, node, transport_type):
add_param(transport_element, "bitrate", "0")
# get emane model cnfiguration
config = emane_manager.get_configs(node.objid, node.model.name)
config = emane_manager.get_configs(node.id, node.model.name)
flowcontrol = config.get("flowcontrolenable", "0") == "1"
if "virtual" in transport_type.lower():
@ -280,7 +280,7 @@ def build_transport_xml(emane_manager, node, transport_type):
add_param(transport_element, "flowcontrolenable", "on")
doc_name = "transport"
file_name = transport_file_name(node.objid, transport_type)
file_name = transport_file_name(node.id, transport_type)
file_path = os.path.join(emane_manager.session.session_dir, file_name)
create_file(transport_element, doc_name, file_path)
@ -382,7 +382,7 @@ def _basename(emane_model, interface=None):
name = "n%s" % emane_model.object_id
if interface:
node_id = interface.node.objid
node_id = interface.node.id
if emane_model.session.emane.getifcconfig(node_id, interface, emane_model.name):
name = interface.localname.replace(".", "_")

View file

@ -37,7 +37,7 @@ def example(options):
node = session.create_wireless_node()
node.setposition(x=150 * (i + 1), y=150)
interface = prefixes.create_interface(node)
session.add_link(node.objid, emane_network.objid, interface_one=interface)
session.add_link(node.id, emane_network.id, interface_one=interface)
# instantiate session
session.instantiate()

View file

@ -34,7 +34,7 @@ def example(options):
for _ in xrange(options.nodes):
node = session.add_node()
interface = prefixes.create_interface(node)
session.add_link(node.objid, switch.objid, interface_one=interface)
session.add_link(node.id, switch.id, interface_one=interface)
# instantiate session
session.instantiate()

View file

@ -29,7 +29,7 @@ def example(nodes):
for _ in xrange(nodes):
node = session.add_node()
interface = prefixes.create_interface(node)
session.add_link(node.objid, switch.objid, interface_one=interface)
session.add_link(node.id, switch.id, interface_one=interface)
# instantiate session
session.instantiate()

View file

@ -38,7 +38,7 @@ def example(options):
for _ in xrange(options.nodes):
node = session.add_node(node_options=node_options)
interface = prefixes.create_interface(node)
session.add_link(node.objid, wlan.objid, interface_one=interface)
session.add_link(node.id, wlan.id, interface_one=interface)
# instantiate session
session.instantiate()

View file

@ -46,7 +46,7 @@ def cmd(node, exec_cmd):
global exec_num
# Set up the command api message
tlvdata = CoreExecuteTlv.pack(ExecuteTlvs.NODE.value, node.objid)
tlvdata = CoreExecuteTlv.pack(ExecuteTlvs.NODE.value, node.id)
tlvdata += CoreExecuteTlv.pack(ExecuteTlvs.NUMBER.value, exec_num)
tlvdata += CoreExecuteTlv.pack(ExecuteTlvs.COMMAND.value, exec_cmd)
msg = coreapi.CoreExecMessage.pack(MessageFlags.STRING.value | MessageFlags.TEXT.value, tlvdata)
@ -149,7 +149,7 @@ def main():
# create remote nodes via API
for i in xrange(1, number_of_nodes + 1):
node = nodes.CoreNode(session=session, objid=i, name="n%d" % i, start=False)
node = nodes.CoreNode(session=session, _id=i, name="n%d" % i, start=False)
node.setposition(x=150 * i, y=150)
node.server = daemon
node_data = node.data(flags)
@ -159,7 +159,7 @@ def main():
# create remote links via API
for i in xrange(1, number_of_nodes + 1):
tlvdata = coreapi.CoreLinkTlv.pack(LinkTlvs.N1_NUMBER.value, switch.objid)
tlvdata = coreapi.CoreLinkTlv.pack(LinkTlvs.N1_NUMBER.value, switch.id)
tlvdata += coreapi.CoreLinkTlv.pack(LinkTlvs.N2_NUMBER.value, i)
tlvdata += coreapi.CoreLinkTlv.pack(LinkTlvs.TYPE.value, LinkTypes.WIRED.value)
tlvdata += coreapi.CoreLinkTlv.pack(LinkTlvs.INTERFACE2_NUMBER.value, 0)

View file

@ -80,7 +80,7 @@ def main():
print "creating %d (%d local / %d remote) nodes with addresses from %s" % \
(options.numnodes, num_local, num_remote, prefix)
for i in xrange(1, num_local + 1):
node = session.add_object(cls=nodes.CoreNode, name="n%d" % i, objid=i)
node = session.add_object(cls=nodes.CoreNode, name="n%d" % i, _id=i)
node.newnetif(switch, ["%s/%s" % (prefix.addr(i), prefix.prefixlen)])
node.cmd([constants.SYSCTL_BIN, "net.ipv4.icmp_echo_ignore_broadcasts=0"])
node.setposition(x=150 * i, y=150)
@ -91,7 +91,7 @@ def main():
# create remote nodes via API
for i in xrange(num_local + 1, options.numnodes + 1):
node = nodes.CoreNode(session=session, objid=i, name="n%d" % i, start=False)
node = nodes.CoreNode(session=session, _id=i, name="n%d" % i, start=False)
node.setposition(x=150 * i, y=150)
node.server = slave
n.append(node)
@ -101,7 +101,7 @@ def main():
# create remote links via API
for i in xrange(num_local + 1, options.numnodes + 1):
tlvdata = coreapi.CoreLinkTlv.pack(LinkTlvs.N1_NUMBER.value, switch.objid)
tlvdata = coreapi.CoreLinkTlv.pack(LinkTlvs.N1_NUMBER.value, switch.id)
tlvdata += coreapi.CoreLinkTlv.pack(LinkTlvs.N2_NUMBER.value, i)
tlvdata += coreapi.CoreLinkTlv.pack(LinkTlvs.TYPE.value, LinkTypes.WIRED.value)
tlvdata += coreapi.CoreLinkTlv.pack(LinkTlvs.INTERFACE2_NUMBER.value, 0)

View file

@ -64,12 +64,12 @@ ip forwarding
confdir = "/usr/local/etc/quagga"
def __init__(self, core, ipaddr, routerid=None,
objid=None, name=None, nodedir=None):
_id=None, name=None, nodedir=None):
if routerid is None:
routerid = ipaddr.split("/")[0]
self.ipaddr = ipaddr
self.routerid = routerid
nodes.LxcNode.__init__(self, core, objid, name, nodedir)
nodes.LxcNode.__init__(self, core, _id, name, nodedir)
self.privatedir(self.confdir)
self.privatedir(QUAGGA_STATE_DIR)
@ -246,7 +246,7 @@ class ManetExperiment(object):
self.net = self.session.add_object(cls=nodes.WlanNode)
for i in xrange(1, numnodes + 1):
addr = "%s/%s" % (prefix.addr(i), 32)
tmp = self.session.add_object(cls=ManetNode, ipaddr=addr, objid="%d" % i, name="n%d" % i)
tmp = self.session.add_object(cls=ManetNode, ipaddr=addr, _id="%d" % i, name="n%d" % i)
tmp.newnetif(self.net, [addr])
self.nodes.append(tmp)
# connect nodes with probability linkprob

View file

@ -417,7 +417,7 @@ class Experiment(object):
prev = None
for i in xrange(1, numnodes + 1):
addr = "%s/%s" % (prefix.addr(i), 32)
tmp = self.session.add_object(cls=nodes.CoreNode, objid=i, name="n%d" % i)
tmp = self.session.add_object(cls=nodes.CoreNode, _id=i, name="n%d" % i)
tmp.newnetif(self.net, [addr])
self.nodes.append(tmp)
self.session.services.add_services(tmp, "router", "IPForward")
@ -440,13 +440,12 @@ class Experiment(object):
self.session.location.setrefgeo(47.57917, -122.13232, 2.00000)
self.session.location.refscale = 150.0
self.session.emane.loadmodels()
self.net = self.session.add_object(cls=EmaneNode, objid=numnodes + 1, name="wlan1")
self.net = self.session.add_object(cls=EmaneNode, _id=numnodes + 1, name="wlan1")
self.net.verbose = verbose
# self.session.emane.addobj(self.net)
for i in xrange(1, numnodes + 1):
addr = "%s/%s" % (prefix.addr(i), 32)
tmp = self.session.add_object(cls=nodes.CoreNode, objid=i,
name="n%d" % i)
tmp = self.session.add_object(cls=nodes.CoreNode, _id=i, name="n%d" % i)
# tmp.setposition(i * 20, 50, None)
tmp.setposition(50, 50, None)
tmp.newnetif(self.net, [addr])
@ -455,7 +454,7 @@ class Experiment(object):
if values is None:
values = cls.getdefaultvalues()
self.session.emane.setconfig(self.net.objid, cls.name, values)
self.session.emane.setconfig(self.net.id, cls.name, values)
self.session.instantiate()
self.info("waiting %s sec (TAP bring-up)" % 2)

View file

@ -37,11 +37,11 @@ from core.service import ServiceManager
EMANE_SERVICES = "zebra|OSPFv3MDR|IPForward"
def node_message(objid, name, emulation_server=None, node_type=NodeTypes.DEFAULT, model=None):
def node_message(_id, name, emulation_server=None, node_type=NodeTypes.DEFAULT, model=None):
"""
Convenience method for creating a node TLV messages.
:param int objid: node id
:param int _id: node id
:param str name: node name
:param str emulation_server: distributed server name, if desired
:param core.enumerations.NodeTypes node_type: node type
@ -50,7 +50,7 @@ def node_message(objid, name, emulation_server=None, node_type=NodeTypes.DEFAULT
:rtype: core.api.coreapi.CoreNodeMessage
"""
values = [
(NodeTlvs.NUMBER, objid),
(NodeTlvs.NUMBER, _id),
(NodeTlvs.TYPE, node_type.value),
(NodeTlvs.NAME, name),
(NodeTlvs.EMULATION_SERVER, emulation_server),
@ -118,7 +118,7 @@ def command_message(node, command):
"""
flags = MessageFlags.STRING.value | MessageFlags.TEXT.value
return CoreExecMessage.create(flags, [
(ExecuteTlvs.NODE, node.objid),
(ExecuteTlvs.NODE, node.id),
(ExecuteTlvs.NUMBER, 1),
(ExecuteTlvs.COMMAND, command)
])

View file

@ -40,7 +40,7 @@ class TestDistributed:
# create local node
message = conftest.node_message(
objid=1,
_id=1,
name="n1",
model="host"
)
@ -48,7 +48,7 @@ class TestDistributed:
# create distributed node and assign to distributed server
message = conftest.node_message(
objid=2,
_id=2,
name="n2",
emulation_server=cored.distributed_server,
model="host"
@ -57,7 +57,7 @@ class TestDistributed:
# create distributed switch and assign to distributed server
message = conftest.node_message(
objid=3,
_id=3,
name="n3",
emulation_server=cored.distributed_server,
node_type=NodeTypes.SWITCH
@ -106,7 +106,7 @@ class TestDistributed:
# create local node
message = conftest.node_message(
objid=1,
_id=1,
name="n1",
model="host"
)
@ -114,7 +114,7 @@ class TestDistributed:
# create distributed node and assign to distributed server
message = conftest.node_message(
objid=2,
_id=2,
name="n2",
emulation_server=cored.distributed_server,
node_type=NodeTypes.PHYSICAL,
@ -124,7 +124,7 @@ class TestDistributed:
# create distributed switch and assign to distributed server
message = conftest.node_message(
objid=3,
_id=3,
name="n3",
node_type=NodeTypes.SWITCH
)
@ -173,7 +173,7 @@ class TestDistributed:
# create local node
message = conftest.node_message(
objid=1,
_id=1,
name="n1",
model="host"
)
@ -181,7 +181,7 @@ class TestDistributed:
# create distributed node and assign to distributed server
message = conftest.node_message(
objid=2,
_id=2,
name=distributed_address,
emulation_server=cored.distributed_server,
node_type=NodeTypes.TUNNEL

View file

@ -160,7 +160,7 @@ class TestConf:
session.mobility.set_model(wlan_node, BasicRangeModel)
# then
assert session.mobility.get_model_config(wlan_node.objid, BasicRangeModel.name)
assert session.mobility.get_model_config(wlan_node.id, BasicRangeModel.name)
def test_model_set_error(self, session):
# given

View file

@ -69,7 +69,7 @@ class TestCore:
# link nodes to net node
for node in [node_one, node_two]:
interface = ip_prefixes.create_interface(node)
session.add_link(node.objid, net_node.objid, interface_one=interface)
session.add_link(node.id, net_node.id, interface_one=interface)
# instantiate session
session.instantiate()
@ -96,7 +96,7 @@ class TestCore:
# link nodes to ptp net
for node in [node_one, node_two]:
interface = ip_prefixes.create_interface(node)
session.add_link(node.objid, ptp_node.objid, interface_one=interface)
session.add_link(node.id, ptp_node.id, interface_one=interface)
# get node client for testing
client = node_one.client
@ -152,7 +152,7 @@ class TestCore:
# link nodes to ptp net
for node in [node_one, node_two]:
interface = ip_prefixes.create_interface(node)
session.add_link(node.objid, ptp_node.objid, interface_one=interface)
session.add_link(node.id, ptp_node.id, interface_one=interface)
# instantiate session
session.instantiate()
@ -199,7 +199,7 @@ class TestCore:
# link nodes
for node in [node_one, node_two]:
interface = ip_prefixes.create_interface(node)
session.add_link(node.objid, wlan_node.objid, interface_one=interface)
session.add_link(node.id, wlan_node.id, interface_one=interface)
# instantiate session
session.instantiate()
@ -229,7 +229,7 @@ class TestCore:
# link nodes
for node in [node_one, node_two]:
interface = ip_prefixes.create_interface(node)
session.add_link(node.objid, wlan_node.objid, interface_one=interface)
session.add_link(node.id, wlan_node.id, interface_one=interface)
# configure mobility script for session
config = {

View file

@ -43,7 +43,7 @@ class TestEmane:
# configure tdma
if model == EmaneTdmaModel:
session.emane.set_model_config(emane_network.objid, EmaneTdmaModel.name, {
session.emane.set_model_config(emane_network.id, EmaneTdmaModel.name, {
"schedule": os.path.join(_DIR, "../examples/tdma/schedule.xml")
})
@ -57,7 +57,7 @@ class TestEmane:
for i, node in enumerate([node_one, node_two]):
node.setposition(x=150 * (i + 1), y=150)
interface = ip_prefixes.create_interface(node)
session.add_link(node.objid, emane_network.objid, interface_one=interface)
session.add_link(node.id, emane_network.id, interface_one=interface)
# instantiate session
session.instantiate()

View file

@ -192,10 +192,10 @@ class TestGrpc:
# then
with client.context_connect():
response = client.get_node(session.id, node.objid)
response = client.get_node(session.id, node.id)
# then
assert response.node.id == node.objid
assert response.node.id == node.id
@pytest.mark.parametrize("node_id, expected", [
(1, True),
@ -237,7 +237,7 @@ class TestGrpc:
assert response.result is expected
if expected is True:
with pytest.raises(KeyError):
assert session.get_object(node.objid)
assert session.get_object(node.id)
def test_get_hooks(self, grpc_server):
# given
@ -307,11 +307,11 @@ class TestGrpc:
switch = session.add_node(_type=NodeTypes.SWITCH)
node = session.add_node()
interface = ip_prefixes.create_interface(node)
session.add_link(node.objid, switch.objid, interface)
session.add_link(node.id, switch.id, interface)
# then
with client.context_connect():
response = client.get_node_links(session.id, switch.objid)
response = client.get_node_links(session.id, switch.id)
# then
assert len(response.links) == 1
@ -323,7 +323,7 @@ class TestGrpc:
switch = session.add_node(_type=NodeTypes.SWITCH)
node = session.add_node()
interface = ip_prefixes.create_interface(node)
session.add_link(node.objid, switch.objid, interface)
session.add_link(node.id, switch.id, interface)
# then
with pytest.raises(grpc.RpcError):
@ -339,9 +339,9 @@ class TestGrpc:
assert len(switch.all_link_data(0)) == 0
# then
interface = interface_helper.create_interface(node.objid, 0)
interface = interface_helper.create_interface(node.id, 0)
with client.context_connect():
response = client.add_link(session.id, node.objid, switch.objid, interface)
response = client.add_link(session.id, node.id, switch.id, interface)
# then
assert response.result is True
@ -354,7 +354,7 @@ class TestGrpc:
node = session.add_node()
# then
interface = interface_helper.create_interface(node.objid, 0)
interface = interface_helper.create_interface(node.id, 0)
with pytest.raises(grpc.RpcError):
with client.context_connect():
client.add_link(session.id, 1, 3, interface)
@ -366,14 +366,14 @@ class TestGrpc:
switch = session.add_node(_type=NodeTypes.SWITCH)
node = session.add_node()
interface = ip_prefixes.create_interface(node)
session.add_link(node.objid, switch.objid, interface)
session.add_link(node.id, switch.id, interface)
options = core_pb2.LinkOptions(bandwidth=30000)
link = switch.all_link_data(0)[0]
assert options.bandwidth != link.bandwidth
# then
with client.context_connect():
response = client.edit_link(session.id, node.objid, switch.objid, options)
response = client.edit_link(session.id, node.id, switch.id, options)
# then
assert response.result is True
@ -388,11 +388,11 @@ class TestGrpc:
interface_one = ip_prefixes.create_interface(node_one)
node_two = session.add_node()
interface_two = ip_prefixes.create_interface(node_two)
session.add_link(node_one.objid, node_two.objid, interface_one, interface_two)
session.add_link(node_one.id, node_two.id, interface_one, interface_two)
link_node = None
for node_id in session.objects:
node = session.objects[node_id]
if node.objid not in {node_one.objid, node_two.objid}:
if node.id not in {node_one.id, node_two.id}:
link_node = node
break
assert len(link_node.all_link_data(0)) == 1
@ -400,7 +400,7 @@ class TestGrpc:
# then
with client.context_connect():
response = client.delete_link(
session.id, node_one.objid, node_two.objid, interface_one.id, interface_two.id)
session.id, node_one.id, node_two.id, interface_one.id, interface_two.id)
# then
assert response.result is True
@ -414,7 +414,7 @@ class TestGrpc:
# then
with client.context_connect():
response = client.get_wlan_config(session.id, wlan.objid)
response = client.get_wlan_config(session.id, wlan.id)
# then
assert len(response.groups) > 0
@ -429,11 +429,11 @@ class TestGrpc:
# then
with client.context_connect():
response = client.set_wlan_config(session.id, wlan.objid, {range_key: range_value})
response = client.set_wlan_config(session.id, wlan.id, {range_key: range_value})
# then
assert response.result is True
config = session.mobility.get_model_config(wlan.objid, BasicRangeModel.name)
config = session.mobility.get_model_config(wlan.id, BasicRangeModel.name)
assert config[range_key] == range_value
def test_get_emane_config(self, grpc_server):
@ -475,7 +475,7 @@ class TestGrpc:
)
config_key = "platform_id_start"
config_value = "2"
session.emane.set_model_config(emane_network.objid, EmaneIeee80211abgModel.name, {config_key: config_value})
session.emane.set_model_config(emane_network.id, EmaneIeee80211abgModel.name, {config_key: config_value})
# then
with client.context_connect():
@ -483,7 +483,7 @@ class TestGrpc:
# then
assert len(response.configs) == 1
assert emane_network.objid in response.configs
assert emane_network.id in response.configs
def test_set_emane_model_config(self, grpc_server):
# given
@ -499,11 +499,11 @@ class TestGrpc:
# then
with client.context_connect():
response = client.set_emane_model_config(
session.id, emane_network.objid, EmaneIeee80211abgModel.name, {config_key: config_value})
session.id, emane_network.id, EmaneIeee80211abgModel.name, {config_key: config_value})
# then
assert response.result is True
config = session.emane.get_model_config(emane_network.objid, EmaneIeee80211abgModel.name)
config = session.emane.get_model_config(emane_network.id, EmaneIeee80211abgModel.name)
assert config[config_key] == config_value
def test_get_emane_model_config(self, grpc_server):
@ -518,7 +518,7 @@ class TestGrpc:
# then
with client.context_connect():
response = client.get_emane_model_config(
session.id, emane_network.objid, EmaneIeee80211abgModel.name)
session.id, emane_network.id, EmaneIeee80211abgModel.name)
# then
assert len(response.groups) > 0
@ -540,7 +540,7 @@ class TestGrpc:
client = CoreGrpcClient()
session = grpc_server.coreemu.create_session()
wlan = session.add_node(_type=NodeTypes.WIRELESS_LAN)
session.mobility.set_model_config(wlan.objid, Ns2ScriptedMobility.name, {})
session.mobility.set_model_config(wlan.id, Ns2ScriptedMobility.name, {})
# then
with client.context_connect():
@ -548,18 +548,18 @@ class TestGrpc:
# then
assert len(response.configs) > 0
assert wlan.objid in response.configs
assert wlan.id in response.configs
def test_get_mobility_config(self, grpc_server):
# given
client = CoreGrpcClient()
session = grpc_server.coreemu.create_session()
wlan = session.add_node(_type=NodeTypes.WIRELESS_LAN)
session.mobility.set_model_config(wlan.objid, Ns2ScriptedMobility.name, {})
session.mobility.set_model_config(wlan.id, Ns2ScriptedMobility.name, {})
# then
with client.context_connect():
response = client.get_mobility_config(session.id, wlan.objid)
response = client.get_mobility_config(session.id, wlan.id)
# then
assert len(response.groups) > 0
@ -574,11 +574,11 @@ class TestGrpc:
# then
with client.context_connect():
response = client.set_mobility_config(session.id, wlan.objid, {config_key: config_value})
response = client.set_mobility_config(session.id, wlan.id, {config_key: config_value})
# then
assert response.result is True
config = session.mobility.get_model_config(wlan.objid, Ns2ScriptedMobility.name)
config = session.mobility.get_model_config(wlan.id, Ns2ScriptedMobility.name)
assert config[config_key] == config_value
def test_mobility_action(self, grpc_server):
@ -586,12 +586,12 @@ class TestGrpc:
client = CoreGrpcClient()
session = grpc_server.coreemu.create_session()
wlan = session.add_node(_type=NodeTypes.WIRELESS_LAN)
session.mobility.set_model_config(wlan.objid, Ns2ScriptedMobility.name, {})
session.mobility.set_model_config(wlan.id, Ns2ScriptedMobility.name, {})
session.instantiate()
# then
with client.context_connect():
response = client.mobility_action(session.id, wlan.objid, core_pb2.MOBILITY_STOP)
response = client.mobility_action(session.id, wlan.id, core_pb2.MOBILITY_STOP)
# then
assert response.result is True
@ -642,7 +642,7 @@ class TestGrpc:
# then
with client.context_connect():
response = client.get_node_service(session.id, node.objid, "IPForward")
response = client.get_node_service(session.id, node.id, "IPForward")
# then
assert len(response.service.configs) > 0
@ -655,7 +655,7 @@ class TestGrpc:
# then
with client.context_connect():
response = client.get_node_service_file(session.id, node.objid, "IPForward", "ipforward.sh")
response = client.get_node_service_file(session.id, node.id, "IPForward", "ipforward.sh")
# then
assert response.data is not None
@ -670,11 +670,11 @@ class TestGrpc:
# then
with client.context_connect():
response = client.set_node_service(session.id, node.objid, service_name, (), validate, ())
response = client.set_node_service(session.id, node.id, service_name, (), validate, ())
# then
assert response.result is True
service = session.services.get_service(node.objid, service_name, default_service=True)
service = session.services.get_service(node.id, service_name, default_service=True)
assert service.validate == validate
def test_set_node_service_file(self, grpc_server):
@ -688,7 +688,7 @@ class TestGrpc:
# then
with client.context_connect():
response = client.set_node_service_file(session.id, node.objid, service_name, file_name, file_data)
response = client.set_node_service_file(session.id, node.id, service_name, file_name, file_data)
# then
assert response.result is True
@ -704,7 +704,7 @@ class TestGrpc:
# then
with client.context_connect():
response = client.service_action(session.id, node.objid, service_name, core_pb2.SERVICE_STOP)
response = client.service_action(session.id, node.id, service_name, core_pb2.SERVICE_STOP)
# then
assert response.result is True
@ -736,7 +736,7 @@ class TestGrpc:
wlan = session.add_node(_type=NodeTypes.WIRELESS_LAN)
node = session.add_node()
interface = ip_prefixes.create_interface(node)
session.add_link(node.objid, wlan.objid, interface)
session.add_link(node.id, wlan.id, interface)
link_data = wlan.all_link_data(0)[0]
queue = Queue()

View file

@ -25,7 +25,7 @@ def command_message(node, command):
:param command: command to execute
:return: packed execute message
"""
tlv_data = CoreExecuteTlv.pack(ExecuteTlvs.NODE.value, node.objid)
tlv_data = CoreExecuteTlv.pack(ExecuteTlvs.NODE.value, node.id)
tlv_data += CoreExecuteTlv.pack(ExecuteTlvs.NUMBER.value, 1)
tlv_data += CoreExecuteTlv.pack(ExecuteTlvs.COMMAND.value, command)
return coreapi.CoreExecMessage.pack(MessageFlags.STRING.value | MessageFlags.TEXT.value, tlv_data)
@ -52,8 +52,8 @@ def switch_link_message(switch, node, address, prefix_len):
:param prefix_len: prefix length of address
:return: packed link message
"""
tlv_data = coreapi.CoreLinkTlv.pack(LinkTlvs.N1_NUMBER.value, switch.objid)
tlv_data += coreapi.CoreLinkTlv.pack(LinkTlvs.N2_NUMBER.value, node.objid)
tlv_data = coreapi.CoreLinkTlv.pack(LinkTlvs.N1_NUMBER.value, switch.id)
tlv_data += coreapi.CoreLinkTlv.pack(LinkTlvs.N2_NUMBER.value, node.id)
tlv_data += coreapi.CoreLinkTlv.pack(LinkTlvs.TYPE.value, LinkTypes.WIRED.value)
tlv_data += coreapi.CoreLinkTlv.pack(LinkTlvs.INTERFACE2_NUMBER.value, 0)
tlv_data += coreapi.CoreLinkTlv.pack(LinkTlvs.INTERFACE2_IP4.value, address)
@ -70,7 +70,7 @@ def run_cmd(node, exec_cmd):
:return: Returns the result of the command
"""
# Set up the command api message
# tlv_data = CoreExecuteTlv.pack(ExecuteTlvs.NODE.value, node.objid)
# tlv_data = CoreExecuteTlv.pack(ExecuteTlvs.NODE.value, node.id)
# tlv_data += CoreExecuteTlv.pack(ExecuteTlvs.NUMBER.value, 1)
# tlv_data += CoreExecuteTlv.pack(ExecuteTlvs.COMMAND.value, exec_cmd)
# message = coreapi.CoreExecMessage.pack(MessageFlags.STRING.value | MessageFlags.TEXT.value, tlv_data)

View file

@ -11,7 +11,7 @@ def create_ptp_network(session, ip_prefixes):
# link nodes to net node
interface_one = ip_prefixes.create_interface(node_one)
interface_two = ip_prefixes.create_interface(node_two)
session.add_link(node_one.objid, node_two.objid, interface_one, interface_two)
session.add_link(node_one.id, node_two.id, interface_one, interface_two)
# instantiate session
session.instantiate()
@ -43,7 +43,7 @@ class TestLinks:
inteface_two = ip_prefixes.create_interface(node_two)
# when
session.add_link(node_one.objid, node_two.objid, interface_one, inteface_two)
session.add_link(node_one.id, node_two.id, interface_one, inteface_two)
# then
assert node_one.netif(interface_one.id)
@ -56,7 +56,7 @@ class TestLinks:
interface_one = ip_prefixes.create_interface(node_one)
# when
session.add_link(node_one.objid, node_two.objid, interface_one)
session.add_link(node_one.id, node_two.id, interface_one)
# then
assert node_two.all_link_data(0)
@ -69,7 +69,7 @@ class TestLinks:
interface_two = ip_prefixes.create_interface(node_two)
# when
session.add_link(node_one.objid, node_two.objid, interface_two=interface_two)
session.add_link(node_one.id, node_two.id, interface_two=interface_two)
# then
assert node_one.all_link_data(0)
@ -81,7 +81,7 @@ class TestLinks:
node_two = session.add_node(_type=NodeTypes.SWITCH)
# when
session.add_link(node_one.objid, node_two.objid)
session.add_link(node_one.id, node_two.id)
# then
assert node_one.all_link_data(0)
@ -91,7 +91,7 @@ class TestLinks:
node_one = session.add_node()
node_two = session.add_node(_type=NodeTypes.SWITCH)
interface_one = ip_prefixes.create_interface(node_one)
session.add_link(node_one.objid, node_two.objid, interface_one)
session.add_link(node_one.id, node_two.id, interface_one)
interface = node_one.netif(interface_one.id)
output = utils.check_cmd(["tc", "qdisc", "show", "dev", interface.localname])
assert "delay" not in output
@ -105,7 +105,7 @@ class TestLinks:
link_options.bandwidth = 5000000
link_options.per = 25
link_options.dup = 25
session.update_link(node_one.objid, node_two.objid,
session.update_link(node_one.id, node_two.id,
interface_one_id=interface_one.id, link_options=link_options)
# then
@ -121,12 +121,12 @@ class TestLinks:
node_two = session.add_node()
interface_one = ip_prefixes.create_interface(node_one)
interface_two = ip_prefixes.create_interface(node_two)
session.add_link(node_one.objid, node_two.objid, interface_one, interface_two)
session.add_link(node_one.id, node_two.id, interface_one, interface_two)
assert node_one.netif(interface_one.id)
assert node_two.netif(interface_two.id)
# when
session.delete_link(node_one.objid, node_two.objid, interface_one.id, interface_two.id)
session.delete_link(node_one.id, node_two.id, interface_one.id, interface_two.id)
# then
assert not node_one.netif(interface_one.id)
@ -155,7 +155,7 @@ class TestLinks:
# change bandwidth in bits per second
link_options = LinkOptions()
link_options.bandwidth = 500000
session.update_link(node_one.objid, node_two.objid, link_options=link_options)
session.update_link(node_one.id, node_two.id, link_options=link_options)
# run iperf again
stdout = iperf(node_one, node_two, ip_prefixes)
@ -186,7 +186,7 @@ class TestLinks:
# change bandwidth in bits per second
link_options = LinkOptions()
link_options.per = 50
session.update_link(node_one.objid, node_two.objid, link_options=link_options)
session.update_link(node_one.id, node_two.id, link_options=link_options)
# run iperf again
stdout = iperf(node_one, node_two, ip_prefixes)
@ -216,7 +216,7 @@ class TestLinks:
# change delay in microseconds
link_options = LinkOptions()
link_options.delay = 1000000
session.update_link(node_one.objid, node_two.objid, link_options=link_options)
session.update_link(node_one.id, node_two.id, link_options=link_options)
# run ping for delay information again
stdout = ping_output(node_one, node_two, ip_prefixes)
@ -249,7 +249,7 @@ class TestLinks:
# change jitter in microseconds
link_options = LinkOptions()
link_options.jitter = 1000000
session.update_link(node_one.objid, node_two.objid, link_options=link_options)
session.update_link(node_one.id, node_two.id, link_options=link_options)
# run iperf again
stdout = iperf(node_one, node_two, ip_prefixes)

View file

@ -48,7 +48,7 @@ class TestNodes:
update_options.set_position(x=position_value, y=position_value)
# when
session.update_node(node.objid, update_options)
session.update_node(node.id, update_options)
# then
assert node.position.x == position_value
@ -59,11 +59,11 @@ class TestNodes:
node = session.add_node()
# when
session.delete_node(node.objid)
session.delete_node(node.id)
# then
with pytest.raises(KeyError):
session.get_object(node.objid)
session.get_object(node.id)
@pytest.mark.parametrize("net_type", NET_TYPES)
def test_net(self, session, net_type):

View file

@ -55,10 +55,10 @@ class TestServices:
node = session.add_node()
# when
session.services.set_service_file(node.objid, SERVICE_ONE, file_name, "# test")
session.services.set_service_file(node.id, SERVICE_ONE, file_name, "# test")
# then
service = session.services.get_service(node.objid, SERVICE_ONE)
service = session.services.get_service(node.id, SERVICE_ONE)
all_files = session.services.all_files(service)
assert service
assert all_files and len(all_files) == 1
@ -69,8 +69,8 @@ class TestServices:
node = session.add_node()
# when
session.services.set_service(node.objid, SERVICE_ONE)
session.services.set_service(node.objid, SERVICE_TWO)
session.services.set_service(node.id, SERVICE_ONE)
session.services.set_service(node.id, SERVICE_TWO)
# then
all_configs = session.services.all_configs()
@ -189,8 +189,8 @@ class TestServices:
node = session.add_node()
# when
session.services.set_service(node.objid, my_service.name)
custom_my_service = session.services.get_service(node.objid, my_service.name)
session.services.set_service(node.id, my_service.name)
custom_my_service = session.services.get_service(node.id, my_service.name)
custom_my_service.startup = ("sh custom.sh",)
# then
@ -205,13 +205,13 @@ class TestServices:
file_name = my_service.configs[0]
file_data_one = "# custom file one"
file_data_two = "# custom file two"
session.services.set_service_file(node_one.objid, my_service.name, file_name, file_data_one)
session.services.set_service_file(node_two.objid, my_service.name, file_name, file_data_two)
session.services.set_service_file(node_one.id, my_service.name, file_name, file_data_one)
session.services.set_service_file(node_two.id, my_service.name, file_name, file_data_two)
# when
custom_service_one = session.services.get_service(node_one.objid, my_service.name)
custom_service_one = session.services.get_service(node_one.id, my_service.name)
session.services.create_service_files(node_one, custom_service_one)
custom_service_two = session.services.get_service(node_two.objid, my_service.name)
custom_service_two = session.services.get_service(node_two.id, my_service.name)
session.services.create_service_files(node_two, custom_service_two)
# then
@ -240,10 +240,10 @@ class TestServices:
node = session.add_node()
# when
no_service = session.services.get_service(node.objid, SERVICE_ONE)
default_service = session.services.get_service(node.objid, SERVICE_ONE, default_service=True)
session.services.set_service(node.objid, SERVICE_ONE)
custom_service = session.services.get_service(node.objid, SERVICE_ONE, default_service=True)
no_service = session.services.get_service(node.id, SERVICE_ONE)
default_service = session.services.get_service(node.id, SERVICE_ONE, default_service=True)
session.services.set_service(node.id, SERVICE_ONE)
custom_service = session.services.get_service(node.id, SERVICE_ONE, default_service=True)
# then
assert no_service is None

View file

@ -64,14 +64,14 @@ class TestXml:
# link nodes to ptp net
for node in [node_one, node_two]:
interface = ip_prefixes.create_interface(node)
session.add_link(node.objid, ptp_node.objid, interface_one=interface)
session.add_link(node.id, ptp_node.id, interface_one=interface)
# instantiate session
session.instantiate()
# get ids for nodes
n1_id = node_one.objid
n2_id = node_two.objid
n1_id = node_one.id
n2_id = node_two.id
# save xml
xml_file = tmpdir.join("session.xml")
@ -118,20 +118,20 @@ class TestXml:
# link nodes to ptp net
for node in [node_one, node_two]:
interface = ip_prefixes.create_interface(node)
session.add_link(node.objid, ptp_node.objid, interface_one=interface)
session.add_link(node.id, ptp_node.id, interface_one=interface)
# set custom values for node service
session.services.set_service(node_one.objid, SshService.name)
session.services.set_service(node_one.id, SshService.name)
service_file = SshService.configs[0]
file_data = "# test"
session.services.set_service_file(node_one.objid, SshService.name, service_file, file_data)
session.services.set_service_file(node_one.id, SshService.name, service_file, file_data)
# instantiate session
session.instantiate()
# get ids for nodes
n1_id = node_one.objid
n2_id = node_two.objid
n1_id = node_one.id
n2_id = node_two.id
# save xml
xml_file = tmpdir.join("session.xml")
@ -155,7 +155,7 @@ class TestXml:
session.open_xml(file_path, start=True)
# retrieve custom service
service = session.services.get_service(node_one.objid, SshService.name)
service = session.services.get_service(node_one.id, SshService.name)
# verify nodes have been recreated
assert session.get_object(n1_id)
@ -184,15 +184,15 @@ class TestXml:
# link nodes
for node in [node_one, node_two]:
interface = ip_prefixes.create_interface(node)
session.add_link(node.objid, wlan_node.objid, interface_one=interface)
session.add_link(node.id, wlan_node.id, interface_one=interface)
# instantiate session
session.instantiate()
# get ids for nodes
wlan_id = wlan_node.objid
n1_id = node_one.objid
n2_id = node_two.objid
wlan_id = wlan_node.id
n1_id = node_one.id
n2_id = node_two.id
# save xml
xml_file = tmpdir.join("session.xml")
@ -251,15 +251,15 @@ class TestXml:
for i, node in enumerate([node_one, node_two]):
node.setposition(x=150 * (i + 1), y=150)
interface = ip_prefixes.create_interface(node)
session.add_link(node.objid, emane_network.objid, interface_one=interface)
session.add_link(node.id, emane_network.id, interface_one=interface)
# instantiate session
session.instantiate()
# get ids for nodes
emane_id = emane_network.objid
n1_id = node_one.objid
n2_id = node_two.objid
emane_id = emane_network.id
n1_id = node_one.id
n2_id = node_two.id
# save xml
xml_file = tmpdir.join("session.xml")

View file

@ -37,7 +37,7 @@ switch = session.add_node(_type=NodeTypes.SWITCH)
for _ in xrange(options.nodes):
node = session.add_node()
interface = prefixes.create_interface(node)
session.add_link(node.objid, switch.objid, interface_one=interface)
session.add_link(node.id, switch.id, interface_one=interface)
# instantiate session
session.instantiate()
@ -90,11 +90,11 @@ session = coreemu.create_session()
node = session.add_node()
# create and retrieve custom service
session.services.set_service(node.objid, "ServiceName")
custom_service = session.services.get_service(node.objid, "ServiceName")
session.services.set_service(node.id, "ServiceName")
custom_service = session.services.get_service(node.id, "ServiceName")
# set custom file data
session.services.set_service_file(node.objid, "ServiceName", "FileName", "custom file data")
session.services.set_service_file(node.id, "ServiceName", "FileName", "custom file data")
# set services to a node, using custom services when defined
session.services.add_services(node, node.type, ["Service1", "Service2"])
@ -116,5 +116,5 @@ emane_network.setposition(x=80, y=50)
# set custom emane model config
config = {}
session.emane.set_model_config(emane_network.objid, EmaneIeee80211abgModel.name, config)
session.emane.set_model_config(emane_network.id, EmaneIeee80211abgModel.name, config)
```

View file

@ -46,9 +46,9 @@ class CoreNs3Node(CoreNode, ns.network.Node):
def __init__(self, *args, **kwds):
ns.network.Node.__init__(self)
# ns-3 ID starts at 0, CORE uses 1
objid = self.GetId() + 1
if 'objid' not in kwds:
kwds['objid'] = objid
_id = self.GetId() + 1
if '_id' not in kwds:
kwds['_id'] = _id
CoreNode.__init__(self, *args, **kwds)
def newnetif(self, net=None, addrlist=None, hwaddr=None, ifindex=None, ifname=None):
@ -118,8 +118,8 @@ class CoreNs3Net(PyCoreNet):
# icon used
type = "wlan"
def __init__(self, session, objid=None, name=None, start=True, policy=None):
PyCoreNet.__init__(self, session, objid, name)
def __init__(self, session, _id=None, name=None, start=True, policy=None):
PyCoreNet.__init__(self, session, _id, name)
self.tapbridge = ns.tap_bridge.TapBridgeHelper()
self._ns3devs = {}
self._tapdevs = {}
@ -480,7 +480,7 @@ class Ns3Session(Session):
node.position.set(x, y, z)
node_data = node.data(0)
self.broadcast_node(node_data)
self.sdt.updatenode(node.objid, flags=0, x=x, y=y, z=z)
self.sdt.updatenode(node.id, flags=0, x=x, y=y, z=z)
time.sleep(0.001 * refresh_ms)
def setupmobilitytracing(self, net, filename, nodes):
@ -488,7 +488,7 @@ class Ns3Session(Session):
Start a tracing thread using the ASCII output from the ns3
mobility helper.
"""
net.mobility = WayPointMobility(session=self, object_id=net.objid)
net.mobility = WayPointMobility(session=self, object_id=net.id)
net.mobility.setendtime()
net.mobility.refresh_ms = 300
net.mobility.empty_queue_stop = False
@ -533,8 +533,7 @@ class Ns3Session(Session):
x, y, z = map(float, items['pos'].split(':'))
vel = map(float, items['vel'].split(':'))
node = nodemap[int(items['node'])]
net.mobility.addwaypoint(time=0, nodenum=node.objid,
x=x, y=y, z=z, speed=vel)
net.mobility.addwaypoint(time=0, nodenum=node.id, x=x, y=y, z=z, speed=vel)
if kickstart:
kickstart = False
self.event_loop.add_event(0, net.mobility.start)