From 19b155220e161a4df0facd27bbcdeafa5280192f Mon Sep 17 00:00:00 2001 From: pagienge Date: Fri, 21 Mar 2025 16:49:52 -0500 Subject: [PATCH 1/5] Update custom.py fixing if/else code block to function --- src/vm-repair/azext_vm_repair/custom.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vm-repair/azext_vm_repair/custom.py b/src/vm-repair/azext_vm_repair/custom.py index fc45a73a4bc..492db091cc3 100644 --- a/src/vm-repair/azext_vm_repair/custom.py +++ b/src/vm-repair/azext_vm_repair/custom.py @@ -123,7 +123,7 @@ def create(cmd, vm_name, resource_group_name, repair_password=None, repair_usern # If the Hyper-V generation is 'V2', log this information and select the Linux distribution for a Gen2 VM. logger.info('Generation 2 VM detected') os_image_urn = _select_distro_linux_gen2(distro) - if architecture_type == 'Arm64': + elif architecture_type == 'Arm64': # If the architecture type is 'Arm64', log this information and select the Linux distribution for an Arm64 VM. logger.info('ARM64 VM detected') os_image_urn = _select_distro_linux_Arm64(distro) From d38a850d6fb913788fd4b723a4a9bd1a8569f167 Mon Sep 17 00:00:00 2001 From: pagienge Date: Fri, 21 Mar 2025 18:49:35 -0500 Subject: [PATCH 2/5] Update repair_utils.py Updating image keywords, changing default Gen1 image from a marketplace alias, to match the style of Gen2/ARM, while updating both URNs --- src/vm-repair/azext_vm_repair/repair_utils.py | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/vm-repair/azext_vm_repair/repair_utils.py b/src/vm-repair/azext_vm_repair/repair_utils.py index e3eb0349f94..0e479d45726 100644 --- a/src/vm-repair/azext_vm_repair/repair_utils.py +++ b/src/vm-repair/azext_vm_repair/repair_utils.py @@ -526,11 +526,16 @@ def _fetch_compatible_windows_os_urn_v2(source_vm): def _select_distro_linux(distro): + # list of images needs to be added to before the docs reflect, and the docs need to remove the keywords long before we remove the reference from the extension + # https://learn.microsoft.com/cli/azure/vm/repair?view=azure-cli-latest#az-vm-repair-create-optional-parameters image_lookup = { 'rhel7': 'RedHat:rhel-raw:7-raw:latest', 'rhel8': 'RedHat:rhel-raw:8-raw:latest', + 'rhel9': 'RedHat:rhel-raw:9-raw:latest', 'ubuntu18': 'Canonical:UbuntuServer:18.04-LTS:latest', 'ubuntu20': 'Canonical:0001-com-ubuntu-server-focal:20_04-lts:latest', + 'ubuntu22': 'Canonical:0001-com-ubuntu-server-jammy:22_04-lts:latest', + 'ubuntu24': 'Canonical:ubuntu-24_04-lts:server-gen1:latest', 'centos6': 'OpenLogic:CentOS:6.10:latest', 'centos7': 'OpenLogic:CentOS:7_9:latest', 'centos8': 'OpenLogic:CentOS:8_4:latest', @@ -547,16 +552,20 @@ def _select_distro_linux(distro): os_image_urn = distro else: logger.info('No specific distro was provided , using the default Ubuntu distro') - os_image_urn = "Ubuntu2204" + os_image_urn = "Canonical:ubuntu-24_04-lts:server-gen1:latest" return os_image_urn def _select_distro_linux_Arm64(distro): + # list of images needs to be added to before the docs reflect, and the docs need to remove the keywords long before we remove the reference from the extension + # https://learn.microsoft.com/cli/azure/vm/repair?view=azure-cli-latest#az-vm-repair-create-optional-parameters image_lookup = { 'rhel8': 'RedHat:rhel-arm64:8_8-arm64-gen2:latest', - 'rhel9': 'RedHat:rhel-arm64:9_2-arm64:latest', + 'rhel9': 'RedHat:rhel-arm64:9_3-arm64:latest', 'ubuntu18': 'Canonical:UbuntuServer:18_04-lts-arm64:latest', 'ubuntu20': 'Canonical:0001-com-ubuntu-server-focal:20_04-lts-arm64:latest', + 'ubuntu22': 'Canonical:0001-com-ubuntu-server-jammy:22_04-lts-arm64:latest', + 'ubuntu24': 'Canonical:ubuntu-24_04-lts:server-arm64:latest', 'centos7': 'OpenLogic:CentOS:7_9-arm64:latest', } if distro in image_lookup: @@ -567,23 +576,27 @@ def _select_distro_linux_Arm64(distro): os_image_urn = distro else: logger.info('No specific distro was provided , using the default ARM64 Ubuntu distro') - os_image_urn = "Canonical:UbuntuServer:18_04-lts-arm64:latest" + os_image_urn = "Canonical:ubuntu-24_04-lts:server-arm64:latest" return os_image_urn def _select_distro_linux_gen2(distro): - # base on the document : https://learn.microsoft.com/en-us/azure/virtual-machines/generation-2#generation-2-vm-images-in-azure-marketplace + # list of images needs to be added to before the docs reflect, and the docs need to remove the keywords long before we remove the reference from the extension + # https://learn.microsoft.com/cli/azure/vm/repair?view=azure-cli-latest#az-vm-repair-create-optional-parameters image_lookup = { 'rhel7': 'RedHat:rhel-raw:7-raw-gen2:latest', 'rhel8': 'RedHat:rhel-raw:8-raw-gen2:latest', + 'rhel9': 'RedHat:rhel-raw:9-raw-gen2:latest', 'ubuntu18': 'Canonical:UbuntuServer:18_04-lts-gen2:latest', 'ubuntu20': 'Canonical:0001-com-ubuntu-server-focal:20_04-lts-gen2:latest', + 'ubuntu22': 'Canonical:0001-com-ubuntu-server-jammy:22_04-lts-gen2:latest', + 'ubuntu24': 'Canonical:ubuntu-24_04-lts:server:latest', 'centos7': 'OpenLogic:CentOS:7_9-gen2:latest', 'centos8': 'OpenLogic:CentOS:8_4-gen2:latest', 'oracle7': 'Oracle:Oracle-Linux:ol79-gen2:latest', 'oracle8': 'Oracle:Oracle-Linux:ol82-gen2:latest', 'sles12': 'SUSE:sles-12-sp5:gen2:latest', - 'sles15': 'SUSE:sles-15-sp3:gen2:latest', + 'sles15': 'SUSE:sles-15-sp6:gen2:latest', } if distro in image_lookup: os_image_urn = image_lookup[distro] @@ -597,7 +610,7 @@ def _select_distro_linux_gen2(distro): os_image_urn = "Canonical:UbuntuServer:18_04-lts-gen2:latest" else: logger.info('No specific distro was provided , using the default Ubuntu distro') - os_image_urn = "Canonical:UbuntuServer:18_04-lts-gen2:latest" + os_image_urn = "Canonical:ubuntu-24_04-lts:server:latest" return os_image_urn @@ -809,4 +822,4 @@ def _make_public_ip_name(repair_vm_name, associate_public_ip): public_ip_name = '""' if associate_public_ip: public_ip_name = repair_vm_name + "PublicIP" - return public_ip_name \ No newline at end of file + return public_ip_name From c7d3cf7b52f7cf2c311bea52fc67631f57d451a4 Mon Sep 17 00:00:00 2001 From: pagienge Date: Mon, 31 Mar 2025 11:12:15 -0500 Subject: [PATCH 3/5] Updating version logic, metadata --- src/vm-repair/HISTORY.rst | 6 ++++ src/vm-repair/azext_vm_repair/custom.py | 29 +++++++++++-------- src/vm-repair/azext_vm_repair/repair_utils.py | 2 +- src/vm-repair/setup.py | 2 +- 4 files changed, 25 insertions(+), 14 deletions(-) diff --git a/src/vm-repair/HISTORY.rst b/src/vm-repair/HISTORY.rst index d4cf98ce462..4b40697fad0 100644 --- a/src/vm-repair/HISTORY.rst +++ b/src/vm-repair/HISTORY.rst @@ -2,6 +2,12 @@ Release History =============== +2.1.1 +++++++ +Added images available for --distro flag to include current distributions, will remove EoL versions in future releases +Fixing a logic bug to allow V2 linux detection to work properly, and with Arm64 +Disabled trusted launch for Arm64 + 2.1.0 ++++++ Added new parameter `--os-disk-type` to `vm repair create` to let users specify the repair vm's os disk storage account type. diff --git a/src/vm-repair/azext_vm_repair/custom.py b/src/vm-repair/azext_vm_repair/custom.py index 492db091cc3..326998ebc0f 100644 --- a/src/vm-repair/azext_vm_repair/custom.py +++ b/src/vm-repair/azext_vm_repair/custom.py @@ -117,18 +117,23 @@ def create(cmd, vm_name, resource_group_name, repair_password=None, repair_usern if is_linux and _uses_managed_disk(source_vm): # Setting the OS type to 'Linux'. os_type = 'Linux' - # Checking the Hyper-V generation of the source VM. - hyperV_generation_linux = _check_linux_hyperV_gen(source_vm) - if hyperV_generation_linux == 'V2': - # If the Hyper-V generation is 'V2', log this information and select the Linux distribution for a Gen2 VM. - logger.info('Generation 2 VM detected') - os_image_urn = _select_distro_linux_gen2(distro) - elif architecture_type == 'Arm64': - # If the architecture type is 'Arm64', log this information and select the Linux distribution for an Arm64 VM. - logger.info('ARM64 VM detected') - os_image_urn = _select_distro_linux_Arm64(distro) - else: - # If the architecture type is not 'Arm64', select the Linux distribution for a regular VM. + # Checking the Hyper-V generation of the source VM. + hyperV_generation_linux = _check_linux_hyperV_gen(source_vm) + if hyperV_generation_linux == 'V2': + # If the Hyper-V generation is 'V2', it may be ARM: + if architecture_type == 'Arm64': + # If the architecture type is 'Arm64', log this information and select the Linux distribution for an Arm64 VM. + logger.info('ARM64 VM detected') + os_image_urn = _select_distro_linux_Arm64(distro) + # Trusted launch is not supported on ARM + logger.info('Disabling trusted launch on ARM') + disable_trusted_launch = True + else: + # log this information and select the Linux distribution for an x86 Gen2 VM. + logger.info('Generation 2 VM detected') + os_image_urn = _select_distro_linux_gen2(distro) + else: + # If the architecture type is not 'V2', select a Gen1 VM os_image_urn = _select_distro_linux(distro) else: # If the source VM's OS is not Linux, check if a recovery key is provided. diff --git a/src/vm-repair/azext_vm_repair/repair_utils.py b/src/vm-repair/azext_vm_repair/repair_utils.py index 0e479d45726..98cb040bad2 100644 --- a/src/vm-repair/azext_vm_repair/repair_utils.py +++ b/src/vm-repair/azext_vm_repair/repair_utils.py @@ -607,7 +607,7 @@ def _select_distro_linux_gen2(distro): os_image_urn = distro else: logger.info('The provided URN does not contain Gen2 in it and this VM is a gen2 , dropping to default image') - os_image_urn = "Canonical:UbuntuServer:18_04-lts-gen2:latest" + os_image_urn = "Canonical:ubuntu-24_04-lts:server:latest" else: logger.info('No specific distro was provided , using the default Ubuntu distro') os_image_urn = "Canonical:ubuntu-24_04-lts:server:latest" diff --git a/src/vm-repair/setup.py b/src/vm-repair/setup.py index cae9802da9c..07d3391abc2 100644 --- a/src/vm-repair/setup.py +++ b/src/vm-repair/setup.py @@ -8,7 +8,7 @@ from codecs import open from setuptools import setup, find_packages -VERSION = "2.1.0" +VERSION = "2.1.1" CLASSIFIERS = [ 'Development Status :: 4 - Beta', From 9cc7a881b9fd812444fb6ead4369a655419a898e Mon Sep 17 00:00:00 2001 From: pagienge Date: Mon, 31 Mar 2025 11:34:12 -0500 Subject: [PATCH 4/5] Update HISTORY.rst for version 2.1.2 Version history update --- src/vm-repair/HISTORY.rst | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/vm-repair/HISTORY.rst b/src/vm-repair/HISTORY.rst index fef4810797e..21acc508302 100644 --- a/src/vm-repair/HISTORY.rst +++ b/src/vm-repair/HISTORY.rst @@ -2,11 +2,14 @@ Release History =============== -2.1.1 +2.1.2 ++++++ Added images available for --distro flag to include current distributions, will remove EoL versions in future releases Fixing a logic bug to allow V2 linux detection to work properly, and with Arm64 Disabled trusted launch for Arm64 + +2.1.1 +++++++ Updated README file for `vm repair` extension. 2.1.0 From 48b2b3747af78bce0527686bb75a87d05bde4fe8 Mon Sep 17 00:00:00 2001 From: pagienge Date: Thu, 3 Apr 2025 15:12:50 -0500 Subject: [PATCH 5/5] Update setup.py --- src/vm-repair/setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vm-repair/setup.py b/src/vm-repair/setup.py index 07d3391abc2..2a94947e5a2 100644 --- a/src/vm-repair/setup.py +++ b/src/vm-repair/setup.py @@ -8,7 +8,7 @@ from codecs import open from setuptools import setup, find_packages -VERSION = "2.1.1" +VERSION = "2.1.2" CLASSIFIERS = [ 'Development Status :: 4 - Beta',