From fd35b792230b21829003db66b71342481de6797a Mon Sep 17 00:00:00 2001 From: Edward Moscardini Date: Tue, 3 Oct 2023 11:10:43 -0400 Subject: [PATCH 1/3] removed port 80 from port check --- CHANGELOG | 12 ++++++++++++ router_registration.py | 4 ++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 6a4c7e3..8b9122b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,18 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.0.13] + +### Changed + + - Removed port 80 from port check list + +## [1.0.12] + +### Added + +- Added switches to handle registration without contacting MOP for information. --jwt, --controller, --hostId --linkListener + ## [1.0.11] - 2023-09-18 ### Changed diff --git a/router_registration.py b/router_registration.py index cf9b8b4..d93d16c 100755 --- a/router_registration.py +++ b/router_registration.py @@ -37,7 +37,7 @@ def check_controller(controller_host): check_controller_certificate(controller_host) # check controller for ports - port_list = [80, 443, 6262] + port_list = [443, 6262] for port in port_list: if not check_host_port(controller_host, port): logging.error("Unable to communicate with " @@ -241,7 +241,7 @@ def create_parser(): :return: A Namespace containing arguments """ - __version__ = '1.0.12' + __version__ = '1.0.13' parser = argparse.ArgumentParser() mgroup = parser.add_mutually_exclusive_group(required=True) From b291c32b37540ea2c58c294ea76949ae7b418bdc Mon Sep 17 00:00:00 2001 From: Edward Moscardini Date: Tue, 3 Oct 2023 11:12:50 -0400 Subject: [PATCH 2/3] removed nfhelp download; updated success msg --- CHANGELOG | 1 + router_registration.py | 45 ++---------------------------------------- 2 files changed, 3 insertions(+), 43 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 8b9122b..27b17c3 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -7,6 +7,7 @@ All notable changes to this project will be documented in this file. The format ### Changed - Removed port 80 from port check list + - Removed nfhelp download ## [1.0.12] diff --git a/router_registration.py b/router_registration.py index d93d16c..baf7617 100755 --- a/router_registration.py +++ b/router_registration.py @@ -10,7 +10,6 @@ import json import time import ssl -import tarfile import ipaddress import subprocess import platform @@ -433,43 +432,6 @@ def get_mop_router_information(endpoint_url, registration_key): logging.error("Failed to reach NetFoundry: %s", http_code) sys.exit(1) -def get_nfhelp(): - """ - Download latest version of nfhelp menu - """ - nfhelp_url = ("https://github.com/netfoundry/edge-router-nfhelp" - "/releases/latest/download/nfhelp.tar.gz") - - try: - logging.info("Downloading latest nfhelp") - file_name = "nfhelp.tar.gz" - response = requests.get(nfhelp_url, stream=True, timeout=60) - - total_size = int(response.headers.get("content-length", 0)) - block_size = 1024 # 1 Kibibyte - status_bar = tqdm(total=total_size, unit="iB", unit_scale=True, desc="Downloading") - - with open(file_name, "wb") as open_file: - for data in response.iter_content(block_size): - status_bar.update(len(data)) - open_file.write(data) - - status_bar.close() - except requests.exceptions.ConnectionError as exception_result: - logging.warning('An issue occurred while trying to connect: %s', exception_result) - except requests.exceptions.Timeout as timeout_exception: - logging.warning('Timed out trying to download nfhelp %s', timeout_exception) - - try: - with tarfile.open(file_name) as download_file: - download_file.extractall(path="/opt/netfoundry/") - os.remove("/etc/profile.d/nfhelp.sh") - os.replace("/opt/netfoundry/nfhelp.sh", "/etc/profile.d/nfhelp.sh") - os.chmod("/etc/profile.d/nfhelp.sh", 0o755) - os.remove(file_name) - except OSError as exceptions: - logging.warning("Unable to install new nfhelp: %s", exceptions) - def get_subnet_by_ip(input_ip): """ Given an IP address, this function checks local interfaces to determine @@ -913,9 +875,6 @@ def main(): else: router_info = process_manual_registration_arguments(args) - # get the latest version of nfhelp - get_nfhelp() - # check controller communications check_controller(router_info['networkControllerHost']) @@ -936,8 +895,8 @@ def main(): logging.info("\033[0;35mRegistration Successful\033[0m") - logging.info("\033[0;35mPlease use\033[0m \033[0;31mnfhelp-reload\033[0;35m " - "to use nfhelp commands\033[0m") + logging.info("\033[0;35mPlease use\033[0m \033[0;31mnfhelp-update\033[0;35m " + "before you use nfhelp commands\033[0m") # main if __name__ == '__main__': From 7d3bee9be9f35dcba8fd658e2042ff8b6c9328b5 Mon Sep 17 00:00:00 2001 From: Edward Moscardini Date: Tue, 3 Oct 2023 11:23:46 -0400 Subject: [PATCH 3/3] updated release with new plugin --- .github/workflows/release.yml | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b3ea96f..3d533eb 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -43,32 +43,13 @@ jobs: run: cd dist; mv router_registration .router_registration; tar -zcvf router_registration.tar.gz .router_registration - name: release - uses: actions/create-release@v1 + uses: ncipollo/release-action@v1 id: release with: draft: false prerelease: false - release_name: v${{ env.version }} - tag_name: v${{ env.version }} + tag: v${{ env.version }} + artifacts: "dist/router_registration_bootstrap.tar.gz,dist/router_registration.tar.gz" + artifactContentType: application/gzip env: GITHUB_TOKEN: ${{ github.token }} - - - name: Upload registration bootstrap release - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ github.token }} - with: - upload_url: ${{ steps.release.outputs.upload_url }} - asset_path: dist/router_registration_bootstrap.tar.gz - asset_name: router_registration_bootstrap.tar.gz - asset_content_type: application/gzip - - - name: Upload router_registration - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ github.token }} - with: - upload_url: ${{ steps.release.outputs.upload_url }} - asset_path: dist/router_registration.tar.gz - asset_name: router_registration.tar.gz - asset_content_type: application/gzip