Skip to content

Commit

Permalink
removed nfhelp download; updated success msg
Browse files Browse the repository at this point in the history
  • Loading branch information
emoscardini committed Oct 3, 2023
1 parent fd35b79 commit b291c32
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 43 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
45 changes: 2 additions & 43 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 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 b291c32

Please sign in to comment.