summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rw-r--r--bin/README.md111
-rwxr-xr-xbin/cvp-upload56
-rwxr-xr-xbin/eos-download86
3 files changed, 253 insertions, 0 deletions
diff --git a/bin/README.md b/bin/README.md
new file mode 100644
index 0000000..7509633
--- /dev/null
+++ b/bin/README.md
@@ -0,0 +1,111 @@
+## scripts
+
+These scripts are deprecated and will be removed in a futur version. Please prefer the use of the CLI implemented in the package.
+
+### eos-download
+
+```bash
+usage: eos-download [-h]
+ --version VERSION
+ [--token TOKEN]
+ [--image IMAGE]
+ [--destination DESTINATION]
+ [--eve]
+ [--noztp]
+ [--import_docker]
+ [--docker_name DOCKER_NAME]
+ [--verbose VERBOSE]
+ [--log]
+
+EOS downloader script.
+
+optional arguments:
+ -h, --help show this help message and exit
+ --token TOKEN arista.com user API key - can use ENV:ARISTA_TOKEN
+ --image IMAGE Type of EOS image required
+ --version VERSION EOS version to download from website
+ --destination DESTINATION
+ Path where to save EOS package downloaded
+ --eve Option to install EOS package to EVE-NG
+ --noztp Option to deactivate ZTP when used with EVE-NG
+ --import_docker Option to import cEOS image to docker
+ --docker_name DOCKER_NAME
+ Docker image name to use
+ --verbose VERBOSE Script verbosity
+ --log Option to activate logging to eos-downloader.log file
+```
+
+- Token are read from `ENV:ARISTA_TOKEN` unless you specify a specific token with CLI.
+
+- Supported platforms:
+
+ - `INT`: International version
+ - `64`: 64 bits version
+ - `2GB` for 2GB flash platform
+ - `2GB-INT`: for 2GB running International
+ - `vEOS`: Virtual EOS image
+ - `vEOS-lab`: Virtual Lab EOS
+ - `vEOS64-lab`: Virtual Lab EOS running 64B
+ - `cEOS`: Docker version of EOS
+ - `cEOS64`: Docker version of EOS running in 64 bits
+
+#### Examples
+
+- Download vEOS-lab image and install in EVE-NG
+
+```bash
+$ eos-download --image vEOS-lab --version 4.25.7M --eve --noztp
+```
+
+- Download Docker image
+
+```bash
+$ eos-download --image cEOS --version 4.27.1F
+šŸŖ eos-downloader is starting...
+ - Image Type: cEOS
+ - Version: 4.27.2F
+āœ… Authenticated on arista.com
+šŸ”Ž Searching file cEOS-lab-4.27.2F.tar.xz
+ -> Found file at /support/download/EOS-USA/Active Releases/4.27/EOS-4.27.2F/cEOS-lab/cEOS-lab-4.27.2F.tar.xz
+šŸ’¾ Downloading cEOS-lab-4.27.2F.tar.xz ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā” 100.0% ā€¢ 17.1 MB/s ā€¢ 451.6/451.6 MB ā€¢ 0:00:19 ā€¢
+šŸš€ Running checksum validation
+šŸ”Ž Searching file cEOS-lab-4.27.2F.tar.xz.sha512sum
+ -> Found file at /support/download/EOS-USA/Active
+Releases/4.27/EOS-4.27.2F/cEOS-lab/cEOS-lab-4.27.2F.tar.xz.sha512sum
+šŸ’¾ Downloading cEOS-lab-4.27.2F.tar.xz.sha512sum ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā” 100.0% ā€¢ ? ā€¢ 154/154 bytes ā€¢ 0:00:00 ā€¢
+āœ… Downloaded file is correct.
+```
+
+__Note:__ `ARISTA_TOKEN` should be set in your .profile and not set for each command. If not set, you can use `--token` knob.
+
+```bash
+# Export Token
+export ARISTA_TOKEN="xxxxxxx"
+```
+
+### Cloudvision Image uploader
+
+Create an image bundle on Cloudvision.
+
+```bash
+cvp-upload -h
+usage: cvp-upload [-h]
+ [--token TOKEN]
+ [--image IMAGE]
+ --cloudvision CLOUDVISION
+ [--create_bundle]
+ [--timeout TIMEOUT]
+ [--verbose VERBOSE]
+
+Cloudvision Image uploader script.
+
+optional arguments:
+ -h, --help show this help message and exit
+ --token TOKEN CVP Authentication token - can use ENV:ARISTA_AVD_CV_TOKEN
+ --image IMAGE Type of EOS image required
+ --cloudvision CLOUDVISION
+ Cloudvision instance where to upload image
+ --create_bundle Option to create image bundle with new uploaded image
+ --timeout TIMEOUT Timeout connection. Default is set to 1200sec
+ --verbose VERBOSE Script verbosity
+``` \ No newline at end of file
diff --git a/bin/cvp-upload b/bin/cvp-upload
new file mode 100755
index 0000000..74213fe
--- /dev/null
+++ b/bin/cvp-upload
@@ -0,0 +1,56 @@
+#!/usr/bin/python
+
+import sys
+import os
+import argparse
+from eos_downloader.cvp import CvFeatureManager, CvpAuthenticationItem
+from loguru import logger
+
+ARISTA_AVD_CV_TOKEN = os.getenv('ARISTA_AVD_CV_TOKEN', '')
+
+
+def read_cli():
+ parser = argparse.ArgumentParser(description='Cloudvision Image uploader script.')
+ parser.add_argument('--token', required=False,
+ default=ARISTA_AVD_CV_TOKEN,
+ help='CVP Authentication token - can use ENV:ARISTA_AVD_CV_TOKEN')
+ parser.add_argument('--image', required=False,
+ default='EOS', help='Type of EOS image required')
+ parser.add_argument('--cloudvision', required=True,
+ help='Cloudvision instance where to upload image')
+ parser.add_argument('--create_bundle', required=False, action='store_true',
+ help="Option to create image bundle with new uploaded image")
+ parser.add_argument('--timeout', required=False,
+ default=1200,
+ help='Timeout connection. Default is set to 1200sec')
+ parser.add_argument('--verbose', required=False,
+ default='info', help='Script verbosity')
+ return parser.parse_args()
+
+
+if __name__ == '__main__':
+
+ cli_options = read_cli()
+
+ logger.remove()
+ logger.add(sys.stderr, level=str(cli_options.verbose).upper())
+
+ cv_authentication = CvpAuthenticationItem(
+ server=cli_options.cloudvision,
+ token=cli_options.token,
+ port=443,
+ timeout=cli_options.timeout,
+ validate_cert=False
+ )
+
+ my_cvp_uploader = CvFeatureManager(authentication=cv_authentication)
+ result_upload = my_cvp_uploader.upload_image(cli_options.image)
+ if result_upload and cli_options.create_bundle:
+ bundle_name = os.path.basename(cli_options.image)
+ logger.info('Creating image bundle {}'.format(bundle_name))
+ my_cvp_uploader.create_bundle(
+ name=bundle_name,
+ images_name=[bundle_name]
+ )
+
+ sys.exit(0)
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)