Skip to content

Commit 11c45c3

Browse files
authored
Merge branch 'master' into add-dns-solution
2 parents 0f0610f + 74c0653 commit 11c45c3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+2950
-0
lines changed

.github/workflows/pythonpackage.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3+
4+
name: Python package
5+
6+
on:
7+
push:
8+
branches: [ master ]
9+
pull_request:
10+
branches: [ master ]
11+
12+
jobs:
13+
build:
14+
15+
runs-on: ubuntu-latest
16+
strategy:
17+
matrix:
18+
python-version: [3.5, 3.6, 3.7, 3.8]
19+
20+
steps:
21+
- uses: actions/checkout@v2
22+
- name: Set up Python ${{ matrix.python-version }}
23+
uses: actions/setup-python@v2
24+
with:
25+
python-version: ${{ matrix.python-version }}
26+
- name: Install dependencies
27+
run: |
28+
python -m pip install --upgrade pip
29+
pip install wheel flake8 pytest
30+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
31+
- name: Lint with flake8
32+
run: |
33+
# stop the build if there are Python syntax errors or undefined names
34+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
35+
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
36+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
37+
#- name: Test with pytest
38+
# run: |
39+
# pytest

nets/3routers/.venv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/root/.mininet-venv

nets/3routers/ospf3r.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,29 @@
11
#!/usr/bin/python
22

33
import os
4+
5+
# Activate virtual environment if a venv path has been specified in .venv
6+
# This must be executed only if this file has been executed as a
7+
# script (instead of a module)
8+
if __name__ == '__main__':
9+
# Check if .venv file exists
10+
if os.path.exists('.venv'):
11+
with open('.venv', 'r') as venv_file:
12+
# Get virtualenv path from .venv file
13+
# and remove trailing newline chars
14+
venv_path = venv_file.read().rstrip()
15+
# Get path of the activation script
16+
venv_path = os.path.join(venv_path, 'bin/activate_this.py')
17+
if not os.path.exists(venv_path):
18+
print('Virtual environment path specified in .venv '
19+
'points to an invalid path\n')
20+
exit(-2)
21+
with open(venv_path) as f:
22+
# Read the activation script
23+
code = compile(f.read(), venv_path, 'exec')
24+
# Execute the activation script to activate the venv
25+
exec(code, {'__file__': venv_path})
26+
427
import shutil
528
from mininet.topo import Topo
629
from mininet.node import Host

nets/8r-1c-in-band-isis/.env

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export WORKSPACE=${HOME}/workspace
2+
export CONTROL_PLANE=${WORKSPACE}/rose-srv6-control-plane
3+
4+
export NODE_MANAGER_PATH=${CONTROL_PLANE}/srv6_controller/node-manager/
5+
export NODE_MANAGER_GRPC_PORT=12345

nets/8r-1c-in-band-isis/.venv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/root/.mininet-venv

nets/8r-1c-in-band-isis/isis8d.py

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,32 @@
11
#!/usr/bin/python
22

33
import os
4+
5+
# Activate virtual environment if a venv path has been specified in .venv
6+
# This must be executed only if this file has been executed as a
7+
# script (instead of a module)
8+
if __name__ == '__main__':
9+
# Check if .venv file exists
10+
if os.path.exists('.venv'):
11+
with open('.venv', 'r') as venv_file:
12+
# Get virtualenv path from .venv file
13+
venv_path = venv_file.read()
14+
# Get path of the activation script
15+
venv_path = os.path.join(venv_path, 'bin/activate_this.py')
16+
if not os.path.exists(venv_path):
17+
print('Virtual environment path specified in .venv '
18+
'points to an invalid path\n')
19+
exit(-2)
20+
with open(venv_path) as f:
21+
# Read the activation script
22+
code = compile(f.read(), venv_path, 'exec')
23+
# Execute the activation script to activate the venv
24+
exec(code, {'__file__': venv_path})
25+
26+
from argparse import ArgumentParser
427
import python_hosts
528
import shutil
29+
from dotenv import load_dotenv
630
from mininet.topo import Topo
731
from mininet.node import Host
832
from mininet.net import Mininet
@@ -21,6 +45,21 @@
2145
# to be added to /etc/hosts
2246
ETC_HOSTS_FILE = './etc-hosts'
2347

