diff --git a/framework/device.py b/framework/device.py index eef275d54..53263e6a6 100644 --- a/framework/device.py +++ b/framework/device.py @@ -1,3 +1,17 @@ +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """Track device object information.""" from network_device import NetworkDevice diff --git a/framework/logger.py b/framework/logger.py index d4702cb38..cb71c9fdd 100644 --- a/framework/logger.py +++ b/framework/logger.py @@ -1,3 +1,17 @@ +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """Manages stream and file loggers.""" import json import logging diff --git a/framework/test_runner.py b/framework/test_runner.py index 0733d4353..0ee5e8416 100644 --- a/framework/test_runner.py +++ b/framework/test_runner.py @@ -1,4 +1,17 @@ -#!/usr/bin/env python3 +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """Wrapper for the TestRun that simplifies virtual testing procedure by allowing direct calling from the command line. diff --git a/framework/testrun.py b/framework/testrun.py index 94ad2ef9f..a818c9a45 100644 --- a/framework/testrun.py +++ b/framework/testrun.py @@ -1,3 +1,17 @@ +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """The overall control of the Test Run application. This file provides the integration between all of the diff --git a/net_orc/docker-compose.yml b/net_orc/docker-compose.yml deleted file mode 100644 index 8c50d766a..000000000 --- a/net_orc/docker-compose.yml +++ /dev/null @@ -1,64 +0,0 @@ -version: "3.7" - -services: - - base: - build: - context: network/modules/base - dockerfile: base.Dockerfile - image: test-run/base - container_name: tr-ct-base - - ovs: - depends_on: - - base - build: - context: network/modules/ovs - dockerfile: ovs.Dockerfile - image: test-run/ovs - network_mode: host - container_name: tr-ct-ovs - stdin_open: true - privileged: true - volumes: - - $PWD/network/modules/ovs/python:/ovs/python - # Mount host open vswitch socket to allow container - # access to control open vswitch on the host - - /var/run/openvswitch/db.sock:/var/run/openvswitch/db.sock - # Mount host network namespace to allow container - # access to assign proper namespaces to containers - - /var/run/netns:/var/run/netns - - netorch: - depends_on: - - base - build: - context: . - dockerfile: orchestrator.Dockerfile - image: test-run/orchestrator - network_mode: host - privileged: true - volumes: - - $PWD/cmd:/orchestrator/cmd - - $PWD/network:/orchestrator/network - - $PWD/python:/orchestrator/python - # Mount host docker socket to allow container access - # control docker containers on the host - - /var/run/docker.sock:/var/run/docker.sock - # Mount host open vswitch socket to allow container - # access to control open vswitch on the host - - /var/run/openvswitch/db.sock:/var/run/openvswitch/db.sock - # Mount host network namespace to allow container - # access to assign proper namespaces to containers - - /var/run/netns:/var/run/netns - # Mount the host process information to allow container - # access to configure docker containers and namespaces properly - - /proc:/proc - container_name: network_orchestrator - stdin_open: true - working_dir: /orchestrator - #entrypoint: ["cmd/start"] - # Give more time for stopping so when we stop the container it has - # time to stop all network services gracefuly - stop_grace_period: 60s - entrypoint: ["python3","-u","python/src/run.py"] diff --git a/net_orc/network/devices/faux-dev/python/src/dhcp_check.py b/net_orc/network/devices/faux-dev/python/src/dhcp_check.py index 82dd6e31f..565e33308 100644 --- a/net_orc/network/devices/faux-dev/python/src/dhcp_check.py +++ b/net_orc/network/devices/faux-dev/python/src/dhcp_check.py @@ -1,3 +1,17 @@ +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """Used to check if the DHCP server is functioning as expected""" import time diff --git a/net_orc/network/devices/faux-dev/python/src/dns_check.py b/net_orc/network/devices/faux-dev/python/src/dns_check.py index 73a72e8c8..be9c58d43 100644 --- a/net_orc/network/devices/faux-dev/python/src/dns_check.py +++ b/net_orc/network/devices/faux-dev/python/src/dns_check.py @@ -1,3 +1,17 @@ +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """Used to check if the DNS server is functioning as expected""" import logger diff --git a/net_orc/network/devices/faux-dev/python/src/gateway_check.py b/net_orc/network/devices/faux-dev/python/src/gateway_check.py index 85fe35db0..a913993fc 100644 --- a/net_orc/network/devices/faux-dev/python/src/gateway_check.py +++ b/net_orc/network/devices/faux-dev/python/src/gateway_check.py @@ -1,3 +1,17 @@ +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """Used to check if the Gateway server is functioning as expected""" import logger diff --git a/net_orc/network/devices/faux-dev/python/src/logger.py b/net_orc/network/devices/faux-dev/python/src/logger.py index 97d7f935a..a727ad7bb 100644 --- a/net_orc/network/devices/faux-dev/python/src/logger.py +++ b/net_orc/network/devices/faux-dev/python/src/logger.py @@ -1,3 +1,17 @@ +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """Sets up the logger to be used for the faux-device.""" import json diff --git a/net_orc/network/devices/faux-dev/python/src/ntp_check.py b/net_orc/network/devices/faux-dev/python/src/ntp_check.py index ceef164c6..371e4464c 100644 --- a/net_orc/network/devices/faux-dev/python/src/ntp_check.py +++ b/net_orc/network/devices/faux-dev/python/src/ntp_check.py @@ -1,3 +1,17 @@ +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """Used to check if the NTP server is functioning as expected""" import time import logger diff --git a/net_orc/network/devices/faux-dev/python/src/run.py b/net_orc/network/devices/faux-dev/python/src/run.py index 062a1a643..8f9733eb4 100644 --- a/net_orc/network/devices/faux-dev/python/src/run.py +++ b/net_orc/network/devices/faux-dev/python/src/run.py @@ -1,3 +1,17 @@ +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """Used to run all the various validator modules for the faux-device""" import argparse diff --git a/net_orc/network/devices/faux-dev/python/src/util.py b/net_orc/network/devices/faux-dev/python/src/util.py index 6848206b4..920752217 100644 --- a/net_orc/network/devices/faux-dev/python/src/util.py +++ b/net_orc/network/devices/faux-dev/python/src/util.py @@ -1,3 +1,17 @@ +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """Provides basic utilities for the faux-device.""" import subprocess import shlex diff --git a/net_orc/network/modules/base/python/src/grpc/start_server.py b/net_orc/network/modules/base/python/src/grpc/start_server.py index b4016c831..d372949e5 100644 --- a/net_orc/network/modules/base/python/src/grpc/start_server.py +++ b/net_orc/network/modules/base/python/src/grpc/start_server.py @@ -1,3 +1,17 @@ +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """Base class for starting the gRPC server for a network module.""" from concurrent import futures import grpc diff --git a/net_orc/network/modules/base/python/src/logger.py b/net_orc/network/modules/base/python/src/logger.py index abec00f69..8893b1e8d 100644 --- a/net_orc/network/modules/base/python/src/logger.py +++ b/net_orc/network/modules/base/python/src/logger.py @@ -1,3 +1,17 @@ +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """Sets up the logger to be used for the network modules.""" import json import logging diff --git a/net_orc/network/modules/dhcp-1/python/src/grpc/dhcp_config.py b/net_orc/network/modules/dhcp-1/python/src/grpc/dhcp_config.py index 23e1b4047..99d6bdebd 100644 --- a/net_orc/network/modules/dhcp-1/python/src/grpc/dhcp_config.py +++ b/net_orc/network/modules/dhcp-1/python/src/grpc/dhcp_config.py @@ -1,3 +1,17 @@ +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """Contains all the necessary classes to maintain the DHCP server's configuration""" import re diff --git a/net_orc/network/modules/dhcp-1/python/src/grpc/network_service.py b/net_orc/network/modules/dhcp-1/python/src/grpc/network_service.py index 49732b362..64aab8a07 100644 --- a/net_orc/network/modules/dhcp-1/python/src/grpc/network_service.py +++ b/net_orc/network/modules/dhcp-1/python/src/grpc/network_service.py @@ -1,3 +1,17 @@ +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """gRPC Network Service for the DHCP Server network module""" import proto.grpc_pb2_grpc as pb2_grpc import proto.grpc_pb2 as pb2 diff --git a/net_orc/network/modules/dhcp-2/python/src/grpc/dhcp_config.py b/net_orc/network/modules/dhcp-2/python/src/grpc/dhcp_config.py index 1d93c2d34..f6e79a2ec 100644 --- a/net_orc/network/modules/dhcp-2/python/src/grpc/dhcp_config.py +++ b/net_orc/network/modules/dhcp-2/python/src/grpc/dhcp_config.py @@ -1,3 +1,17 @@ +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """Contains all the necessary classes to maintain the DHCP server's configuration""" import re diff --git a/net_orc/network/modules/dhcp-2/python/src/grpc/network_service.py b/net_orc/network/modules/dhcp-2/python/src/grpc/network_service.py index 49732b362..64aab8a07 100644 --- a/net_orc/network/modules/dhcp-2/python/src/grpc/network_service.py +++ b/net_orc/network/modules/dhcp-2/python/src/grpc/network_service.py @@ -1,3 +1,17 @@ +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """gRPC Network Service for the DHCP Server network module""" import proto.grpc_pb2_grpc as pb2_grpc import proto.grpc_pb2 as pb2 diff --git a/net_orc/network/modules/ntp/python/src/ntp_server.py b/net_orc/network/modules/ntp/python/src/ntp_server.py index 602585196..4eda2b13e 100644 --- a/net_orc/network/modules/ntp/python/src/ntp_server.py +++ b/net_orc/network/modules/ntp/python/src/ntp_server.py @@ -1,3 +1,17 @@ +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """NTP Server""" import datetime import socket diff --git a/net_orc/network/modules/ovs/bin/start_network_service b/net_orc/network/modules/ovs/bin/start_network_service deleted file mode 100644 index 7c38f484a..000000000 --- a/net_orc/network/modules/ovs/bin/start_network_service +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash -e - -if [[ "$EUID" -ne 0 ]]; then - echo "Must run as root." - exit 1 -fi - -asyncRun() { - "$@" & - pid="$!" - trap "echo 'Stopping PID $pid'; kill -SIGTERM $pid" SIGINT SIGTERM - - # A signal emitted while waiting will make the wait command return code > 128 - # Let's wrap it in a loop that doesn't end before the process is indeed stopped - while kill -0 $pid > /dev/null 2>&1; do - wait - done -} - -# -u flag allows python print statements -# to be logged by docker by running unbuffered -asyncRun exec python3 -u /ovs/python/src/run.py \ No newline at end of file diff --git a/net_orc/network/modules/ovs/conf/module_config.json b/net_orc/network/modules/ovs/conf/module_config.json deleted file mode 100644 index 8a440d0ae..000000000 --- a/net_orc/network/modules/ovs/conf/module_config.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "config": { - "meta": { - "name": "ovs", - "display_name": "OVS", - "description": "Setup and configure Open vSwitch" - }, - "network": { - "interface": "veth0", - "enable_wan": false, - "ip_index": 6, - "host": true - }, - "docker": { - "depends_on": "base", - "mounts": [ - { - "source": "runtime/network", - "target": "/runtime/network" - } - ] - } - } -} \ No newline at end of file diff --git a/net_orc/network/modules/ovs/ovs.Dockerfile b/net_orc/network/modules/ovs/ovs.Dockerfile deleted file mode 100644 index cd4710e66..000000000 --- a/net_orc/network/modules/ovs/ovs.Dockerfile +++ /dev/null @@ -1,20 +0,0 @@ -# Image name: test-run/orchestrator -FROM test-run/base:latest - -#Update and get all additional requirements not contained in the base image -RUN apt-get update --fix-missing - -#Install openvswitch -RUN apt-get install -y openvswitch-switch - -# Copy over all configuration files -COPY network/modules/ovs/conf /testrun/conf - -# Copy over all binary files -COPY network/modules/ovs/bin /testrun/bin - -# Copy over all python files -COPY network/modules/ovs/python /testrun/python - -#Install all python requirements for the module -RUN pip3 install -r /testrun/python/requirements.txt \ No newline at end of file diff --git a/net_orc/network/modules/ovs/python/requirements.txt b/net_orc/network/modules/ovs/python/requirements.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/net_orc/network/modules/ovs/python/src/logger.py b/net_orc/network/modules/ovs/python/src/logger.py deleted file mode 100644 index 23e697e43..000000000 --- a/net_orc/network/modules/ovs/python/src/logger.py +++ /dev/null @@ -1,16 +0,0 @@ -"""Sets up the logger to be used for the ovs modules.""" -import logging - -LOGGERS = {} -_LOG_FORMAT = '%(asctime)s %(name)-8s %(levelname)-7s %(message)s' -_DATE_FORMAT = '%b %02d %H:%M:%S' - -# Set level to debug if set as runtime flag -logging.basicConfig(format=_LOG_FORMAT, - datefmt=_DATE_FORMAT, - level=logging.INFO) - -def get_logger(name): - if name not in LOGGERS: - LOGGERS[name] = logging.getLogger(name) - return LOGGERS[name] diff --git a/net_orc/network/modules/ovs/python/src/ovs_control.py b/net_orc/network/modules/ovs/python/src/ovs_control.py deleted file mode 100644 index 765c50f92..000000000 --- a/net_orc/network/modules/ovs/python/src/ovs_control.py +++ /dev/null @@ -1,105 +0,0 @@ -"""OVS Control Module""" -import json -import logger -import util - -CONFIG_FILE = '/ovs/conf/system.json' -DEVICE_BRIDGE = 'tr-d' -INTERNET_BRIDGE = 'tr-c' -LOGGER = logger.get_logger('ovs_ctrl') - -class OVSControl: - """OVS Control""" - def __init__(self): - self._int_intf = None - self._dev_intf = None - self._load_config() - - def add_bridge(self, bridge_name): - LOGGER.info('Adding OVS Bridge: ' + bridge_name) - # Create the bridge using ovs-vsctl commands - # Uses the --may-exist option to prevent failures - # if this bridge already exists by this name it won't fail - # and will not modify the existing bridge - success=util.run_command('ovs-vsctl --may-exist add-br ' + bridge_name) - return success - - def add_port(self,port, bridge_name): - LOGGER.info('Adding Port ' + port + ' to OVS Bridge: ' + bridge_name) - # Add a port to the bridge using ovs-vsctl commands - # Uses the --may-exist option to prevent failures - # if this port already exists on the bridge and will not - # modify the existing bridge - success=util.run_command(f"""ovs-vsctl --may-exist - add-port {bridge_name} {port}""") - return success - - def create_net(self): - LOGGER.info('Creating baseline network') - - # Create data plane - self.add_bridge(DEVICE_BRIDGE) - - # Create control plane - self.add_bridge(INTERNET_BRIDGE) - - # Remove IP from internet adapter - self.set_interface_ip(self._int_intf,'0.0.0.0') - - # Add external interfaces to data and control plane - self.add_port(self._dev_intf,DEVICE_BRIDGE) - self.add_port(self._int_intf,INTERNET_BRIDGE) - - # # Set ports up - self.set_bridge_up(DEVICE_BRIDGE) - self.set_bridge_up(INTERNET_BRIDGE) - - def delete_bridge(self,bridge_name): - LOGGER.info('Deleting OVS Bridge: ' + bridge_name) - # Delete the bridge using ovs-vsctl commands - # Uses the --if-exists option to prevent failures - # if this bridge does not exists - success=util.run_command('ovs-vsctl --if-exists del-br ' + bridge_name) - return success - - def _load_config(self): - LOGGER.info('Loading Configuration: ' + CONFIG_FILE) - with open(CONFIG_FILE, 'r', encoding='utf-8') as conf_file: - config_json = json.load(conf_file) - self._int_intf = config_json['internet_intf'] - self._dev_intf = config_json['device_intf'] - LOGGER.info('Configuration Loaded') - LOGGER.info('Internet Interface: ' + self._int_intf) - LOGGER.info('Device Interface: ' + self._dev_intf) - - def restore_net(self): - LOGGER.info('Restoring Network...') - # Delete data plane - self.delete_bridge(DEVICE_BRIDGE) - - # Delete control plane - self.delete_bridge(INTERNET_BRIDGE) - - LOGGER.info('Network is restored') - - def show_config(self): - LOGGER.info('Show current config of OVS') - success=util.run_command('ovs-vsctl show') - return success - - def set_bridge_up(self,bridge_name): - LOGGER.info('Setting Bridge device to up state: ' + bridge_name) - success=util.run_command('ip link set dev ' + bridge_name + ' up') - return success - - def set_interface_ip(self,interface, ip_addr): - LOGGER.info('Setting interface ' + interface + ' to ' + ip_addr) - # Remove IP from internet adapter - util.run_command('ifconfig ' + interface + ' 0.0.0.0') - -if __name__ == '__main__': - ovs = OVSControl() - ovs.create_net() - ovs.show_config() - ovs.restore_net() - ovs.show_config() diff --git a/net_orc/network/modules/ovs/python/src/run.py b/net_orc/network/modules/ovs/python/src/run.py deleted file mode 100644 index 5787a74e6..000000000 --- a/net_orc/network/modules/ovs/python/src/run.py +++ /dev/null @@ -1,54 +0,0 @@ -"""Run OVS module""" -import logger -import signal -import sys -import time - -from ovs_control import OVSControl - -LOGGER = logger.get_logger('ovs_control_run') - -class OVSControlRun: - """Run the OVS module.""" - def __init__(self): - - signal.signal(signal.SIGINT, self.handler) - signal.signal(signal.SIGTERM, self.handler) - signal.signal(signal.SIGABRT, self.handler) - signal.signal(signal.SIGQUIT, self.handler) - - LOGGER.info('Starting OVS Control') - - # Get all components ready - self._ovs_control = OVSControl() - - self._ovs_control.restore_net() - - self._ovs_control.create_net() - - self._ovs_control.show_config() - - # Get network ready (via Network orchestrator) - LOGGER.info('Network is ready. Waiting for device information...') - - #Loop forever until process is stopped - while True: - LOGGER.info('OVS Running') - time.sleep(1000) - - # TODO: This time should be configurable (How long to hold before exiting, - # this could be infinite too) - #time.sleep(300) - - # Tear down network - #self._ovs_control.shutdown() - - def handler(self, signum): - LOGGER.info('SigtermEnum: ' + str(signal.SIGTERM)) - LOGGER.info('Exit signal received: ' + str(signum)) - if (signum == 2 or signal == signal.SIGTERM): - LOGGER.info('Exit signal received. Restoring network...') - self._ovs_control.shutdown() - sys.exit(1) - -ovs = OVSControlRun() diff --git a/net_orc/network/modules/ovs/python/src/util.py b/net_orc/network/modules/ovs/python/src/util.py deleted file mode 100644 index a3ebbb10a..000000000 --- a/net_orc/network/modules/ovs/python/src/util.py +++ /dev/null @@ -1,23 +0,0 @@ -"""Provides basic utilities for a ovs module.""" -import subprocess -import logger - -LOGGER = logger.get_logger('util') - -def run_command(cmd): - success = False - process = subprocess.Popen(cmd.split(), - stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - stdout, stderr = process.communicate() - if process.returncode != 0: - err_msg = f'{stderr.strip()}. Code: {process.returncode}' - LOGGER.error('Command Failed: ' + cmd) - LOGGER.error('Error: ' + err_msg) - else: - msg = stdout.strip().decode('utf-8') - succ_msg = f'{msg}. Code: {process.returncode}' - LOGGER.info('Command Success: ' + cmd) - LOGGER.info('Success: ' + succ_msg) - success = True - return success diff --git a/net_orc/network/modules/radius/python/src/authenticator.py b/net_orc/network/modules/radius/python/src/authenticator.py index 32f4ac221..0cca1921a 100644 --- a/net_orc/network/modules/radius/python/src/authenticator.py +++ b/net_orc/network/modules/radius/python/src/authenticator.py @@ -1,3 +1,17 @@ +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """Authenticator for the RADIUS Server""" from chewie.chewie import Chewie import logging diff --git a/net_orc/network/modules/template/python/src/template_main.py b/net_orc/network/modules/template/python/src/template_main.py index df2452550..ddf83e2c4 100644 --- a/net_orc/network/modules/template/python/src/template_main.py +++ b/net_orc/network/modules/template/python/src/template_main.py @@ -1,3 +1,17 @@ +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """Python code for the template module.""" if __name__ == "__main__": diff --git a/net_orc/python/src/listener.py b/net_orc/python/src/listener.py index de7a07616..0bbd2b1c9 100644 --- a/net_orc/python/src/listener.py +++ b/net_orc/python/src/listener.py @@ -1,3 +1,17 @@ +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """Intercepts network traffic between network services and the device under test.""" import threading diff --git a/net_orc/python/src/network_device.py b/net_orc/python/src/network_device.py index 1b856da16..f17ac0f0d 100644 --- a/net_orc/python/src/network_device.py +++ b/net_orc/python/src/network_device.py @@ -1,3 +1,17 @@ +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """Track device object information.""" from dataclasses import dataclass diff --git a/net_orc/python/src/network_event.py b/net_orc/python/src/network_event.py index f56adf494..204c97a0a 100644 --- a/net_orc/python/src/network_event.py +++ b/net_orc/python/src/network_event.py @@ -1,3 +1,17 @@ +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """Specify the various types of network events to be reported.""" from enum import Enum diff --git a/net_orc/python/src/network_orchestrator.py b/net_orc/python/src/network_orchestrator.py index 53a94b795..ba16b6a9c 100644 --- a/net_orc/python/src/network_orchestrator.py +++ b/net_orc/python/src/network_orchestrator.py @@ -1,3 +1,17 @@ +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """Network orchestrator is responsible for managing all of the virtual network services""" import getpass @@ -18,6 +32,7 @@ from network_device import NetworkDevice from network_event import NetworkEvent from network_validator import NetworkValidator +from ovs_control import OVSControl LOGGER = logger.get_logger('net_orc') CONFIG_FILE = 'conf/system.json' @@ -73,6 +88,7 @@ def __init__(self, shutil.rmtree(os.path.join(os.getcwd(), NET_DIR), ignore_errors=True) self.network_config = NetworkConfig() self.load_config(config_file) + self._ovs = OVSControl() def start(self): """Start the network orchestrator.""" @@ -142,7 +158,7 @@ def load_config(self, config_file=None): if not os.path.isfile(self._config_file): LOGGER.error('Configuration file is not present at ' + config_file) - LOGGER.info('An example is present in '+ EXAMPLE_CONFIG_FILE) + LOGGER.info('An example is present in ' + EXAMPLE_CONFIG_FILE) sys.exit(1) LOGGER.info('Loading config file: ' + os.path.abspath(self._config_file)) @@ -153,7 +169,7 @@ def load_config(self, config_file=None): def _device_discovered(self, mac_addr): LOGGER.debug( - f'Discovered device {mac_addr}. Waiting for device to obtain IP') + f'Discovered device {mac_addr}. Waiting for device to obtain IP') device = self._get_device(mac_addr=mac_addr) os.makedirs( os.path.join(RUNTIME_DIR, DEVICES_DIR, device.mac_addr.replace(':', @@ -169,12 +185,12 @@ def _device_discovered(self, mac_addr): if device.ip_addr is None: LOGGER.info( - f'Timed out whilst waiting for {mac_addr} to obtain an IP address') + f'Timed out whilst waiting for {mac_addr} to obtain an IP address') return LOGGER.info( - f'Device with mac addr {device.mac_addr} has obtained IP address ' - f'{device.ip_addr}') + f'Device with mac addr {device.mac_addr} has obtained IP address ' + f'{device.ip_addr}') self._start_device_monitor(device) @@ -186,9 +202,8 @@ def _dhcp_lease_ack(self, packet): def _start_device_monitor(self, device): """Start a timer until the steady state has been reached and callback the steady state method for this device.""" - LOGGER.info( - f'Monitoring device with mac addr {device.mac_addr} ' - f'for {str(self._monitor_period)} seconds') + LOGGER.info(f'Monitoring device with mac addr {device.mac_addr} ' + f'for {str(self._monitor_period)} seconds') packet_capture = sniff(iface=self._dev_intf, timeout=self._monitor_period) wrpcap( @@ -293,9 +308,8 @@ def _ci_post_network_create(self): util.run_command(f'ip link set dev {INTERNET_BRIDGE} up') util.run_command(f'dhclient {INTERNET_BRIDGE}') util.run_command('ip route del default via 10.1.0.1') - util.run_command( - f'ip route add default via {self._gateway} ' - f'src {self._ipv4[:-3]} metric 100 dev {INTERNET_BRIDGE}') + util.run_command(f'ip route add default via {self._gateway} ' + f'src {self._ipv4[:-3]} metric 100 dev {INTERNET_BRIDGE}') def create_net(self): LOGGER.info('Creating baseline network') @@ -309,28 +323,14 @@ def create_net(self): if self._single_intf: self._ci_pre_network_create() - # Create data plane - util.run_command('ovs-vsctl add-br ' + DEVICE_BRIDGE) - - # Create control plane - util.run_command('ovs-vsctl add-br ' + INTERNET_BRIDGE) - - # Add external interfaces to data and control plane - util.run_command('ovs-vsctl add-port ' + DEVICE_BRIDGE + ' ' + - self._dev_intf) - util.run_command('ovs-vsctl add-port ' + INTERNET_BRIDGE + ' ' + - self._int_intf) - - # Enable forwarding of eapol packets - util.run_command('ovs-ofctl add-flow ' + DEVICE_BRIDGE + - ' \'table=0, dl_dst=01:80:c2:00:00:03, actions=flood\'') - # Remove IP from internet adapter util.run_command('ifconfig ' + self._int_intf + ' 0.0.0.0') - # Set ports up - util.run_command('ip link set dev ' + DEVICE_BRIDGE + ' up') - util.run_command('ip link set dev ' + INTERNET_BRIDGE + ' up') + # Setup the virtual network + if not self._ovs.create_baseline_net(verify=True): + LOGGER.error('Baseline network validation failed.') + self.stop() + sys.exit(1) if self._single_intf: self._ci_post_network_create() @@ -367,8 +367,9 @@ def _load_network_module(self, module_dir): # Load module information with open(os.path.join(self._path, net_modules_dir, module_dir, - NETWORK_MODULE_METADATA), 'r', - encoding='UTF-8') as module_file_open: + NETWORK_MODULE_METADATA), + 'r', + encoding='UTF-8') as module_file_open: net_module_json = json.load(module_file_open) net_module.name = net_module_json['config']['meta']['name'] @@ -443,13 +444,6 @@ def _get_network_module(self, name): return net_module return None - # Start the OVS network module - # This should always be called before loading all - # other modules to allow for a properly setup base - # network - def _start_ovs_module(self): - self._start_network_service(self._get_network_module('OVS')) - def _start_network_service(self, net_module): LOGGER.debug('Starting net service ' + net_module.display_name) @@ -521,16 +515,12 @@ def start_network_services(self): for net_module in self._net_modules: - # TODO: There should be a better way of doing this - # Do not try starting OVS module again, as it should already be running - if 'OVS' != net_module.display_name: - - # Network modules may just be Docker images, - # so we do not want to start them as containers - if not net_module.enable_container: - continue + # Network modules may just be Docker images, + # so we do not want to start them as containers + if not net_module.enable_container: + continue - self._start_network_service(net_module) + self._start_network_service(net_module) LOGGER.info('All network services are running') self._check_network_services() @@ -555,7 +545,7 @@ def attach_test_module_to_network(self, test_module): container_intf) # Add bridge interface to device bridge - util.run_command('ovs-vsctl add-port ' + DEVICE_BRIDGE + ' ' + bridge_intf) + self._ovs.add_port(port=bridge_intf, bridge_name=DEVICE_BRIDGE) # Get PID for running container # TODO: Some error checking around missing PIDs might be required @@ -620,7 +610,11 @@ def _attach_service_to_network(self, net_module): container_intf) # Add bridge interface to device bridge - util.run_command('ovs-vsctl add-port ' + DEVICE_BRIDGE + ' ' + bridge_intf) + if self._ovs.add_port(port=bridge_intf, bridge_name=DEVICE_BRIDGE): + if not self._ovs.port_exists(bridge_name=DEVICE_BRIDGE, port=bridge_intf): + LOGGER.error('Failed to add ' + net_module.name + ' to device bridge ' + + DEVICE_BRIDGE + '. Exiting.') + sys.exit(1) # Get PID for running container # TODO: Some error checking around missing PIDs might be required @@ -675,8 +669,12 @@ def _attach_service_to_network(self, net_module): container_intf) # Attach bridge interface to internet bridge - util.run_command('ovs-vsctl add-port ' + INTERNET_BRIDGE + ' ' + - bridge_intf) + if self._ovs.add_port(port=bridge_intf, bridge_name=INTERNET_BRIDGE): + if not self._ovs.port_exists(bridge_name=INTERNET_BRIDGE, + port=bridge_intf): + LOGGER.error('Failed to add ' + net_module.name + + ' to internet bridge ' + DEVICE_BRIDGE + '. Exiting.') + sys.exit(1) # Attach container interface to container network namespace util.run_command('ip link set ' + container_intf + ' netns ' + @@ -714,11 +712,8 @@ def restore_net(self): except Exception: # pylint: disable=W0703 continue - # Delete data plane - util.run_command('ovs-vsctl --if-exists del-br tr-d') - - # Delete control plane - util.run_command('ovs-vsctl --if-exists del-br tr-c') + # Clear the virtual network + self._ovs.restore_net() # Restart internet interface if util.interface_exists(self._int_intf): diff --git a/net_orc/python/src/network_validator.py b/net_orc/python/src/network_validator.py index 83ca6f671..a90096f7d 100644 --- a/net_orc/python/src/network_validator.py +++ b/net_orc/python/src/network_validator.py @@ -1,3 +1,17 @@ +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """Holds logic for validation of network services prior to runtime.""" import json import os diff --git a/net_orc/python/src/ovs_control.py b/net_orc/python/src/ovs_control.py new file mode 100644 index 000000000..4c989756b --- /dev/null +++ b/net_orc/python/src/ovs_control.py @@ -0,0 +1,186 @@ +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""OVS Control Module""" +import json +import logger +import util +import os + +CONFIG_FILE = 'conf/system.json' +DEVICE_BRIDGE = 'tr-d' +INTERNET_BRIDGE = 'tr-c' +LOGGER = logger.get_logger('ovs_ctrl') + + +class OVSControl: + """OVS Control""" + + def __init__(self): + self._int_intf = None + self._dev_intf = None + self._load_config() + + def add_bridge(self, bridge_name): + LOGGER.debug('Adding OVS bridge: ' + bridge_name) + # Create the bridge using ovs-vsctl commands + # Uses the --may-exist option to prevent failures + # if this bridge already exists by this name it won't fail + # and will not modify the existing bridge + success = util.run_command('ovs-vsctl --may-exist add-br ' + bridge_name) + return success + + def add_flow(self, bridge_name, flow): + # Add a flow to the bridge using ovs-ofctl commands + LOGGER.debug(f'Adding flow {flow} to bridge: {bridge_name}') + success = util.run_command(f'ovs-ofctl add-flow {bridge_name} \'{flow}\'') + return success + + def add_port(self, port, bridge_name): + LOGGER.debug('Adding port ' + port + ' to OVS bridge: ' + bridge_name) + # Add a port to the bridge using ovs-vsctl commands + # Uses the --may-exist option to prevent failures + # if this port already exists on the bridge and will not + # modify the existing bridge + success = util.run_command(f"""ovs-vsctl --may-exist + add-port {bridge_name} {port}""") + return success + + def get_bridge_ports(self, bridge_name): + # Get a list of all the ports on a bridge + response = util.run_command(f'ovs-vsctl list-ports {bridge_name}', + output=True) + return response[0].splitlines() + + def bridge_exists(self, bridge_name): + # Check if a bridge exists by the name provided + LOGGER.debug(f'Checking if {bridge_name} exists') + success = util.run_command(f'ovs-vsctl br-exists {bridge_name}') + return success + + def port_exists(self, bridge_name, port): + # Check if a port exists on a specified bridge + LOGGER.debug(f'Checking if {bridge_name} exists') + resp = util.run_command(f'ovs-vsctl port-to-br {port}', True) + return resp[0] == bridge_name + + def validate_baseline_network(self): + # Verify the OVS setup of the virtual network + LOGGER.info('Validating baseline network') + + # Verify the device bridge + dev_bridge = self.verify_bridge(DEVICE_BRIDGE, [self._dev_intf]) + LOGGER.info('Device bridge verified: ' + str(dev_bridge)) + + # Verify the internet bridge + int_bridge = self.verify_bridge(INTERNET_BRIDGE, [self._int_intf]) + LOGGER.info('Internet bridge verified: ' + str(int_bridge)) + + return dev_bridge and int_bridge + + def verify_bridge(self, bridge_name, ports): + LOGGER.debug('Verifying bridge: ' + bridge_name) + verified = True + if self.bridge_exists(bridge_name): + bridge_ports = self.get_bridge_ports(bridge_name) + LOGGER.debug('Checking bridge for ports: ' + str(ports)) + for port in ports: + if port not in bridge_ports: + verified = False + break + else: + verified = False + return verified + + def create_baseline_net(self, verify=True): + LOGGER.debug('Creating baseline network') + + # Remove IP from internet adapter + self.set_interface_ip(interface=self._int_intf, ip_addr='0.0.0.0') + + # Create data plane + self.add_bridge(DEVICE_BRIDGE) + + # Create control plane + self.add_bridge(INTERNET_BRIDGE) + + # Remove IP from internet adapter + self.set_interface_ip(self._int_intf, '0.0.0.0') + + # Add external interfaces to data and control plane + self.add_port(self._dev_intf, DEVICE_BRIDGE) + self.add_port(self._int_intf, INTERNET_BRIDGE) + + # Enable forwarding of eapol packets + self.add_flow(bridge_name=DEVICE_BRIDGE, + flow='table=0, dl_dst=01:80:c2:00:00:03, actions=flood') + + # Set ports up + self.set_bridge_up(DEVICE_BRIDGE) + self.set_bridge_up(INTERNET_BRIDGE) + + self.show_config() + + if verify: + return self.validate_baseline_network() + else: + return None + + def delete_bridge(self, bridge_name): + LOGGER.debug('Deleting OVS Bridge: ' + bridge_name) + # Delete the bridge using ovs-vsctl commands + # Uses the --if-exists option to prevent failures + # if this bridge does not exists + success = util.run_command('ovs-vsctl --if-exists del-br ' + bridge_name) + return success + + def _load_config(self): + path = os.path.dirname( + os.path.dirname( + os.path.dirname(os.path.dirname(os.path.realpath(__file__))))) + config_file = os.path.join(path, CONFIG_FILE) + LOGGER.debug('Loading configuration: ' + config_file) + with open(config_file, 'r', encoding='utf-8') as conf_file: + config_json = json.load(conf_file) + self._int_intf = config_json['network']['internet_intf'] + self._dev_intf = config_json['network']['device_intf'] + LOGGER.debug('Configuration loaded') + LOGGER.debug('Internet interface: ' + self._int_intf) + LOGGER.debug('Device interface: ' + self._dev_intf) + + def restore_net(self): + LOGGER.debug('Restoring network...') + # Delete data plane + self.delete_bridge(DEVICE_BRIDGE) + + # Delete control plane + self.delete_bridge(INTERNET_BRIDGE) + + LOGGER.debug('Network is restored') + + def show_config(self): + LOGGER.debug('Show current config of OVS') + success = util.run_command('ovs-vsctl show', output=True) + LOGGER.debug(f'OVS Config\n{success[0]}') + return success + + def set_bridge_up(self, bridge_name): + LOGGER.debug('Setting bridge device to up state: ' + bridge_name) + success = util.run_command('ip link set dev ' + bridge_name + ' up') + return success + + def set_interface_ip(self, interface, ip_addr): + LOGGER.debug('Setting interface ' + interface + ' to ' + ip_addr) + # Remove IP from internet adapter + util.run_command(f'ifconfig {interface} {ip_addr}') diff --git a/net_orc/python/src/util.py b/net_orc/python/src/util.py index a7b07ddf9..ba9527996 100644 --- a/net_orc/python/src/util.py +++ b/net_orc/python/src/util.py @@ -1,3 +1,17 @@ +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """Provides basic utilities for the network orchestrator.""" import subprocess import shlex diff --git a/test_orc/modules/base/python/src/grpc/start_server.py b/test_orc/modules/base/python/src/grpc/start_server.py index b4016c831..d372949e5 100644 --- a/test_orc/modules/base/python/src/grpc/start_server.py +++ b/test_orc/modules/base/python/src/grpc/start_server.py @@ -1,3 +1,17 @@ +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """Base class for starting the gRPC server for a network module.""" from concurrent import futures import grpc diff --git a/test_orc/modules/base/python/src/logger.py b/test_orc/modules/base/python/src/logger.py index 42124beea..64594c7b3 100644 --- a/test_orc/modules/base/python/src/logger.py +++ b/test_orc/modules/base/python/src/logger.py @@ -1,3 +1,17 @@ +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """Sets up the logger to be used for the test modules.""" import json import logging diff --git a/test_orc/modules/base/python/src/test_module.py b/test_orc/modules/base/python/src/test_module.py index 8e10a3637..57795a182 100644 --- a/test_orc/modules/base/python/src/test_module.py +++ b/test_orc/modules/base/python/src/test_module.py @@ -1,3 +1,17 @@ +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """Base class for all core test module functions""" import json import logger diff --git a/test_orc/modules/base/python/src/util.py b/test_orc/modules/base/python/src/util.py index d387db796..0f54c4298 100644 --- a/test_orc/modules/base/python/src/util.py +++ b/test_orc/modules/base/python/src/util.py @@ -1,3 +1,17 @@ +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """Provides basic utilities for a test module.""" import subprocess import shlex diff --git a/test_orc/modules/baseline/python/src/baseline_module.py b/test_orc/modules/baseline/python/src/baseline_module.py index 083123436..22555d369 100644 --- a/test_orc/modules/baseline/python/src/baseline_module.py +++ b/test_orc/modules/baseline/python/src/baseline_module.py @@ -1,3 +1,17 @@ +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """Baseline test module""" from test_module import TestModule diff --git a/test_orc/modules/baseline/python/src/run.py b/test_orc/modules/baseline/python/src/run.py index 1892ed8ae..42eccbef4 100644 --- a/test_orc/modules/baseline/python/src/run.py +++ b/test_orc/modules/baseline/python/src/run.py @@ -1,3 +1,17 @@ +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """Run Baseline module""" import argparse import signal diff --git a/test_orc/modules/dns/python/src/dns_module.py b/test_orc/modules/dns/python/src/dns_module.py index 58ce48123..cd7261da0 100644 --- a/test_orc/modules/dns/python/src/dns_module.py +++ b/test_orc/modules/dns/python/src/dns_module.py @@ -1,3 +1,17 @@ +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """DNS test module""" import subprocess from test_module import TestModule diff --git a/test_orc/modules/dns/python/src/run.py b/test_orc/modules/dns/python/src/run.py index 4cd991804..2b924bbaf 100644 --- a/test_orc/modules/dns/python/src/run.py +++ b/test_orc/modules/dns/python/src/run.py @@ -1,3 +1,17 @@ +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """Run DNS test module""" import argparse import signal diff --git a/test_orc/modules/nmap/python/src/nmap_module.py b/test_orc/modules/nmap/python/src/nmap_module.py index 876343a0f..028471bb9 100644 --- a/test_orc/modules/nmap/python/src/nmap_module.py +++ b/test_orc/modules/nmap/python/src/nmap_module.py @@ -1,3 +1,17 @@ +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """NMAP test module""" import time import util diff --git a/test_orc/modules/nmap/python/src/run.py b/test_orc/modules/nmap/python/src/run.py index 959e30f87..ecb6cd028 100644 --- a/test_orc/modules/nmap/python/src/run.py +++ b/test_orc/modules/nmap/python/src/run.py @@ -1,3 +1,17 @@ +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """Run NMAP test module""" import argparse import signal diff --git a/test_orc/python/src/module.py b/test_orc/python/src/module.py index 72791f86e..185940dd8 100644 --- a/test_orc/python/src/module.py +++ b/test_orc/python/src/module.py @@ -1,3 +1,17 @@ +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """Represemts a test module.""" from dataclasses import dataclass from docker.models.containers import Container diff --git a/test_orc/python/src/runner.py b/test_orc/python/src/runner.py index d82935057..363f800af 100644 --- a/test_orc/python/src/runner.py +++ b/test_orc/python/src/runner.py @@ -1,3 +1,17 @@ +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """Provides high level management of the test orchestrator.""" import time import logger diff --git a/test_orc/python/src/test_orchestrator.py b/test_orc/python/src/test_orchestrator.py index 4b65bae12..14b39720d 100644 --- a/test_orc/python/src/test_orchestrator.py +++ b/test_orc/python/src/test_orchestrator.py @@ -1,3 +1,17 @@ +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """Provides high level management of the test orchestrator.""" import getpass import os diff --git a/testing/test_baseline.py b/testing/test_baseline.py index b356983dd..246857581 100644 --- a/testing/test_baseline.py +++ b/testing/test_baseline.py @@ -1,3 +1,17 @@ +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import json import pytest import re