some initial remote node commands using fabric
This commit is contained in:
parent
cc9c0eec96
commit
f83f98262f
3 changed files with 127 additions and 14 deletions
55
daemon/examples/python/distributed.py
Normal file
55
daemon/examples/python/distributed.py
Normal file
|
@ -0,0 +1,55 @@
|
|||
import logging
|
||||
|
||||
from core.emulator.coreemu import CoreEmu
|
||||
from core.emulator.emudata import NodeOptions
|
||||
from core.emulator.enumerations import EventTypes
|
||||
|
||||
|
||||
def main():
|
||||
# ip generator for example
|
||||
# prefixes = IpPrefixes(ip4_prefix="10.83.0.0/16")
|
||||
|
||||
# create emulator instance for creating sessions and utility methods
|
||||
coreemu = CoreEmu()
|
||||
session = coreemu.create_session()
|
||||
|
||||
# initialize distributed
|
||||
session.servers.add("core2")
|
||||
session.init_distributed()
|
||||
|
||||
# must be in configuration state for nodes to start, when using "node_add" below
|
||||
session.set_state(EventTypes.CONFIGURATION_STATE)
|
||||
|
||||
# create switch network node
|
||||
# switch = session.add_node(_type=NodeTypes.SWITCH)
|
||||
|
||||
# create nodes
|
||||
options = NodeOptions()
|
||||
options.emulation_server = "10.10.4.38"
|
||||
options.emulation_server = "core2"
|
||||
session.add_node(node_options=options)
|
||||
# interface = prefixes.create_interface(node_one)
|
||||
# session.add_link(node_one.id, switch.id, interface_one=interface)
|
||||
|
||||
# node_two = session.add_node()
|
||||
# interface = prefixes.create_interface(node_two)
|
||||
# session.add_link(node_two.id, switch.id, interface_one=interface)
|
||||
|
||||
# instantiate session
|
||||
session.instantiate()
|
||||
|
||||
# print("starting iperf server on node: %s" % node_one.name)
|
||||
# node_one.cmd(["iperf", "-s", "-D"])
|
||||
# node_one_address = prefixes.ip4_address(node_one)
|
||||
#
|
||||
# print("node %s connecting to %s" % (node_two.name, node_one_address))
|
||||
# node_two.client.icmd(["iperf", "-t", "10", "-c", node_one_address])
|
||||
# node_one.cmd(["killall", "-9", "iperf"])
|
||||
|
||||
# shutdown session
|
||||
coreemu.shutdown()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
main()
|
Loading…
Add table
Add a link
Reference in a new issue