update examples scripts, replacing add_to_server() with two-line statement

note that due to the usage of the 'server' global, it will not work to add a
Session.add_to_server() or core.misc.utils.add_to_server() function
(Boeing r1828)
This commit is contained in:
ahrenholz 2014-03-12 21:38:07 +00:00
parent 5aef9cddbd
commit 481daf4c0d
4 changed files with 8 additions and 48 deletions

View file

@ -25,17 +25,6 @@ coreapi.add_node_class("CORE_NODE_SWITCH",
# node list (count from 1)
n = [None]
def add_to_server(session):
''' Add this session to the server's list if this script is executed from
the core-daemon server.
'''
global server
try:
server.addsession(session)
return True
except NameError:
return False
def main():
usagestr = "usage: %prog [-h] [options] [args]"
parser = optparse.OptionParser(usage = usagestr)
@ -68,7 +57,8 @@ def main():
prefix = ipaddr.IPv4Prefix("10.83.0.0/16")
session = pycore.Session(persistent=True)
add_to_server(session)
if 'server' in globals():
server.addsession(session)
# distributed setup - connect to slave server
slaveport = options.slave.split(':')

View file

@ -16,17 +16,6 @@ from core.emane.ieee80211abg import EmaneIeee80211abgModel
# node list (count from 1)
n = [None]
def add_to_server(session):
''' Add this session to the server's list if this script is executed from
the core-daemon server.
'''
global server
try:
server.addsession(session)
return True
except NameError:
return False
def main():
usagestr = "usage: %prog [-h] [options] [args]"
parser = optparse.OptionParser(usage = usagestr)
@ -62,7 +51,8 @@ def main():
session.location.refscale = 150.0
session.cfg['emane_models'] = "RfPipe, Ieee80211abg, Bypass, AtdlOmni"
session.emane.loadmodels()
add_to_server(session)
if 'server' in globals():
server.addsession(session)
# EMANE WLAN
print "creating EMANE WLAN wlan1"

View file

@ -23,17 +23,6 @@ from core.constants import *
# node list (count from 1)
n = [None]
def add_to_server(session):
''' Add this session to the server's list if this script is executed from
the core-daemon server.
'''
global server
try:
server.addsession(session)
return True
except NameError:
return False
def main():
usagestr = "usage: %prog [-h] [options] [args]"
parser = optparse.OptionParser(usage = usagestr)
@ -64,7 +53,8 @@ def main():
start = datetime.datetime.now()
session = pycore.Session(persistent=True)
add_to_server(session)
if 'server' in globals():
server.addsession(session)
print "creating %d nodes" % options.numnodes
left = None
prefix = None

View file

@ -14,17 +14,6 @@ from core.constants import *
# node list (count from 1)
n = [None]
def add_to_server(session):
''' Add this session to the server's list if this script is executed from
the core-daemon server.
'''
global server
try:
server.addsession(session)
return True
except NameError:
return False
def main():
usagestr = "usage: %prog [-h] [options] [args]"
parser = optparse.OptionParser(usage = usagestr)
@ -54,7 +43,8 @@ def main():
# IP subnet
prefix = ipaddr.IPv4Prefix("10.83.0.0/16")
session = pycore.Session(persistent=True)
add_to_server(session)
if 'server' in globals():
server.addsession(session)
# emulated Ethernet switch
switch = session.addobj(cls = pycore.nodes.SwitchNode, name = "switch")
switch.setposition(x=80,y=50)