distributed example for ptp

This commit is contained in:
Blake Harnden 2019-10-08 21:17:15 -07:00
parent c8d68c332a
commit 7e45168e77
4 changed files with 54 additions and 4 deletions

View file

@ -852,7 +852,7 @@ class CtrlNet(CoreNetwork):
self.brname,
self.updown_script,
)
utils.check_cmd([self.updown_script, self.brname, "startup"])
self.net_cmd([self.updown_script, self.brname, "startup"])
if self.serverintf:
self.net_client.create_interface(self.brname, self.serverintf)
@ -880,7 +880,7 @@ class CtrlNet(CoreNetwork):
self.brname,
self.updown_script,
)
utils.check_cmd([self.updown_script, self.brname, "shutdown"])
self.net_cmd([self.updown_script, self.brname, "shutdown"])
except CoreCommandError:
logging.exception("error issuing shutdown script shutdown")

View file

@ -34,7 +34,7 @@ def main():
options.emulation_server = remote
node_two = session.add_node(node_options=options)
# create not interfaces and link
# create node interfaces and link
interface_one = prefixes.create_interface(node_one)
interface_two = prefixes.create_interface(node_two)
session.add_link(node_one.id, switch.id, interface_one=interface_one)

View file

@ -0,0 +1,50 @@
import logging
import pdb
import sys
from core.emulator.coreemu import CoreEmu
from core.emulator.emudata import IpPrefixes, 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
address = sys.argv[1]
remote = sys.argv[2]
session.address = address
session.add_distributed(remote)
# must be in configuration state for nodes to start, when using "node_add" below
session.set_state(EventTypes.CONFIGURATION_STATE)
# create local node, switch, and remote nodes
node_one = session.add_node()
options = NodeOptions()
options.emulation_server = remote
node_two = session.add_node(node_options=options)
# create node interfaces and link
interface_one = prefixes.create_interface(node_one)
interface_two = prefixes.create_interface(node_two)
session.add_link(node_one.id, node_two.id, interface_one, interface_two)
# instantiate session
session.instantiate()
# pause script for verification
pdb.set_trace()
# shutdown session
coreemu.shutdown()
if __name__ == "__main__":
logging.basicConfig(level=logging.INFO)
main()

View file

@ -24,7 +24,7 @@ def main():
switch_one = session.add_node(_type=NodeTypes.SWITCH)
switch_two = session.add_node(_type=NodeTypes.SWITCH)
# create not interfaces and link
# create node interfaces and link
session.add_link(switch_one.id, switch_two.id)
# instantiate session