summaryrefslogtreecommitdiffstats
path: root/bin/eos-download
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xbin/eos-download86
1 files changed, 86 insertions, 0 deletions
diff --git a/bin/eos-download b/bin/eos-download
new file mode 100755
index 0000000..9826b31
--- /dev/null
+++ b/bin/eos-download
@@ -0,0 +1,86 @@
+#!/usr/bin/python
+
+import sys
+import os
+import argparse
+import eos_downloader.eos
+from loguru import logger
+from rich.console import Console
+
+ARISTA_TOKEN = os.getenv('ARISTA_TOKEN', '')
+
+
+def read_cli():
+ parser = argparse.ArgumentParser(description='EOS downloader script.')
+ parser.add_argument('--token', required=False,
+ default=ARISTA_TOKEN,
+ help='arista.com user API key - can use ENV:ARISTA_TOKEN')
+ parser.add_argument('--image', required=False,
+ default='EOS', help='Type of EOS image required')
+ parser.add_argument('--version', required=True,
+ default='', help='EOS version to download from website')
+
+ parser.add_argument('--destination', required=False,
+ default=str(os.getcwd()),
+ help='Path where to save EOS package downloaded')
+
+ parser.add_argument('--eve', required=False, action='store_true',
+ help="Option to install EOS package to EVE-NG")
+ parser.add_argument('--noztp', required=False, action='store_true',
+ help="Option to deactivate ZTP when used with EVE-NG")
+
+ parser.add_argument('--import_docker', required=False, action='store_true',
+ help="Option to import cEOS image to docker")
+ parser.add_argument('--docker_name', required=False,
+ default='arista/ceos',
+ help='Docker image name to use')
+
+ parser.add_argument('--verbose', required=False,
+ default='info', help='Script verbosity')
+ parser.add_argument('--log', required=False, action='store_true',
+ help="Option to activate logging to eos-downloader.log file")
+
+ return parser.parse_args()
+
+
+if __name__ == '__main__':
+
+ cli_options = read_cli()
+
+ console = Console()
+
+ console.print('\n[red]WARNING: This script is now deprecated. Please use ardl cli instead[/red]\n\n')
+
+ if cli_options.token is None or cli_options.token == '':
+ console.print('\nā— Token is unset ! Please configure ARISTA_TOKEN or use --token option', style="bold red")
+ sys.exit(1)
+
+ logger.remove()
+ if cli_options.log:
+ logger.add("eos-downloader.log", rotation="10 MB", level=str(cli_options.verbose).upper())
+
+ console.print("šŸŖ [bold blue]eos-downloader[/bold blue] is starting...", )
+ console.print(f' - Image Type: {cli_options.image}')
+ console.print(f' - Version: {cli_options.version}')
+
+
+ my_download = eos_downloader.eos.EOSDownloader(
+ image=cli_options.image,
+ software='EOS',
+ version=cli_options.version,
+ token=cli_options.token,
+ hash_method='sha512sum')
+
+ my_download.authenticate()
+
+ if cli_options.eve:
+ my_download.provision_eve(noztp=cli_options.noztp, checksum=True)
+ else:
+ my_download.download_local(file_path=cli_options.destination, checksum=True)
+
+ if cli_options.import_docker:
+ my_download.docker_import(
+ image_name=cli_options.docker_name
+ )
+ console.print('āœ… processing done !')
+ sys.exit(0)