diff --git a/src/image-copy/HISTORY.rst b/src/image-copy/HISTORY.rst index e8bf471ccef..74ca3cfdbdd 100644 --- a/src/image-copy/HISTORY.rst +++ b/src/image-copy/HISTORY.rst @@ -3,6 +3,10 @@ Release History =============== +0.2.10 +++++++ +* Fix the issue that the hyper_v_generation used for copying image is None when showing resource. + 0.2.9 ++++++ * Fix the issue that the hyper_v_generation is always V1 when copying the image. diff --git a/src/image-copy/azext_imagecopy/create_target.py b/src/image-copy/azext_imagecopy/create_target.py index d8f2278f4d8..32618d9bfa6 100644 --- a/src/image-copy/azext_imagecopy/create_target.py +++ b/src/image-copy/azext_imagecopy/create_target.py @@ -118,14 +118,14 @@ def create_target_image(cmd, location, transient_resource_group_name, source_typ transient_resource_group_name, target_subscription) - cli_cmd = prepare_cli_command(['snapshot', 'create', - '--resource-group', snapshot_resource_group_name, - '--name', target_snapshot_name, - '--location', location, - '--source', target_blob_path, - '--source-storage-account-id', source_storage_account_id, - '--hyper-v-generation', hyper_v_generation], - subscription=target_subscription) + cmd_content = ['snapshot', 'create', + '--resource-group', snapshot_resource_group_name, + '--name', target_snapshot_name, + '--location', location, + '--source', target_blob_path, + '--source-storage-account-id', source_storage_account_id, + '--hyper-v-generation', hyper_v_generation] + cli_cmd = prepare_cli_command(cmd_content, subscription=target_subscription) json_output = run_cli_command(cli_cmd, return_as_json=True) target_snapshot_id = json_output['id'] @@ -143,13 +143,14 @@ def create_target_image(cmd, location, transient_resource_group_name, source_typ else: target_image_name = target_name - cli_cmd = prepare_cli_command(['image', 'create', - '--resource-group', target_resource_group_name, - '--name', target_image_name, - '--location', location, - '--os-type', source_os_type, - '--source', target_snapshot_id, - '--hyper-v-generation', hyper_v_generation], + cmd_content = ['image', 'create', + '--resource-group', target_resource_group_name, + '--name', target_image_name, + '--location', location, + '--os-type', source_os_type, + '--source', target_snapshot_id, + '--hyper-v-generation', hyper_v_generation] + cli_cmd = prepare_cli_command(cmd_content, tags=tags, subscription=target_subscription) diff --git a/src/image-copy/azext_imagecopy/custom.py b/src/image-copy/azext_imagecopy/custom.py index 92871e23985..088fe21d073 100644 --- a/src/image-copy/azext_imagecopy/custom.py +++ b/src/image-copy/azext_imagecopy/custom.py @@ -90,21 +90,21 @@ def imagecopy(cmd, source_resource_group_name, source_object_name, target_locati source_storage_account_id = get_storage_account_id_from_blob_path(cmd, source_os_disk_id, source_resource_group_name) - cli_cmd = prepare_cli_command(['snapshot', 'create', - '--name', source_os_disk_snapshot_name, - '--location', snapshot_location, - '--resource-group', source_resource_group_name, - '--source', source_os_disk_id, - '--source-storage-account-id', source_storage_account_id, - '--hyper-v-generation', hyper_v_generation]) + cmd_content = ['snapshot', 'create', + '--name', source_os_disk_snapshot_name, + '--location', snapshot_location, + '--resource-group', source_resource_group_name, + '--source', source_os_disk_id, + '--source-storage-account-id', source_storage_account_id] else: - cli_cmd = prepare_cli_command(['snapshot', 'create', - '--name', source_os_disk_snapshot_name, - '--location', snapshot_location, - '--resource-group', source_resource_group_name, - '--source', source_os_disk_id, - '--hyper-v-generation', hyper_v_generation]) - + cmd_content = ['snapshot', 'create', + '--name', source_os_disk_snapshot_name, + '--location', snapshot_location, + '--resource-group', source_resource_group_name, + '--source', source_os_disk_id] + if hyper_v_generation: + cmd_content = cmd_content + ['--hyper-v-generation', hyper_v_generation] + cli_cmd = prepare_cli_command(cmd_content) run_cli_command(cli_cmd) # Get SAS URL for the snapshotName @@ -169,11 +169,13 @@ def imagecopy(cmd, source_resource_group_name, source_object_name, target_locati tasks = [] for location in target_location: location = location.strip() - tasks.append((location, transient_resource_group_name, source_type, - source_object_name, source_os_disk_snapshot_name, source_os_disk_snapshot_url, - source_os_type, target_resource_group_name, azure_pool_frequency, - tags, target_name, target_subscription, export_as_snapshot, timeout, - hyper_v_generation)) + task_content = (location, transient_resource_group_name, source_type, + source_object_name, source_os_disk_snapshot_name, source_os_disk_snapshot_url, + source_os_type, target_resource_group_name, azure_pool_frequency, + tags, target_name, target_subscription, export_as_snapshot, timeout) + if hyper_v_generation: + task_content = task_content + tuple(hyper_v_generation) + tasks.append(task_content) logger.warning("Starting async process for all locations") diff --git a/src/image-copy/setup.py b/src/image-copy/setup.py index b0e6c1936da..cd53ee43685 100644 --- a/src/image-copy/setup.py +++ b/src/image-copy/setup.py @@ -8,7 +8,7 @@ from codecs import open from setuptools import setup, find_packages -VERSION = "0.2.9" +VERSION = "0.2.10" CLASSIFIERS = [ 'Development Status :: 4 - Beta',