48+
# Define whether to start the node managers on the routers or not
49+
START_NODE_MANAGERS = False
50+
51+
# Load environment variables from .env file
52+
load_dotenv()
53+
54+
# Get node manager path
55+
NODE_MANAGER_PATH = os.getenv('NODE_MANAGER_PATH', None)
56+
if NODE_MANAGER_PATH is not None:
57+
NODE_MANAGER_PATH = os.path.join(NODE_MANAGER_PATH,
58+
'srv6_manager.py')
59+
# Get gRPC server port
60+
NODE_MANAGER_GRPC_PORT = os.getenv('NODE_MANAGER_GRPC_PORT', None)
61+
62+
2463
class BaseNode(Host):
2564

2665
def __init__(self, name, *args, **kwargs):
@@ -91,6 +130,15 @@ class Router(BaseNode):
91130
def __init__(self, name, *args, **kwargs):
92131
BaseNode.__init__(self, name, *args, **kwargs)
93132

133+
def config(self, **kwargs):
134+
# Init steps
135+
BaseNode.config(self, **kwargs)
136+
# Start node managers
137+
if START_NODE_MANAGERS:
138+
self.cmd('python %s --grpc-port %s &'
139+
% (NODE_MANAGER_PATH, NODE_MANAGER_GRPC_PORT))
140+
141+
94142
# the add_link function creates a link and assigns the interface names
95143
# as node1-node2 and node2-node1
96144
def add_link (my_net, node1, node2):
@@ -249,8 +297,45 @@ def simpleTest():
249297
stopAll()
250298

251299

300+
def parse_arguments():
301+
# Get parser
302+
parser = ArgumentParser(
303+
description='Emulation of a Mininet topology (8 routers running '
304+
'IS-IS, 1 controller in-band'
305+
)
306+
parser.add_argument(
307+
'--start-node-managers', dest='start_node_managers',
308+
action='store_true', default=False,
309+
help='Define whether to start node manager on routers or not'
310+
)
311+
# Parse input parameters
312+
args = parser.parse_args()
313+
# Return the arguments
314+
return args
315+
252316

253317
if __name__ == '__main__':
318+
# Parse command-line arguments
319+
args = parse_arguments()
320+
# Define whether to start node manager on routers or not
321+
START_NODE_MANAGERS = args.start_node_managers
322+
if START_NODE_MANAGERS:
323+
if NODE_MANAGER_PATH is None:
324+
print('Error: --start-node-managers requires NODE_MANAGER_PATH '
325+
'variable')
326+
print('NODE_MANAGER_PATH variable not set in .env file\n')
327+
exit(-2)
328+
if not os.path.exists(NODE_MANAGER_PATH):
329+
print('Error: --start-node-managers requires NODE_MANAGER_PATH '
330+
'variable')
331+
print('NODE_MANAGER_PATH defined in .env file '
332+
'points to a non existing folder\n')
333+
exit(-2)
334+
if NODE_MANAGER_GRPC_PORT is None:
335+
print('Error: --start-node-managers requires '
336+
'NODE_MANAGER_GRPC_PORT variable')
337+
print('NODE_MANAGER_GRPC_PORT variable not set in .env file\n')
338+
exit(-2)
254339
# Tell mininet to print useful information
255340
setLogLevel('info')
256341
simpleTest()

nets/8r-1c-out-band-isis/.env

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export WORKSPACE=${HOME}/workspace
2+
export CONTROL_PLANE=${WORKSPACE}/rose-srv6-control-plane
3+
4+
export NODE_MANAGER_PATH=${CONTROL_PLANE}/srv6_controller/node-manager/
5+
export NODE_MANAGER_GRPC_PORT=12345

nets/8r-1c-out-band-isis/.venv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/root/.mininet-venv

nets/8r-1c-out-band-isis/isis8d.py

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,33 @@
11
#!/usr/bin/python
22

33
import os
4+
5+
# Activate virtual environment if a venv path has been specified in .venv
6+
# This must be executed only if this file has been executed as a
7+
# script (instead of a module)
8+
if __name__ == '__main__':
9+
# Check if .venv file exists
10+
if os.path.exists('.venv'):
11+
with open('.venv', 'r') as venv_file:
12+
# Get virtualenv path from .venv file
13+
# and remove trailing newline chars
14+
venv_path = venv_file.read().rstrip()
15+
# Get path of the activation script
16+
venv_path = os.path.join(venv_path, 'bin/activate_this.py')
17+
if not os.path.exists(venv_path):
18+
print('Virtual environment path specified in .venv '
19+
'points to an invalid path\n')
20+
exit(-2)
21+
with open(venv_path) as f:
22+
# Read the activation script
23+
code = compile(f.read(), venv_path, 'exec')
24+
# Execute the activation script to activate the venv
25+
exec(code, {'__file__': venv_path})
26+
27+
from argparse import ArgumentParser
428
import python_hosts
529
import shutil
30+
from dotenv import load_dotenv
631
from mininet.topo import Topo
732
from mininet.node import Host, OVSBridge
833
from mininet.net import Mininet
@@ -21,6 +46,21 @@
2146
# to be added to /etc/hosts
2247
ETC_HOSTS_FILE = './etc-hosts'
2348

