Skip to content

Commit

Permalink
Merge pull request #32 from netfoundry/remove_port_80_check
Browse files Browse the repository at this point in the history
Remove port 80 check
  • Loading branch information
emoscardini authored Oct 3, 2023
2 parents 504b27b + 7d3bee9 commit 291ebc6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 68 deletions.
27 changes: 4 additions & 23 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
13 changes: 13 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@

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
- Removed nfhelp download

## [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
Expand Down
49 changes: 4 additions & 45 deletions router_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import json
import time
import ssl
import tarfile
import ipaddress
import subprocess
import platform
Expand All @@ -37,7 +36,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 "
Expand Down Expand Up @@ -241,7 +240,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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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'])

Expand All @@ -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__':
Expand Down

0 comments on commit 291ebc6

Please sign in to comment.