2019-07-02 15:48:43 +01:00
|
|
|
import logging
|
|
|
|
|
|
|
|
from core.emulator.coreemu import CoreEmu
|
2022-05-25 18:51:42 +01:00
|
|
|
from core.emulator.data import IpPrefixes
|
2020-05-21 06:14:03 +01:00
|
|
|
from core.emulator.enumerations import EventTypes
|
|
|
|
from core.nodes.lxd import LxcNode
|
2019-07-02 15:48:43 +01:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2019-10-14 22:28:18 +01:00
|
|
|
logging.basicConfig(level=logging.INFO)
|
2019-07-02 15:48:43 +01:00
|
|
|
|
|
|
|
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")
|
|
|
|
|
|
|
|
# create node one
|
2022-05-25 18:51:42 +01:00
|
|
|
options = LxcNode.create_options()
|
|
|
|
options.image = "ubuntu:18.04"
|
2020-06-13 00:52:41 +01:00
|
|
|
node1 = session.add_node(LxcNode, options=options)
|
2020-06-16 17:30:16 +01:00
|
|
|
interface1_data = prefixes.create_iface(node1)
|
2019-07-02 15:48:43 +01:00
|
|
|
|
|
|
|
# create node two
|
2020-06-13 00:52:41 +01:00
|
|
|
node2 = session.add_node(LxcNode, options=options)
|
2020-06-16 17:30:16 +01:00
|
|
|
interface2_data = prefixes.create_iface(node2)
|
2019-07-02 15:48:43 +01:00
|
|
|
|
|
|
|
# add link
|
2020-06-13 00:52:41 +01:00
|
|
|
session.add_link(node1.id, node2.id, interface1_data, interface2_data)
|
2019-07-02 15:48:43 +01:00
|
|
|
|
|
|
|
# instantiate
|
|
|
|
session.instantiate()
|
|
|
|
finally:
|
|
|
|
input("continue to shutdown")
|
|
|
|
coreemu.shutdown()
|