initial commit with some docker nodes integrating with core at a basic level
This commit is contained in:
parent
67595485c6
commit
9825706e03
8 changed files with 686 additions and 1 deletions
30
daemon/examples/docker/README.md
Normal file
30
daemon/examples/docker/README.md
Normal file
|
@ -0,0 +1,30 @@
|
|||
# Docker Support
|
||||
|
||||
Information on how Docker can be leveraged and included to create
|
||||
nodes based on Docker containers and images to interface with
|
||||
existing CORE nodes, when needed.
|
||||
|
||||
# Installation
|
||||
|
||||
```shell
|
||||
sudo apt install docker.io
|
||||
```
|
||||
|
||||
# Configuration
|
||||
|
||||
Custom configuration required to avoid iptable rules being added and removing
|
||||
the need for the default docker network, since core will be orchestrating
|
||||
connections between nodes.
|
||||
|
||||
Place the file below in **/etc/docker/**
|
||||
* daemon.json
|
||||
|
||||
# Tools and Versions Tested With
|
||||
|
||||
* Docker version 18.09.5, build e8ff056
|
||||
* nsenter from util-linux 2.31.1
|
||||
|
||||
# Examples
|
||||
|
||||
This directory provides a few small examples creating Docker nodes
|
||||
and linking them to themselves or with standard CORE nodes.
|
5
daemon/examples/docker/daemon.json
Normal file
5
daemon/examples/docker/daemon.json
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"bridge": "none",
|
||||
"iptables": false
|
||||
|
||||
}
|
31
daemon/examples/docker/docker2core.py
Normal file
31
daemon/examples/docker/docker2core.py
Normal file
|
@ -0,0 +1,31 @@
|
|||
import logging
|
||||
|
||||
from core.emulator.coreemu import CoreEmu
|
||||
from core.emulator.emudata import IpPrefixes
|
||||
from core.emulator.enumerations import NodeTypes, EventTypes
|
||||
|
||||
|
||||
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")
|
||||
node_one = session.add_node(_type=NodeTypes.DOCKER)
|
||||
node_two = session.add_node()
|
||||
interface_one = prefixes.create_interface(node_one)
|
||||
interface_two = prefixes.create_interface(node_two)
|
||||
|
||||
# add link
|
||||
input("press key to continue")
|
||||
session.add_link(node_one.id, node_two.id, interface_one, interface_two)
|
||||
print(node_one.cmd_output("ifconfig"))
|
||||
print(node_two.cmd_output("ifconfig"))
|
||||
input("press key to continue")
|
||||
finally:
|
||||
input("continue to shutdown")
|
||||
coreemu.shutdown()
|
31
daemon/examples/docker/docker2docker.py
Normal file
31
daemon/examples/docker/docker2docker.py
Normal file
|
@ -0,0 +1,31 @@
|
|||
import logging
|
||||
|
||||
from core.emulator.coreemu import CoreEmu
|
||||
from core.emulator.emudata import IpPrefixes
|
||||
from core.emulator.enumerations import NodeTypes, EventTypes
|
||||
|
||||
|
||||
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")
|
||||
node_one = session.add_node(_type=NodeTypes.DOCKER)
|
||||
node_two = session.add_node(_type=NodeTypes.DOCKER)
|
||||
interface_one = prefixes.create_interface(node_one)
|
||||
interface_two = prefixes.create_interface(node_two)
|
||||
|
||||
# add link
|
||||
input("press key to continue")
|
||||
session.add_link(node_one.id, node_two.id, interface_one, interface_two)
|
||||
print(node_one.cmd_output("ifconfig"))
|
||||
print(node_two.cmd_output("ifconfig"))
|
||||
input("press key to continue")
|
||||
finally:
|
||||
input("continue to shutdown")
|
||||
coreemu.shutdown()
|
36
daemon/examples/docker/switch.py
Normal file
36
daemon/examples/docker/switch.py
Normal file
|
@ -0,0 +1,36 @@
|
|||
import logging
|
||||
|
||||
from core.emulator.coreemu import CoreEmu
|
||||
from core.emulator.emudata import IpPrefixes
|
||||
from core.emulator.enumerations import NodeTypes, EventTypes
|
||||
|
||||
|
||||
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")
|
||||
switch = session.add_node(_type=NodeTypes.SWITCH)
|
||||
node_one = session.add_node(_type=NodeTypes.DOCKER)
|
||||
node_two = session.add_node(_type=NodeTypes.DOCKER)
|
||||
node_three = session.add_node()
|
||||
interface_one = prefixes.create_interface(node_one)
|
||||
interface_two = prefixes.create_interface(node_two)
|
||||
interface_three = prefixes.create_interface(node_three)
|
||||
|
||||
# add link
|
||||
input("press key to continue")
|
||||
session.add_link(node_one.id, switch.id, interface_one)
|
||||
session.add_link(node_two.id, switch.id, interface_two)
|
||||
session.add_link(node_three.id, switch.id, interface_three)
|
||||
print(node_one.cmd_output("ifconfig"))
|
||||
print(node_two.cmd_output("ifconfig"))
|
||||
input("press key to continue")
|
||||
finally:
|
||||
input("continue to shutdown")
|
||||
coreemu.shutdown()
|
Loading…
Add table
Add a link
Reference in a new issue