From fbe5b38234c80f321bc2c69102e5a4210dc42adc Mon Sep 17 00:00:00 2001 From: Anuj Gupta Date: Tue, 1 Jul 2025 18:27:03 +0530 Subject: [PATCH 1/7] [ImageCopy] Fix the issue for sasTokenParsing, removing python related warnings from the sasToken(cmd_output is unfiltered) --- src/image-copy/HISTORY.rst | 4 ++++ src/image-copy/azext_imagecopy/create_target.py | 9 +++++---- src/image-copy/setup.py | 4 ++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/image-copy/HISTORY.rst b/src/image-copy/HISTORY.rst index 885ce98091a..90f678c9418 100644 --- a/src/image-copy/HISTORY.rst +++ b/src/image-copy/HISTORY.rst @@ -3,6 +3,10 @@ Release History =============== +1.0.3 +++++++ +* Fix the issue for sasTokenParsing, removing python related warnings from the sasToken(cmd_output was unfiltered) + 1.0.2 ++++++ * Create temporary storage account with minimum TLS version set to `TLS1_2` diff --git a/src/image-copy/azext_imagecopy/create_target.py b/src/image-copy/azext_imagecopy/create_target.py index 2001fcbd834..55938c598f7 100644 --- a/src/image-copy/azext_imagecopy/create_target.py +++ b/src/image-copy/azext_imagecopy/create_target.py @@ -6,10 +6,10 @@ import datetime import time -from knack.util import CLIError +from azext_imagecopy.cli_utils import (get_storage_account_id_from_blob_path, + prepare_cli_command, run_cli_command) from knack.log import get_logger - -from azext_imagecopy.cli_utils import run_cli_command, prepare_cli_command, get_storage_account_id_from_blob_path +from knack.util import CLIError logger = get_logger(__name__) @@ -73,6 +73,7 @@ def create_target_image(location, transient_resource_group_name, source_type, so sas_token = run_cli_command(cli_cmd) sas_token = sas_token.rstrip("\n\r") # STRANGE + sas_token = sas_token.split()[-1] # Removing the warnings if there is any python lib warnings in output logger.debug("sas token: %s", sas_token) # create a container in the target blob storage account @@ -206,7 +207,7 @@ def wait_for_blob_copy_operation(blob_name, target_container_name, target_storag def get_random_string(length): - import string import random + import string chars = string.ascii_lowercase + string.digits return ''.join(random.choice(chars) for _ in range(length)) diff --git a/src/image-copy/setup.py b/src/image-copy/setup.py index a203df00938..7f9d39e1aa3 100644 --- a/src/image-copy/setup.py +++ b/src/image-copy/setup.py @@ -6,9 +6,9 @@ # -------------------------------------------------------------------------------------------- from codecs import open -from setuptools import setup, find_packages +from setuptools import find_packages, setup -VERSION = "1.0.2" +VERSION = "1.0.3" CLASSIFIERS = [ 'Development Status :: 4 - Beta', From 7db60f06bb96388f2fffda63e2a2395e0a41d9a9 Mon Sep 17 00:00:00 2001 From: ajgupta42 Date: Wed, 9 Jul 2025 10:53:17 +0530 Subject: [PATCH 2/7] Update src/image-copy/azext_imagecopy/create_target.py Co-authored-by: Xing Zhou --- src/image-copy/azext_imagecopy/create_target.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/image-copy/azext_imagecopy/create_target.py b/src/image-copy/azext_imagecopy/create_target.py index 55938c598f7..aa135d46564 100644 --- a/src/image-copy/azext_imagecopy/create_target.py +++ b/src/image-copy/azext_imagecopy/create_target.py @@ -73,8 +73,7 @@ def create_target_image(location, transient_resource_group_name, source_type, so sas_token = run_cli_command(cli_cmd) sas_token = sas_token.rstrip("\n\r") # STRANGE - sas_token = sas_token.split()[-1] # Removing the warnings if there is any python lib warnings in output - logger.debug("sas token: %s", sas_token) + logger.debug("sas token: %s", sas_token.split()[-1]) # create a container in the target blob storage account logger.warning( From 3796cf4f432cc396b083cf066ff394db0c510ea1 Mon Sep 17 00:00:00 2001 From: Anuj Gupta Date: Wed, 9 Jul 2025 10:56:26 +0530 Subject: [PATCH 3/7] [ImageCopy] Fix the issue for sasTokenParsing, removing python related warnings from the sasToken(cmd_output is unfiltered) --- src/image-copy/azext_imagecopy/create_target.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/image-copy/azext_imagecopy/create_target.py b/src/image-copy/azext_imagecopy/create_target.py index aa135d46564..a97c6636d1a 100644 --- a/src/image-copy/azext_imagecopy/create_target.py +++ b/src/image-copy/azext_imagecopy/create_target.py @@ -96,7 +96,7 @@ def create_target_image(location, transient_resource_group_name, source_type, so '--destination-blob', blob_name, '--destination-container', target_container_name, '--account-name', target_storage_account_name, - '--sas-token', sas_token], + '--sas-token', sas_token.split()[-1]], subscription=target_subscription, only_show_errors=only_show_errors) From 213475350fbd96d869ca9359440c485a2f9f6057 Mon Sep 17 00:00:00 2001 From: Anuj Gupta Date: Wed, 9 Jul 2025 13:49:29 +0530 Subject: [PATCH 4/7] [ImageCopy] Puttting it under if statement --- src/image-copy/azext_imagecopy/create_target.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/image-copy/azext_imagecopy/create_target.py b/src/image-copy/azext_imagecopy/create_target.py index a97c6636d1a..af64c01172c 100644 --- a/src/image-copy/azext_imagecopy/create_target.py +++ b/src/image-copy/azext_imagecopy/create_target.py @@ -73,7 +73,9 @@ def create_target_image(location, transient_resource_group_name, source_type, so sas_token = run_cli_command(cli_cmd) sas_token = sas_token.rstrip("\n\r") # STRANGE - logger.debug("sas token: %s", sas_token.split()[-1]) + if len(sas_token.split()) > 1: + sas_token = sas_token.split()[-1] + logger.debug("sas token: %s") # create a container in the target blob storage account logger.warning( @@ -96,7 +98,7 @@ def create_target_image(location, transient_resource_group_name, source_type, so '--destination-blob', blob_name, '--destination-container', target_container_name, '--account-name', target_storage_account_name, - '--sas-token', sas_token.split()[-1]], + '--sas-token', sas_token], subscription=target_subscription, only_show_errors=only_show_errors) From 27085c722f89027640991d7e1190edabd9e61c64 Mon Sep 17 00:00:00 2001 From: Anuj Gupta Date: Wed, 9 Jul 2025 13:51:28 +0530 Subject: [PATCH 5/7] [ImageCopy] Puttting it under if statement --- src/image-copy/azext_imagecopy/create_target.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/image-copy/azext_imagecopy/create_target.py b/src/image-copy/azext_imagecopy/create_target.py index af64c01172c..03b9a1f9d64 100644 --- a/src/image-copy/azext_imagecopy/create_target.py +++ b/src/image-copy/azext_imagecopy/create_target.py @@ -75,7 +75,7 @@ def create_target_image(location, transient_resource_group_name, source_type, so sas_token = sas_token.rstrip("\n\r") # STRANGE if len(sas_token.split()) > 1: sas_token = sas_token.split()[-1] - logger.debug("sas token: %s") + logger.debug("sas token: %s", sas_token) # create a container in the target blob storage account logger.warning( From f19c135be41a7a9aa38cb486f5632008deabe202 Mon Sep 17 00:00:00 2001 From: Anuj Gupta Date: Wed, 9 Jul 2025 14:19:07 +0530 Subject: [PATCH 6/7] [ImageCopy] Puttting it under if statement --- src/image-copy/azext_imagecopy/create_target.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/image-copy/azext_imagecopy/create_target.py b/src/image-copy/azext_imagecopy/create_target.py index 03b9a1f9d64..8c98fe1982a 100644 --- a/src/image-copy/azext_imagecopy/create_target.py +++ b/src/image-copy/azext_imagecopy/create_target.py @@ -74,7 +74,7 @@ def create_target_image(location, transient_resource_group_name, source_type, so sas_token = run_cli_command(cli_cmd) sas_token = sas_token.rstrip("\n\r") # STRANGE if len(sas_token.split()) > 1: - sas_token = sas_token.split()[-1] + sas_token = sas_token.split()[-1] logger.debug("sas token: %s", sas_token) # create a container in the target blob storage account From eaf96e7fc60005786a2c9aeb60e98f29b1bb5e82 Mon Sep 17 00:00:00 2001 From: ajgupta42 Date: Fri, 11 Jul 2025 12:08:29 +0530 Subject: [PATCH 7/7] Update src/image-copy/azext_imagecopy/create_target.py Co-authored-by: Xing Zhou --- src/image-copy/azext_imagecopy/create_target.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/image-copy/azext_imagecopy/create_target.py b/src/image-copy/azext_imagecopy/create_target.py index 8c98fe1982a..62273a69757 100644 --- a/src/image-copy/azext_imagecopy/create_target.py +++ b/src/image-copy/azext_imagecopy/create_target.py @@ -73,8 +73,10 @@ def create_target_image(location, transient_resource_group_name, source_type, so sas_token = run_cli_command(cli_cmd) sas_token = sas_token.rstrip("\n\r") # STRANGE + # Remove python related warnings from the SAS token if there are warning included in the SAS token if len(sas_token.split()) > 1: sas_token = sas_token.split()[-1] + logger.debug("sas token: %s", sas_token) # create a container in the target blob storage account