From 6cd3258e61b707ecb8a108a53832b00ccc6482bf Mon Sep 17 00:00:00 2001 From: jhughesbiot Date: Thu, 7 Sep 2023 10:22:53 -0600 Subject: [PATCH 1/7] Change ntp server to use chronyd --- modules/network/ntp/bin/start_network_service | 6 + modules/network/ntp/conf/chrony.conf | 62 +++ modules/network/ntp/ntp.Dockerfile | 66 ++-- modules/network/ntp/python/src/chronyd.py | 49 +++ modules/network/ntp/python/src/ntp_server.py | 354 ++---------------- 5 files changed, 188 insertions(+), 349 deletions(-) create mode 100644 modules/network/ntp/conf/chrony.conf create mode 100644 modules/network/ntp/python/src/chronyd.py diff --git a/modules/network/ntp/bin/start_network_service b/modules/network/ntp/bin/start_network_service index 91129b18f..17a41309b 100644 --- a/modules/network/ntp/bin/start_network_service +++ b/modules/network/ntp/bin/start_network_service @@ -19,9 +19,15 @@ LOG_FILE="/runtime/network/ntp.log" echo Starting ntp +# Route internet traffic through gateway +ip route add default via 10.10.10.1 dev veth0 + #Create and set permissions on the log file touch $LOG_FILE chown $HOST_USER $LOG_FILE +# Move the config files to the correct location +cp /testrun/conf/chrony.conf /etc/chrony/ + #Start the NTP server python3 -u $PYTHON_SRC_DIR/ntp_server.py > $LOG_FILE diff --git a/modules/network/ntp/conf/chrony.conf b/modules/network/ntp/conf/chrony.conf new file mode 100644 index 000000000..5504e0fe4 --- /dev/null +++ b/modules/network/ntp/conf/chrony.conf @@ -0,0 +1,62 @@ +# Welcome to the chrony configuration file. See chrony.conf(5) for more +# information about usable directives. + +# Include configuration files found in /etc/chrony/conf.d. +confdir /etc/chrony/conf.d + +# This will use (up to): +# - 4 sources from ntp.ubuntu.com which some are ipv6 enabled +# - 2 sources from 2.ubuntu.pool.ntp.org which is ipv6 enabled as well +# - 1 source from [01].ubuntu.pool.ntp.org each (ipv4 only atm) +# This means by default, up to 6 dual-stack and up to 2 additional IPv4-only +# sources will be used. +# At the same time it retains some protection against one of the entries being +# down (compare to just using one of the lines). See (LP: #1754358) for the +# discussion. +# +# About using servers from the NTP Pool Project in general see (LP: #104525). +# Approved by Ubuntu Technical Board on 2011-02-08. +# See http://www.pool.ntp.org/join.html for more information. +pool time.google.com iburst maxsources 4 + +# Use time sources from DHCP. +sourcedir /run/chrony-dhcp + +# Use NTP sources found in /etc/chrony/sources.d. +sourcedir /etc/chrony/sources.d + +# This directive specify the location of the file containing ID/key pairs for +# NTP authentication. +keyfile /etc/chrony/chrony.keys + +# This directive0 specify the file into which chronyd will store the rate +# information. +driftfile /var/lib/chrony/chrony.drift + +# Save NTS keys and cookies. +ntsdumpdir /var/lib/chrony + +# Uncomment the following line to turn logging on. +#log tracking measurements statistics + +# Log files location. +logdir /var/log/chrony + +# Stop bad estimates upsetting machine clock. +maxupdateskew 100.0 + +# This directive enables kernel synchronisation (every 11 minutes) of the +# real-time clock. Note that it can’t be used along with the 'rtcfile' directive. +rtcsync + +# Step the system clock instead of slewing it if the adjustment is larger than +# one second, but only in the first three clock updates. +makestep 1 3 + +# Get TAI-UTC offset and leap seconds from the system tz database. +# This directive must be commented out when using time sources serving +# leap-smeared time. +leapsectz right/UTC + +# Enable NTP server and allow all traffic to this server +allow \ No newline at end of file diff --git a/modules/network/ntp/ntp.Dockerfile b/modules/network/ntp/ntp.Dockerfile index cfd78c05e..aa6f63e3f 100644 --- a/modules/network/ntp/ntp.Dockerfile +++ b/modules/network/ntp/ntp.Dockerfile @@ -1,30 +1,36 @@ -# 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. - -# Image name: test-run/ntp -FROM test-run/base:latest - -ARG MODULE_NAME=ntp -ARG MODULE_DIR=modules/network/$MODULE_NAME - -# Copy over all configuration files -COPY $MODULE_DIR/conf /testrun/conf - -# Copy over all binary files -COPY $MODULE_DIR/bin /testrun/bin - -# Copy over all python files -COPY $MODULE_DIR/python /testrun/python - -EXPOSE 123/udp +# 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. + +# Image name: test-run/ntp +FROM test-run/base:latest + +ARG MODULE_NAME=ntp +ARG MODULE_DIR=modules/network/$MODULE_NAME + +# Set DEBIAN_FRONTEND to noninteractive mode +ENV DEBIAN_FRONTEND=noninteractive + +# Install all necessary packages +RUN apt-get install -y chrony + +# Copy over all configuration files +COPY $MODULE_DIR/conf /testrun/conf + +# Copy over all binary files +COPY $MODULE_DIR/bin /testrun/bin + +# Copy over all python files +COPY $MODULE_DIR/python /testrun/python + +EXPOSE 123/udp diff --git a/modules/network/ntp/python/src/chronyd.py b/modules/network/ntp/python/src/chronyd.py new file mode 100644 index 000000000..b8ce7db56 --- /dev/null +++ b/modules/network/ntp/python/src/chronyd.py @@ -0,0 +1,49 @@ +# 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 +chronyd server booted from the chronyd.conf file""" +from common import logger +from common import util +import os + +LOG_NAME = 'chronyd' +LOGGER = None +PID_FILE='/run/chrony/chronyd.pid' + +class ChronydServer: + """Represents the chronyd server""" + + def __init__(self): + global LOGGER + LOGGER = logger.get_logger(LOG_NAME, 'ntp') + + def start(self): + LOGGER.info('Starting chronyd server') + response = util.run_command('chronyd', False) + LOGGER.info('chronyd server started: ' + str(response)) + return response + + def stop(self): + LOGGER.info('Stopping chronyd server') + with open(PID_FILE, 'r', encoding='UTF-8') as f: + pid = f.read() + response = util.run_command(f'kill {pid}', False) + LOGGER.info('chronyd server stopped: ' + str(response)) + return response + + def is_running(self): + LOGGER.info('Checking chronyd server') + running = os.path.exists(PID_FILE) + LOGGER.info('chronyd server status: ' + str(running)) + return running \ No newline at end of file diff --git a/modules/network/ntp/python/src/ntp_server.py b/modules/network/ntp/python/src/ntp_server.py index 4eda2b13e..14a3d9bac 100644 --- a/modules/network/ntp/python/src/ntp_server.py +++ b/modules/network/ntp/python/src/ntp_server.py @@ -11,328 +11,44 @@ # 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 -import struct -import time -import queue - -import threading -import select - -task_queue = queue.Queue() -stop_flag = False - - -def system_to_ntp_time(timestamp): - """Convert a system time to a NTP time. - - Parameters: - timestamp -- timestamp in system time - - Returns: - corresponding NTP time - """ - return timestamp + NTP.NTP_DELTA - - -def _to_int(timestamp): - """Return the integral part of a timestamp. - - Parameters: - timestamp -- NTP timestamp - - Retuns: - integral part - """ - return int(timestamp) - - -def _to_frac(timestamp, n=32): - """Return the fractional part of a timestamp. - - Parameters: - timestamp -- NTP timestamp - n -- number of bits of the fractional part - - Retuns: - fractional part - """ - return int(abs(timestamp - _to_int(timestamp)) * 2**n) - - -def _to_time(integ, frac, n=32): - """Return a timestamp from an integral and fractional part. - - Parameters: - integ -- integral part - frac -- fractional part - n -- number of bits of the fractional part - - Retuns: - timestamp - """ - return integ + float(frac) / 2**n - - -class NTPException(Exception): - """Exception raised by this module.""" - pass - - -class NTP: - """Helper class defining constants.""" - - _SYSTEM_EPOCH = datetime.date(*time.gmtime(0)[0:3]) - """system epoch""" - _NTP_EPOCH = datetime.date(1900, 1, 1) - """NTP epoch""" - NTP_DELTA = (_SYSTEM_EPOCH - _NTP_EPOCH).days * 24 * 3600 - """delta between system and NTP time""" - - REF_ID_TABLE = { - 'DNC': 'DNC routing protocol', - 'NIST': 'NIST public modem', - 'TSP': 'TSP time protocol', - 'DTS': 'Digital Time Service', - 'ATOM': 'Atomic clock (calibrated)', - 'VLF': 'VLF radio (OMEGA, etc)', - 'callsign': 'Generic radio', - 'LORC': 'LORAN-C radionavidation', - 'GOES': 'GOES UHF environment satellite', - 'GPS': 'GPS UHF satellite positioning', - } - """reference identifier table""" - - STRATUM_TABLE = { - 0: 'unspecified', - 1: 'primary reference', - } - """stratum table""" - - MODE_TABLE = { - 0: 'unspecified', - 1: 'symmetric active', - 2: 'symmetric passive', - 3: 'client', - 4: 'server', - 5: 'broadcast', - 6: 'reserved for NTP control messages', - 7: 'reserved for private use', - } - """mode table""" - LEAP_TABLE = { - 0: 'no warning', - 1: 'last minute has 61 seconds', - 2: 'last minute has 59 seconds', - 3: 'alarm condition (clock not synchronized)', - } - """leap indicator table""" - - -class NTPPacket: - """NTP packet class. - - This represents an NTP packet. - """ - - _PACKET_FORMAT = '!B B B b 11I' - """packet format to pack/unpack""" - - def __init__(self, version=4, mode=3, tx_timestamp=0): - """Constructor. - - Parameters: - version -- NTP version - mode -- packet mode (client, server) - tx_timestamp -- packet transmit timestamp - """ - self.leap = 0 - """leap second indicator""" - self.version = version - """version""" - self.mode = mode - """mode""" - self.stratum = 0 - """stratum""" - self.poll = 0 - """poll interval""" - self.precision = 0 - """precision""" - self.root_delay = 0 - """root delay""" - self.root_dispersion = 0 - """root dispersion""" - self.ref_id = 0 - """reference clock identifier""" - self.ref_timestamp = 0 - """reference timestamp""" - self.orig_timestamp = 0 - self.orig_timestamp_high = 0 - self.orig_timestamp_low = 0 - """originate timestamp""" - self.recv_timestamp = 0 - """receive timestamp""" - self.tx_timestamp = tx_timestamp - self.tx_timestamp_high = 0 - self.tx_timestamp_low = 0 - """tansmit timestamp""" - - def to_data(self): - """Convert this NTPPacket to a buffer that can be sent over a socket. - - Returns: - buffer representing this packet - - Raises: - NTPException -- in case of invalid field - """ - try: - packed = struct.pack( - NTPPacket._PACKET_FORMAT, - (self.leap << 6 | self.version << 3 | self.mode), - self.stratum, - self.poll, - self.precision, - _to_int(self.root_delay) << 16 | _to_frac(self.root_delay, 16), - _to_int(self.root_dispersion) << 16 - | _to_frac(self.root_dispersion, 16), - self.ref_id, - _to_int(self.ref_timestamp), - _to_frac(self.ref_timestamp), - #Change by lichen, avoid loss of precision - self.orig_timestamp_high, - self.orig_timestamp_low, - _to_int(self.recv_timestamp), - _to_frac(self.recv_timestamp), - _to_int(self.tx_timestamp), - _to_frac(self.tx_timestamp)) - except struct.error as exc: - raise NTPException('Invalid NTP packet fields.') from exc - return packed - - def from_data(self, data): - """Populate this instance from a NTP packet payload received from - the network. - - Parameters: - data -- buffer payload - - Raises: - NTPException -- in case of invalid packet format - """ - try: - unpacked = struct.unpack( - NTPPacket._PACKET_FORMAT, - data[0:struct.calcsize(NTPPacket._PACKET_FORMAT)]) - except struct.error as exc: - raise NTPException('Invalid NTP packet.') from exc - - self.leap = unpacked[0] >> 6 & 0x3 - self.version = unpacked[0] >> 3 & 0x7 - self.mode = unpacked[0] & 0x7 - self.stratum = unpacked[1] - self.poll = unpacked[2] - self.precision = unpacked[3] - self.root_delay = float(unpacked[4]) / 2**16 - self.root_dispersion = float(unpacked[5]) / 2**16 - self.ref_id = unpacked[6] - self.ref_timestamp = _to_time(unpacked[7], unpacked[8]) - self.orig_timestamp = _to_time(unpacked[9], unpacked[10]) - self.orig_timestamp_high = unpacked[9] - self.orig_timestamp_low = unpacked[10] - self.recv_timestamp = _to_time(unpacked[11], unpacked[12]) - self.tx_timestamp = _to_time(unpacked[13], unpacked[14]) - self.tx_timestamp_high = unpacked[13] - self.tx_timestamp_low = unpacked[14] - - def get_tx_timestamp(self): - return (self.tx_timestamp_high, self.tx_timestamp_low) - - def set_origin_timestamp(self, high, low): - self.orig_timestamp_high = high - self.orig_timestamp_low = low +from common import logger +from chronyd import ChronydServer +import time +LOG_NAME = 'ntp_server' -class RecvThread(threading.Thread): - """Thread class to recieve all requests""" +class NTPServer: + """Represents the NTP server""" def __init__(self): - threading.Thread.__init__(self) - #self.local_socket = local_socket - - def run(self): + global LOGGER + LOGGER = logger.get_logger(LOG_NAME, 'ntp') + self._chronyd = ChronydServer() + + def start(self): + return self._chronyd.start() + + def stop(self): + return self._chronyd.stop() + + def is_running(self): + return self._chronyd.is_running() + +if __name__ == '__main__': + ntp = NTPServer() + ntp.start() + # give some time for the server to start + running = False + for _ in range(10): + running = ntp.is_running() + if running: + break + else: + time.sleep(1) + # Enter loop if ntp server is running + if running: while True: - if stop_flag: - print('RecvThread Ended') - break - rlist, wlist, elist = select.select([local_socket], [], [], 1) # pylint: disable=unused-variable - if len(rlist) != 0: - print(f'Received {len(rlist)} packets') - for temp_socket in rlist: - try: - data, addr = temp_socket.recvfrom(1024) - recv_timestamp = system_to_ntp_time(time.time()) - task_queue.put((data, addr, recv_timestamp)) - except socket.error as msg: - print(msg) - - -class WorkThread(threading.Thread): - """Thread class to process all requests and respond""" - def __init__(self): - threading.Thread.__init__(self) - #self.local_socket = local_socket - - def run(self): - while True: - if stop_flag: - print('WorkThread Ended') - break - try: - data, addr, recv_timestamp = task_queue.get(timeout=1) - recv_packet = NTPPacket() - recv_packet.from_data(data) - timestamp_high, timestamp_low = recv_packet.get_tx_timestamp() - send_packet = NTPPacket(version=4, mode=4) - send_packet.stratum = 2 - send_packet.poll = 10 - - # send_packet.precision = 0xfa - # send_packet.root_delay = 0x0bfa - # send_packet.root_dispersion = 0x0aa7 - # send_packet.ref_id = 0x808a8c2c - - send_packet.ref_timestamp = recv_timestamp - 5 - send_packet.set_origin_timestamp(timestamp_high, timestamp_low) - send_packet.recv_timestamp = recv_timestamp - send_packet.tx_timestamp = system_to_ntp_time(time.time()) - local_socket.sendto(send_packet.to_data(), addr) - print(f'Sent to {addr[0]}:{addr[1]}') - except queue.Empty: - continue - - -listen_ip = '0.0.0.0' -listen_port = 123 -local_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) -local_socket.bind((listen_ip, listen_port)) -print('local socket: ', local_socket.getsockname()) -recvThread = RecvThread() -recvThread.start() -workThread = WorkThread() -workThread.start() - -while True: - try: - time.sleep(0.5) - except KeyboardInterrupt: - print('Exiting...') - stop_flag = True - recvThread.join() - workThread.join() - #local_socket.close() - print('Exited') - break + time.sleep(1) + else: + LOGGER.info('NTP server failed to start') From 162670a463393e8071be3ca1a3635b5fd82bc0fc Mon Sep 17 00:00:00 2001 From: jhughesbiot Date: Thu, 7 Sep 2023 10:24:06 -0600 Subject: [PATCH 2/7] Minor fixes to dhcp builds --- modules/network/dhcp-1/dhcp-1.Dockerfile | 75 ++++++++++++------------ modules/network/dhcp-2/dhcp-2.Dockerfile | 75 ++++++++++++------------ 2 files changed, 78 insertions(+), 72 deletions(-) diff --git a/modules/network/dhcp-1/dhcp-1.Dockerfile b/modules/network/dhcp-1/dhcp-1.Dockerfile index 6b941d878..db0114880 100644 --- a/modules/network/dhcp-1/dhcp-1.Dockerfile +++ b/modules/network/dhcp-1/dhcp-1.Dockerfile @@ -1,37 +1,40 @@ -# 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. - -# Image name: test-run/dhcp-primary -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 systemd - -# Copy over all configuration files -COPY $MODULE_DIR/conf /testrun/conf - -# Copy over all binary files -COPY $MODULE_DIR/bin /testrun/bin - -# Copy over all python files +# 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. + +# Image name: test-run/dhcp-primary +FROM test-run/base:latest + +ARG MODULE_NAME=dhcp-1 +ARG MODULE_DIR=modules/network/$MODULE_NAME + +#Update and get all additional requirements not contained in the base image +RUN apt-get update --fix-missing + +# 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 systemd + +# Copy over all configuration files +COPY $MODULE_DIR/conf /testrun/conf + +# Copy over all binary files +COPY $MODULE_DIR/bin /testrun/bin + +# Copy over all python files COPY $MODULE_DIR/python /testrun/python \ No newline at end of file diff --git a/modules/network/dhcp-2/dhcp-2.Dockerfile b/modules/network/dhcp-2/dhcp-2.Dockerfile index 153aa50e7..e33803c60 100644 --- a/modules/network/dhcp-2/dhcp-2.Dockerfile +++ b/modules/network/dhcp-2/dhcp-2.Dockerfile @@ -1,37 +1,40 @@ -# 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. - -# Image name: test-run/dhcp-primary -FROM test-run/base:latest - -ARG MODULE_NAME=dhcp-2 -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 systemd - -# Copy over all configuration files -COPY $MODULE_DIR/conf /testrun/conf - -# Copy over all binary files -COPY $MODULE_DIR/bin /testrun/bin - -# Copy over all python files +# 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. + +# Image name: test-run/dhcp-primary +FROM test-run/base:latest + +ARG MODULE_NAME=dhcp-2 +ARG MODULE_DIR=modules/network/$MODULE_NAME + +#Update and get all additional requirements not contained in the base image +RUN apt-get update --fix-missing + +# 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 systemd + +# Copy over all configuration files +COPY $MODULE_DIR/conf /testrun/conf + +# Copy over all binary files +COPY $MODULE_DIR/bin /testrun/bin + +# Copy over all python files COPY $MODULE_DIR/python /testrun/python \ No newline at end of file From 1f85317ce0be37da5174d91e8aefc69bd5fd1f04 Mon Sep 17 00:00:00 2001 From: Jacob Boddey Date: Fri, 8 Sep 2023 12:58:38 +0100 Subject: [PATCH 3/7] Add conf line --- modules/network/ntp/conf/chrony.conf | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/network/ntp/conf/chrony.conf b/modules/network/ntp/conf/chrony.conf index 5504e0fe4..f68e3f415 100644 --- a/modules/network/ntp/conf/chrony.conf +++ b/modules/network/ntp/conf/chrony.conf @@ -59,4 +59,7 @@ makestep 1 3 leapsectz right/UTC # Enable NTP server and allow all traffic to this server -allow \ No newline at end of file +allow + +# Continue if no internet connection is present +local stratum 10 \ No newline at end of file From cbecad7b36f79d2020adb474f38a82f5f2aa237b Mon Sep 17 00:00:00 2001 From: Jacob Boddey Date: Fri, 8 Sep 2023 13:47:54 +0100 Subject: [PATCH 4/7] Try CI network again --- framework/python/src/net_orc/network_orchestrator.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/framework/python/src/net_orc/network_orchestrator.py b/framework/python/src/net_orc/network_orchestrator.py index d1fd9cdb0..f0a2df761 100644 --- a/framework/python/src/net_orc/network_orchestrator.py +++ b/framework/python/src/net_orc/network_orchestrator.py @@ -272,7 +272,7 @@ def _ci_pre_network_create(self): """ Stores network properties to restore network after network creation and flushes internet interface """ - + LOGGER.info('Pre network create') self._ethmac = subprocess.check_output( f'cat /sys/class/net/{self._session.get_internet_interface()}/address', shell=True).decode('utf-8').strip() @@ -294,7 +294,7 @@ def _ci_pre_network_create(self): def _ci_post_network_create(self): """ Restore network connection in CI environment """ - LOGGER.info('post cr') + LOGGER.info('Post network create') util.run_command(((f'ip address del {self._ipv4} ' + 'dev {self._session.get_internet_interface()}'))) util.run_command((f'ip -6 address del {self._ipv6} ' + @@ -320,7 +320,7 @@ def _ci_post_network_create(self): def create_net(self): LOGGER.info('Creating baseline network') - if os.getenv('GITHUB_ACTIONS'): + if 'CI' in os.environ: self._ci_pre_network_create() # Setup the virtual network @@ -329,7 +329,7 @@ def create_net(self): self.stop() sys.exit(1) - if os.getenv("GITHUB_ACTIONS"): + if 'CI' in os.environ: self._ci_post_network_create() self._create_private_net() From da7a33a75eff0fc8a45747a729112915ed2a75c0 Mon Sep 17 00:00:00 2001 From: jhughesbiot <50999916+jhughesbiot@users.noreply.github.com> Date: Tue, 12 Sep 2023 08:27:33 -0600 Subject: [PATCH 5/7] Update chrony.conf --- modules/network/ntp/conf/chrony.conf | 3 --- 1 file changed, 3 deletions(-) diff --git a/modules/network/ntp/conf/chrony.conf b/modules/network/ntp/conf/chrony.conf index f68e3f415..c7fe108b5 100644 --- a/modules/network/ntp/conf/chrony.conf +++ b/modules/network/ntp/conf/chrony.conf @@ -60,6 +60,3 @@ leapsectz right/UTC # Enable NTP server and allow all traffic to this server allow - -# Continue if no internet connection is present -local stratum 10 \ No newline at end of file From a840b7b104c2236466b4420e8a67e4167baf4de7 Mon Sep 17 00:00:00 2001 From: Jacob Boddey Date: Mon, 18 Sep 2023 13:27:30 +0100 Subject: [PATCH 6/7] Remove ntp from testing --- local/system.json.example | 4 ++-- testing/tests/test_tests.json | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/local/system.json.example b/local/system.json.example index 17e5b0891..c640669b4 100644 --- a/local/system.json.example +++ b/local/system.json.example @@ -6,6 +6,6 @@ "log_level": "INFO", "startup_timeout": 60, "monitor_period": 300, - "runtime": 1200, + "runtime": 120, "max_device_reports": 5 -} \ No newline at end of file +} diff --git a/testing/tests/test_tests.json b/testing/tests/test_tests.json index 728f7764f..0b151d6ca 100644 --- a/testing/tests/test_tests.json +++ b/testing/tests/test_tests.json @@ -14,8 +14,6 @@ "ethmac": "02:42:aa:00:00:02", "expected_results": { "security.nmap.ports": "Compliant", - "ntp.network.ntp_support": "Compliant", - "ntp.network.ntp_dhcp": "Compliant", "connection.shared_address": "Compliant", "connection.dhcp_address": "Compliant", "connection.mac_address": "Compliant", From b7f210393c16af062a198e790a793ca7b139a387 Mon Sep 17 00:00:00 2001 From: J Boddey Date: Mon, 18 Sep 2023 14:02:41 +0100 Subject: [PATCH 7/7] Disable protocol module Signed-off-by: J Boddey --- testing/device_configs/only_baseline/device_config.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/testing/device_configs/only_baseline/device_config.json b/testing/device_configs/only_baseline/device_config.json index 925929f81..fef1ceecf 100644 --- a/testing/device_configs/only_baseline/device_config.json +++ b/testing/device_configs/only_baseline/device_config.json @@ -20,6 +20,9 @@ }, "tls": { "enabled": false + }, + "protocol": { + "enabled": false } } }