updated distributed python examples a bit to clean things up
This commit is contained in:
parent
78f981463d
commit
630b44627c
11 changed files with 46 additions and 167 deletions
|
@ -1,26 +1,22 @@
|
|||
import logging
|
||||
import pdb
|
||||
import sys
|
||||
|
||||
import distributed_parser
|
||||
from core.emulator.coreemu import CoreEmu
|
||||
from core.emulator.emudata import IpPrefixes, NodeOptions
|
||||
from core.emulator.enumerations import EventTypes, NodeTypes
|
||||
|
||||
|
||||
def main():
|
||||
address = sys.argv[1]
|
||||
remote = sys.argv[2]
|
||||
|
||||
def main(args):
|
||||
# ip generator for example
|
||||
prefixes = IpPrefixes(ip4_prefix="10.83.0.0/16")
|
||||
|
||||
# create emulator instance for creating sessions and utility methods
|
||||
coreemu = CoreEmu({"distributed_address": address})
|
||||
coreemu = CoreEmu({"distributed_address": args.address})
|
||||
session = coreemu.create_session()
|
||||
|
||||
# initialize distributed
|
||||
server_name = "core2"
|
||||
session.distributed.add_server(server_name, remote)
|
||||
session.distributed.add_server(server_name, args.server)
|
||||
|
||||
# must be in configuration state for nodes to start, when using "node_add" below
|
||||
session.set_state(EventTypes.CONFIGURATION_STATE)
|
||||
|
@ -40,7 +36,7 @@ def main():
|
|||
session.instantiate()
|
||||
|
||||
# pause script for verification
|
||||
pdb.set_trace()
|
||||
input("press enter for shutdown")
|
||||
|
||||
# shutdown session
|
||||
coreemu.shutdown()
|
||||
|
@ -48,4 +44,5 @@ def main():
|
|||
|
||||
if __name__ == "__main__":
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
main()
|
||||
args = distributed_parser.parse(__file__)
|
||||
main(args)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue