2019-06-27 15:45:35 -07:00
|
|
|
import logging
|
|
|
|
|
|
|
|
from core.emulator.coreemu import CoreEmu
|
2022-05-25 10:51:42 -07:00
|
|
|
from core.emulator.data import IpPrefixes
|
2020-05-20 22:14:03 -07:00
|
|
|
from core.emulator.enumerations import EventTypes
|
|
|
|
from core.nodes.docker import DockerNode
|
2019-06-27 15:45:35 -07:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
logging.basicConfig(level=logging.DEBUG)
|
|
|
|
|
|
|
|
coreemu = CoreEmu()
|
|
|
|
session = coreemu.create_session()
|
|
|
|
session.set_state(EventTypes.CONFIGURATION_STATE)
|
|
|
|
|
|
|
|
# create nodes and interfaces
|
|
|
|
try:
|
|
|
|
prefixes = IpPrefixes(ip4_prefix="10.83.0.0/16")
|
2019-06-28 15:41:55 -07:00
|
|
|
|
|
|
|
# create node one
|
2022-05-25 10:51:42 -07:00
|
|
|
options = DockerNode.create_options()
|
|
|
|
options.image = "ubuntu"
|
2020-06-12 16:52:41 -07:00
|
|
|
node1 = session.add_node(DockerNode, options=options)
|
2020-06-16 09:30:16 -07:00
|
|
|
interface1_data = prefixes.create_iface(node1)
|
2019-06-28 15:41:55 -07:00
|
|
|
|
|
|
|
# create node two
|
2020-06-12 16:52:41 -07:00
|
|
|
node2 = session.add_node(DockerNode, options=options)
|
2020-06-16 09:30:16 -07:00
|
|
|
interface2_data = prefixes.create_iface(node2)
|
2019-06-27 15:45:35 -07:00
|
|
|
|
|
|
|
# add link
|
2020-06-12 16:52:41 -07:00
|
|
|
session.add_link(node1.id, node2.id, interface1_data, interface2_data)
|
2019-06-28 15:41:55 -07:00
|
|
|
|
|
|
|
# instantiate
|
2019-06-28 08:17:11 -07:00
|
|
|
session.instantiate()
|
2019-06-27 15:45:35 -07:00
|
|
|
finally:
|
|
|
|
input("continue to shutdown")
|
|
|
|
coreemu.shutdown()
|