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(':')