From 5493da83e9dbae4eabe4b4b17bc54738a6a39695 Mon Sep 17 00:00:00 2001 From: aapatwa <161330416+aapatwa@users.noreply.github.com> Date: Wed, 28 Feb 2024 13:36:52 +0530 Subject: [PATCH 1/3] Update ucsfirmware.py Adding a new method for firmware upload of size greater than 2 GB --- ucsmsdk_samples/firmware/ucsfirmware.py | 59 +++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/ucsmsdk_samples/firmware/ucsfirmware.py b/ucsmsdk_samples/firmware/ucsfirmware.py index e7fa0d0..e837814 100755 --- a/ucsmsdk_samples/firmware/ucsfirmware.py +++ b/ucsmsdk_samples/firmware/ucsfirmware.py @@ -332,6 +332,65 @@ def firmware_add_local(handle, image_dir, image_name, timeout=10 * 60): return firmware_downloader +def firmware_add_local_largeFile(handle, image_dir, image_name, timeout=10 * 60): + """ + Downloads the firmware image on ucsm from local server + + Args: + image_dir (string): path of download directory + image_name (string): firmware image name + timeout (number): timeout in seconds + + Returns: + FirmwareDownloader: Managed Object + + Raises: + ValueError if download fail or timeout + + Example: + firmware_add_local_largeFile(image_dir="/home/imagedir", + image_name="ucs-k9-bundle-c-series.2.2.5b.C.bin") + """ + + file_path = os.path.join(image_dir, image_name) + + if not os.path.exists(file_path): + raise IOError("File does not exist") + + top_system = TopSystem() + firmware_catalogue = FirmwareCatalogue(parent_mo_or_dn=top_system) + firmware_downloader = FirmwareDownloader( + parent_mo_or_dn=firmware_catalogue, + file_name=image_name) + firmware_downloader.server = FirmwareDownloaderConsts.PROTOCOL_LOCAL + firmware_downloader.protocol = FirmwareDownloaderConsts.PROTOCOL_LOCAL + firmware_downloader.admin_state = \ + FirmwareDownloaderConsts.ADMIN_STATE_RESTART + + uri_suffix = "operations/file-%s/imagechunk.txt" % image_name + handle.firmware_upload(url_suffix=uri_suffix, + file_dir=image_dir, + file_name=image_name) + + handle.add_mo(firmware_downloader, modify_present=True) + # handle.set_dump_xml() + handle.commit() + + start = datetime.datetime.now() + while not firmware_downloader.transfer_state == \ + FirmwareDownloaderConsts.TRANSFER_STATE_DOWNLOADED: + firmware_downloader = handle.query_dn(firmware_downloader.dn) + if firmware_downloader.transfer_state == \ + FirmwareDownloaderConsts.TRANSFER_STATE_FAILED: + raise Exception("Download of '%s' failed. Error: %s" % + (image_name, + firmware_downloader.fsm_rmt_inv_err_descr)) + if (datetime.datetime.now() - start).total_seconds() > timeout: + raise Exception("Download of '%s' timed out" % image_name) + + return firmware_downloader + + def firmware_add_remote(handle, file_name, remote_path, protocol, server, user="", pwd=""): """ From 957e2d6166cfced6253bbcbfef9fc8afd5e1bad8 Mon Sep 17 00:00:00 2001 From: aapatwa <161330416+aapatwa@users.noreply.github.com> Date: Fri, 1 Mar 2024 10:54:47 +0530 Subject: [PATCH 2/3] Update ucsmsdk_samples/firmware/ucsfirmware.py Co-authored-by: Vikrant Balyan --- ucsmsdk_samples/firmware/ucsfirmware.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ucsmsdk_samples/firmware/ucsfirmware.py b/ucsmsdk_samples/firmware/ucsfirmware.py index e837814..2a8f8c3 100755 --- a/ucsmsdk_samples/firmware/ucsfirmware.py +++ b/ucsmsdk_samples/firmware/ucsfirmware.py @@ -332,7 +332,7 @@ def firmware_add_local(handle, image_dir, image_name, timeout=10 * 60): return firmware_downloader -def firmware_add_local_largeFile(handle, image_dir, image_name, timeout=10 * 60): +def firmware_add_local_large_file(handle, image_dir, image_name, timeout=10 * 60): """ Downloads the firmware image on ucsm from local server From f3461f1198707e50249fd734ca92da6fde536f02 Mon Sep 17 00:00:00 2001 From: aapatwa <161330416+aapatwa@users.noreply.github.com> Date: Fri, 1 Mar 2024 10:54:55 +0530 Subject: [PATCH 3/3] Update ucsmsdk_samples/firmware/ucsfirmware.py Co-authored-by: Vikrant Balyan --- ucsmsdk_samples/firmware/ucsfirmware.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ucsmsdk_samples/firmware/ucsfirmware.py b/ucsmsdk_samples/firmware/ucsfirmware.py index 2a8f8c3..344a409 100755 --- a/ucsmsdk_samples/firmware/ucsfirmware.py +++ b/ucsmsdk_samples/firmware/ucsfirmware.py @@ -348,7 +348,7 @@ def firmware_add_local_large_file(handle, image_dir, image_name, timeout=10 * 60 ValueError if download fail or timeout Example: - firmware_add_local_largeFile(image_dir="/home/imagedir", + firmware_add_local_large_file(image_dir="/home/imagedir", image_name="ucs-k9-bundle-c-series.2.2.5b.C.bin") """