49+
# Define whether to start the node managers on the routers or not
50+
START_NODE_MANAGERS = False
51+
52+
# Load environment variables from .env file
53+
load_dotenv()
54+
55+
# Get node manager path
56+
NODE_MANAGER_PATH = os.getenv('NODE_MANAGER_PATH', None)
57+
if NODE_MANAGER_PATH is not None:
58+
NODE_MANAGER_PATH = os.path.join(NODE_MANAGER_PATH,
59+
'srv6_manager.py')
60+
# Get gRPC server port
61+
NODE_MANAGER_GRPC_PORT = os.getenv('NODE_MANAGER_GRPC_PORT', None)
62+
63+
2464
class BaseNode(Host):
2565

2666
def __init__(self, name, *args, **kwargs):
@@ -91,6 +131,14 @@ class Router(BaseNode):
91131
def __init__(self, name, *args, **kwargs):
92132
BaseNode.__init__(self, name, *args, **kwargs)
93133

134+
def config(self, **kwargs):
135+
# Init steps
136+
BaseNode.config(self, **kwargs)
137+
# Start node managers
138+
if START_NODE_MANAGERS:
139+
self.cmd('python %s --grpc-port %s &'
140+
% (NODE_MANAGER_PATH, NODE_MANAGER_GRPC_PORT))
141+
94142

95143
class Switch(OVSBridge):
96144
def __init__(self, name, *args, **kwargs):
@@ -303,8 +351,45 @@ def simpleTest():
303351
stopAll()
304352

305353

354+
def parse_arguments():
355+
# Get parser
356+
parser = ArgumentParser(
357+
description='Emulation of a Mininet topology (8 routers running '
358+
'IS-IS, 1 controller out-of-band'
359+
)
360+
parser.add_argument(
361+
'--start-node-managers', dest='start_node_managers',
362+
action='store_true', default=False,
363+
help='Define whether to start node manager on routers or not'
364+
)
365+
# Parse input parameters
366+
args = parser.parse_args()
367+
# Return the arguments
368+
return args
369+
306370

307371
if __name__ == '__main__':
372+
# Parse command-line arguments
373+
args = parse_arguments()
374+
# Define whether to start node manager on routers or not
375+
START_NODE_MANAGERS = args.start_node_managers
376+
if START_NODE_MANAGERS:
377+
if NODE_MANAGER_PATH is None:
378+
print('Error: --start-node-managers requires NODE_MANAGER_PATH '
379+
'variable')
380+
print('NODE_MANAGER_PATH variable not set in .env file\n')
381+
exit(-2)
382+
if not os.path.exists(NODE_MANAGER_PATH):
383+
print('Error: --start-node-managers requires NODE_MANAGER_PATH '
384+
'variable')
385+
print('NODE_MANAGER_PATH defined in .env file '
386+
'points to a non existing folder\n')
387+
exit(-2)
388+
if NODE_MANAGER_GRPC_PORT is None:
389+
print('Error: --start-node-managers requires '
390+
'NODE_MANAGER_GRPC_PORT variable')
391+
print('NODE_MANAGER_GRPC_PORT variable not set in .env file\n')
392+
exit(-2)
308393
# Tell mininet to print useful information
309394
setLogLevel('info')
310395
simpleTest()

nets/8r-1c-srv6-pm/.env

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export WORKSPACE=${HOME}/workspace
2+
export ROSE_SRV6_TUTORIAL=${WORKSPACE}/rose-srv6-tutorial
3+
4+
# Configure SRV6_PFPML_PATH
5+
export SRV6_PFPML_PATH=/opt/srv6-pm-xdp-ebpf/srv6-pfplm
6+
7+
# Node manager params
8+
export NODE_MANAGER_PATH=${CONTROL_PLANE}/srv6_controller/node-manager/
9+
export NODE_MANAGER_GRPC_PORT=12345

0 commit comments

Comments
 (0)