Skip to content
Merged

Dhcp #64

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
fc348c1
Add initial work for ip control module
jhughesoti Jun 16, 2023
a2bbe01
Implement ip control module with additional cleanup methods
jhughesoti Jun 16, 2023
016472b
Update link check to not use error stream
jhughesoti Jun 19, 2023
2d7b076
Add error checking around container network configurations
jhughesoti Jun 19, 2023
b71ba1d
Add network cleanup for namespaces and links
jhughesoti Jun 19, 2023
386f41f
formatting
jhughesoti Jun 19, 2023
31572e5
initial work on adding grpc functions for dhcp tests
jhughesoti Jun 26, 2023
b965bb1
rework code to allow for better usage and unit testing
jhughesoti Jun 28, 2023
9a74d65
working poc for test containers and grpc client to dhcp-1
jhughesoti Jun 29, 2023
d442421
Move grpc client code into base image
jhughesoti Jun 29, 2023
ec7cc65
Move grpc proto builds outside of dockerfile into module startup script
jhughesoti Jun 29, 2023
e3102ca
Setup pythonpath var in test module base startup process
jhughesoti Jun 30, 2023
ed6257f
pylinting and logging updates
jhughesoti Jun 30, 2023
c53263b
Add python path resolving to network modules
jhughesoti Jun 30, 2023
62d46b7
Change lease resolving method to fix pylint issue
jhughesoti Jun 30, 2023
227ad58
cleanup unit tests
jhughesoti Jul 3, 2023
976f116
cleanup unit tests
jhughesoti Jul 3, 2023
8a2526b
Add grpc updates to dhcp2 module
jhughesoti Jul 3, 2023
0fd5a8d
Add grpc updates to dhcp2 module
jhughesoti Jul 3, 2023
22658d5
merge dev
jhughesoti Jul 3, 2023
1b3f13f
fix line endings
jhughesoti Jul 3, 2023
d4e3e91
misc cleanup
jhughesoti Jul 3, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions local/system.json.example
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"network": {
"device_intf": "enx123456789123",
"internet_intf": "enx123456789124"
},
"log_level": "INFO",
"startup_timeout": 60,
"monitor_period": 300,
"runtime": 1200
{
"network": {
"device_intf": "enx123456789123",
"internet_intf": "enx123456789124"
},
"log_level": "INFO",
"startup_timeout": 60,
"monitor_period": 300,
"runtime": 1200
}
4 changes: 4 additions & 0 deletions modules/network/base/base.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@ FROM ubuntu:jammy

ARG MODULE_NAME=base
ARG MODULE_DIR=modules/network/$MODULE_NAME
ARG COMMON_DIR=framework/python/src/common

# Install common software
RUN apt-get update && apt-get install -y net-tools iputils-ping tcpdump iproute2 jq python3 python3-pip dos2unix

# Install common python modules
COPY $COMMON_DIR/ /testrun/python/src/common

# Setup the base python requirements
COPY $MODULE_DIR/python /testrun/python

Expand Down
25 changes: 25 additions & 0 deletions modules/network/base/bin/setup_python_path
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

ROOT_DIRECTORY="/testrun/python/src"

