summaryrefslogtreecommitdiffstats
path: root/bin/cvp-upload
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-05-11 09:25:01 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-06-12 05:31:22 +0000
commit7ad1d0e0af695fa7f872b740a1bb7b2897eb41bd (patch)
tree13dd59a8ea98206a8c56ffd466f59c146f9f19c7 /bin/cvp-upload
parentInitial commit. (diff)
downloadeos-downloader-7ad1d0e0af695fa7f872b740a1bb7b2897eb41bd.tar.xz
eos-downloader-7ad1d0e0af695fa7f872b740a1bb7b2897eb41bd.zip
Adding upstream version 0.8.1.upstream/0.8.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'bin/cvp-upload')
-rwxr-xr-xbin/cvp-upload56
1 files changed, 56 insertions, 0 deletions
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)