From be332a2a29e54da9bdb96ecd270b66dd9652b22d Mon Sep 17 00:00:00 2001 From: Blake Harnden <32446120+bharnden@users.noreply.github.com> Date: Sat, 18 Apr 2020 08:24:26 -0700 Subject: [PATCH] updated all distributed examples to remove usage of common local module to avoid confusion, even if duplicate code --- daemon/examples/python/distributed_emane.py | 23 ++++++++++++++++++-- daemon/examples/python/distributed_lxd.py | 23 ++++++++++++++++++-- daemon/examples/python/distributed_parser.py | 15 ------------- daemon/examples/python/distributed_ptp.py | 23 ++++++++++++++++++-- daemon/examples/python/distributed_switch.py | 23 ++++++++++++++++++-- 5 files changed, 84 insertions(+), 23 deletions(-) delete mode 100644 daemon/examples/python/distributed_parser.py diff --git a/daemon/examples/python/distributed_emane.py b/daemon/examples/python/distributed_emane.py index 6b61e505..4b748803 100644 --- a/daemon/examples/python/distributed_emane.py +++ b/daemon/examples/python/distributed_emane.py @@ -1,12 +1,31 @@ +""" +Example for scripting a standalone distributed EMANE session that does not interact +with the GUI. +""" + +import argparse import logging -import distributed_parser from core.emane.ieee80211abg import EmaneIeee80211abgModel from core.emulator.coreemu import CoreEmu from core.emulator.emudata import IpPrefixes, NodeOptions from core.emulator.enumerations import EventTypes, NodeTypes +def parse(name): + parser = argparse.ArgumentParser(description=f"Run {name} example") + parser.add_argument( + "-a", + "--address", + help="local address that distributed servers will use for gre tunneling", + ) + parser.add_argument( + "-s", "--server", help="distributed server to use for creating nodes" + ) + options = parser.parse_args() + return options + + def main(args): # ip generator for example prefixes = IpPrefixes(ip4_prefix="10.83.0.0/16") @@ -55,5 +74,5 @@ def main(args): if __name__ == "__main__": logging.basicConfig(level=logging.INFO) - args = distributed_parser.parse(__file__) + args = parse(__file__) main(args) diff --git a/daemon/examples/python/distributed_lxd.py b/daemon/examples/python/distributed_lxd.py index 73d24b5a..8d46d599 100644 --- a/daemon/examples/python/distributed_lxd.py +++ b/daemon/examples/python/distributed_lxd.py @@ -1,11 +1,30 @@ +""" +Example for scripting a standalone distributed LXD session that does not interact +with the GUI. +""" + +import argparse import logging -import distributed_parser from core.emulator.coreemu import CoreEmu from core.emulator.emudata import IpPrefixes, NodeOptions from core.emulator.enumerations import EventTypes, NodeTypes +def parse(name): + parser = argparse.ArgumentParser(description=f"Run {name} example") + parser.add_argument( + "-a", + "--address", + help="local address that distributed servers will use for gre tunneling", + ) + parser.add_argument( + "-s", "--server", help="distributed server to use for creating nodes" + ) + options = parser.parse_args() + return options + + def main(args): # ip generator for example prefixes = IpPrefixes(ip4_prefix="10.83.0.0/16") @@ -44,5 +63,5 @@ def main(args): if __name__ == "__main__": logging.basicConfig(level=logging.INFO) - args = distributed_parser.parse(__file__) + args = parse(__file__) main(args) diff --git a/daemon/examples/python/distributed_parser.py b/daemon/examples/python/distributed_parser.py deleted file mode 100644 index 5557efd8..00000000 --- a/daemon/examples/python/distributed_parser.py +++ /dev/null @@ -1,15 +0,0 @@ -import argparse - - -def parse(name): - parser = argparse.ArgumentParser(description=f"Run {name} example") - parser.add_argument( - "-a", - "--address", - help="local address that distributed servers will use for gre tunneling", - ) - parser.add_argument( - "-s", "--server", help="distributed server to use for creating nodes" - ) - options = parser.parse_args() - return options diff --git a/daemon/examples/python/distributed_ptp.py b/daemon/examples/python/distributed_ptp.py index 0138dab3..85069603 100644 --- a/daemon/examples/python/distributed_ptp.py +++ b/daemon/examples/python/distributed_ptp.py @@ -1,11 +1,30 @@ +""" +Example for scripting a standalone distributed peer to peer session that does not +interact with the GUI. +""" + +import argparse import logging -import distributed_parser from core.emulator.coreemu import CoreEmu from core.emulator.emudata import IpPrefixes, NodeOptions from core.emulator.enumerations import EventTypes +def parse(name): + parser = argparse.ArgumentParser(description=f"Run {name} example") + parser.add_argument( + "-a", + "--address", + help="local address that distributed servers will use for gre tunneling", + ) + parser.add_argument( + "-s", "--server", help="distributed server to use for creating nodes" + ) + options = parser.parse_args() + return options + + def main(args): # ip generator for example prefixes = IpPrefixes(ip4_prefix="10.83.0.0/16") @@ -44,5 +63,5 @@ def main(args): if __name__ == "__main__": logging.basicConfig(level=logging.INFO) - args = distributed_parser.parse(__file__) + args = parse(__file__) main(args) diff --git a/daemon/examples/python/distributed_switch.py b/daemon/examples/python/distributed_switch.py index f659abd2..57c6141b 100644 --- a/daemon/examples/python/distributed_switch.py +++ b/daemon/examples/python/distributed_switch.py @@ -1,11 +1,30 @@ +""" +Example for scripting a standalone distributed switch session that does not +interact with the GUI. +""" + +import argparse import logging -import distributed_parser from core.emulator.coreemu import CoreEmu from core.emulator.emudata import IpPrefixes, NodeOptions from core.emulator.enumerations import EventTypes, NodeTypes +def parse(name): + parser = argparse.ArgumentParser(description=f"Run {name} example") + parser.add_argument( + "-a", + "--address", + help="local address that distributed servers will use for gre tunneling", + ) + parser.add_argument( + "-s", "--server", help="distributed server to use for creating nodes" + ) + options = parser.parse_args() + return options + + def main(args): # ip generator for example prefixes = IpPrefixes(ip4_prefix="10.83.0.0/16") @@ -48,5 +67,5 @@ def main(args): if __name__ == "__main__": logging.basicConfig(level=logging.INFO) - args = distributed_parser.parse(__file__) + args = parse(__file__) main(args)