# Function to recursively add subdirectories to PYTHONPATH
add_subdirectories_to_pythonpath() {
local directory=$1
local subdirectories=( "$directory"/* )
local subdirectory

for subdirectory in "${subdirectories[@]}"; do
if [[ -d "$subdirectory" && ! "$subdirectory" = *'__pycache__' ]]; then
export PYTHONPATH="$PYTHONPATH:$subdirectory"
add_subdirectories_to_pythonpath "$subdirectory"
fi
done
}

# Set PYTHONPATH initially to an empty string
export PYTHONPATH="$ROOT_DIRECTORY"

# Add all subdirectories to PYTHONPATH
add_subdirectories_to_pythonpath "$ROOT_DIRECTORY"

echo "$PYTHONPATH"
6 changes: 3 additions & 3 deletions modules/network/base/bin/start_grpc
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@
# See the License for the specific language governing permissions and
# limitations under the License.

GRPC_DIR="/testrun/python/src/grpc"
GRPC_DIR="/testrun/python/src/grpc_server"
GRPC_PROTO_DIR="proto"
GRPC_PROTO_FILE="grpc.proto"

#Move into the grpc directory
pushd $GRPC_DIR >/dev/null 2>&1

#Build the grpc proto file every time before starting server
python3 -m grpc_tools.protoc --proto_path=. ./$GRPC_PROTO_DIR/$GRPC_PROTO_FILE --python_out=. --grpc_python_out=.
python3 -u -m grpc_tools.protoc --proto_path=. ./$GRPC_PROTO_DIR/$GRPC_PROTO_FILE --python_out=. --grpc_python_out=.

popd >/dev/null 2>&1

#Start the grpc server
python3 -u $GRPC_DIR/start_server.py $@
python3 -u $GRPC_DIR/start_server.py $@ &

12 changes: 9 additions & 3 deletions modules/network/base/bin/start_module
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,16 @@ else
INTF=$DEFINED_IFACE
fi

echo "Starting module $MODULE_NAME on local interface $INTF..."
# Setup the PYTHONPATH so all imports work as expected
echo "Setting up PYTHONPATH..."
export PYTHONPATH=$($BIN_DIR/setup_python_path)
echo "PYTHONPATH: $PYTHONPATH"

echo "Configuring binary files..."
$BIN_DIR/setup_binaries $BIN_DIR

echo "Starting module $MODULE_NAME on local interface $INTF..."

# Wait for interface to become ready
$BIN_DIR/wait_for_interface $INTF

Expand All @@ -80,9 +86,9 @@ then
if [[ ! -z $GRPC_PORT && ! $GRPC_PORT == "null" ]]
then
echo "gRPC port resolved from config: $GRPC_PORT"
$BIN_DIR/start_grpc "-p $GRPC_PORT" &
$BIN_DIR/start_grpc "-p $GRPC_PORT"
else
$BIN_DIR/start_grpc &
$BIN_DIR/start_grpc
fi
fi

Expand Down
3 changes: 2 additions & 1 deletion modules/network/base/python/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
grpcio
grpcio-tools
grpcio-tools
netifaces
2 changes: 1 addition & 1 deletion modules/network/base/python/src/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
log_level = logging.getLevelName(log_level_str)
except OSError:
# TODO: Print out warning that log level is incorrect or missing
LOG_LEVEL = _DEFAULT_LEVEL
log_level = _DEFAULT_LEVEL

log_format = logging.Formatter(fmt=_LOG_FORMAT, datefmt=_DATE_FORMAT)

Expand Down
2 changes: 1 addition & 1 deletion modules/network/dhcp-1/bin/start_network_service
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ DHCP_LOG_FILE=/runtime/network/dhcp1-dhcpd.log
RA_PID_FILE=/var/run/radvd/radvd.pid
RA_LOG_FILE=/runtime/network/dhcp1-radvd.log

echo "Starrting Network Service..."
echo "Starting Network Service..."

#Enable IPv6 Forwarding
sysctl net.ipv6.conf.all.forwarding=1
Expand Down
54 changes: 28 additions & 26 deletions modules/network/dhcp-1/conf/dhcpd.conf
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
default-lease-time 300;

failover peer "failover-peer" {
primary;
address 10.10.10.2;
port 847;
peer address 10.10.10.3;
peer port 647;
max-response-delay 60;
max-unacked-updates 10;
mclt 3600;
split 128;
load balance max seconds 3;
}

subnet 10.10.10.0 netmask 255.255.255.0 {
option ntp-servers 10.10.10.5;
option subnet-mask 255.255.255.0;
option broadcast-address 10.10.10.255;
option routers 10.10.10.1;
option domain-name-servers 10.10.10.4;
pool {
failover peer "failover-peer";
range 10.10.10.10 10.10.10.20;
}
}
default-lease-time 300;

failover peer "failover-peer" {
primary;
address 10.10.10.2;
port 847;
peer address 10.10.10.3;
peer port 647;
max-response-delay 60;
max-unacked-updates 10;
mclt 3600;
split 128;
load balance max seconds 3;
}

subnet 10.10.10.0 netmask 255.255.255.0 {
option ntp-servers 10.10.10.5;
option subnet-mask 255.255.255.0;
option broadcast-address 10.10.10.255;
option routers 10.10.10.1;
option domain-name-servers 10.10.10.4;
interface veth0;
authoritative;
pool {
failover peer "failover-peer";
range 10.10.10.10 10.10.10.20;
}
}
8 changes: 7 additions & 1 deletion modules/network/dhcp-1/dhcp-1.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ FROM test-run/base:latest
ARG MODULE_NAME=dhcp-1
ARG MODULE_DIR=modules/network/$MODULE_NAME

# Install all necessary packages
RUN apt-get install -y wget

#Update the oui.txt file from ieee
RUN wget http://standards-oui.ieee.org/oui.txt -P /usr/local/etc/

# Install dhcp server
RUN apt-get install -y isc-dhcp-server radvd

Expand All @@ -28,4 +34,4 @@ COPY $MODULE_DIR/conf /testrun/conf
COPY $MODULE_DIR/bin /testrun/bin

# Copy over all python files
COPY $MODULE_DIR/python /testrun/python
COPY $MODULE_DIR/python /testrun/python
Loading