examples: restore docker switch example to previous state

This commit is contained in:
Blake Harnden 2022-06-08 14:06:54 -07:00
parent 1d718aeda2
commit 1aa9d4bccf

View file

@ -3,16 +3,17 @@ import logging
from core.emulator.coreemu import CoreEmu from core.emulator.coreemu import CoreEmu
from core.emulator.data import IpPrefixes from core.emulator.data import IpPrefixes
from core.emulator.enumerations import EventTypes from core.emulator.enumerations import EventTypes
from core.nodes.base import CoreNode
from core.nodes.docker import DockerNode from core.nodes.docker import DockerNode
from core.nodes.network import SwitchNode from core.nodes.network import SwitchNode
if __name__ == "__main__": if __name__ == "__main__":
logging.basicConfig(level=logging.DEBUG) logging.basicConfig(level=logging.DEBUG)
# create core session
coreemu = CoreEmu() coreemu = CoreEmu()
session = coreemu.create_session() session = coreemu.create_session()
session.set_state(EventTypes.CONFIGURATION_STATE) session.set_state(EventTypes.CONFIGURATION_STATE)
try: try:
prefixes = IpPrefixes(ip4_prefix="10.83.0.0/16") prefixes = IpPrefixes(ip4_prefix="10.83.0.0/16")
@ -21,9 +22,7 @@ if __name__ == "__main__":
# node one # node one
options = DockerNode.create_options() options = DockerNode.create_options()
options.image = "core" options.image = "ubuntu"
options.binds.append(("/tmp/testbind", "/tmp/bind"))
options.volumes.append(("var.log", "/tmp/var.log", True, True))
node1 = session.add_node(DockerNode, options=options) node1 = session.add_node(DockerNode, options=options)
interface1_data = prefixes.create_iface(node1) interface1_data = prefixes.create_iface(node1)
@ -32,13 +31,13 @@ if __name__ == "__main__":
interface2_data = prefixes.create_iface(node2) interface2_data = prefixes.create_iface(node2)
# node three # node three
# node_three = session.add_node(CoreNode) node_three = session.add_node(CoreNode)
# interface_three = prefixes.create_iface(node_three) interface_three = prefixes.create_iface(node_three)
# add links # add links
session.add_link(node1.id, switch.id, interface1_data) session.add_link(node1.id, switch.id, interface1_data)
session.add_link(node2.id, switch.id, interface2_data) session.add_link(node2.id, switch.id, interface2_data)
# session.add_link(node_three.id, switch.id, interface_three) session.add_link(node_three.id, switch.id, interface_three)
# instantiate # instantiate
session.instantiate() session.instantiate()