Skip to content

Commit a74d9f4

Browse files
authored
Updating linux image selection (#8620)
1 parent 9dafe9b commit a74d9f4

File tree

4 files changed

+45
-21
lines changed

4 files changed

+45
-21
lines changed

src/vm-repair/HISTORY.rst

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
Release History
33
===============
44

5+
2.1.2
6+
++++++
7+
Added images available for --distro flag to include current distributions, will remove EoL versions in future releases
8+
Fixing a logic bug to allow V2 linux detection to work properly, and with Arm64
9+
Disabled trusted launch for Arm64
10+
511
2.1.1
612
++++++
713
Updated README file for `vm repair` extension.

src/vm-repair/azext_vm_repair/custom.py

+17-12
Original file line numberDiff line numberDiff line change
@@ -117,18 +117,23 @@ def create(cmd, vm_name, resource_group_name, repair_password=None, repair_usern
117117
if is_linux and _uses_managed_disk(source_vm):
118118
# Setting the OS type to 'Linux'.
119119
os_type = 'Linux'
120-
# Checking the Hyper-V generation of the source VM.
121-
hyperV_generation_linux = _check_linux_hyperV_gen(source_vm)
122-
if hyperV_generation_linux == 'V2':
123-
# If the Hyper-V generation is 'V2', log this information and select the Linux distribution for a Gen2 VM.
124-
logger.info('Generation 2 VM detected')
125-
os_image_urn = _select_distro_linux_gen2(distro)
126-
if architecture_type == 'Arm64':
127-
# If the architecture type is 'Arm64', log this information and select the Linux distribution for an Arm64 VM.
128-
logger.info('ARM64 VM detected')
129-
os_image_urn = _select_distro_linux_Arm64(distro)
130-
else:
131-
# If the architecture type is not 'Arm64', select the Linux distribution for a regular VM.
120+
# Checking the Hyper-V generation of the source VM.
121+
hyperV_generation_linux = _check_linux_hyperV_gen(source_vm)
122+
if hyperV_generation_linux == 'V2':
123+
# If the Hyper-V generation is 'V2', it may be ARM:
124+
if architecture_type == 'Arm64':
125+
# If the architecture type is 'Arm64', log this information and select the Linux distribution for an Arm64 VM.
126+
logger.info('ARM64 VM detected')
127+
os_image_urn = _select_distro_linux_Arm64(distro)
128+
# Trusted launch is not supported on ARM
129+
logger.info('Disabling trusted launch on ARM')
130+
disable_trusted_launch = True
131+
else:
132+
# log this information and select the Linux distribution for an x86 Gen2 VM.
133+
logger.info('Generation 2 VM detected')
134+
os_image_urn = _select_distro_linux_gen2(distro)
135+
else:
136+
# If the architecture type is not 'V2', select a Gen1 VM
132137
os_image_urn = _select_distro_linux(distro)
133138
else:
134139
# If the source VM's OS is not Linux, check if a recovery key is provided.

src/vm-repair/azext_vm_repair/repair_utils.py

+21-8
Original file line numberDiff line numberDiff line change
@@ -526,11 +526,16 @@ def _fetch_compatible_windows_os_urn_v2(source_vm):
526526

527527

528528
def _select_distro_linux(distro):
529+
# 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
530+
# https://learn.microsoft.com/cli/azure/vm/repair?view=azure-cli-latest#az-vm-repair-create-optional-parameters
529531
image_lookup = {
530532
'rhel7': 'RedHat:rhel-raw:7-raw:latest',
531533
'rhel8': 'RedHat:rhel-raw:8-raw:latest',
534+
'rhel9': 'RedHat:rhel-raw:9-raw:latest',
532535
'ubuntu18': 'Canonical:UbuntuServer:18.04-LTS:latest',
533536
'ubuntu20': 'Canonical:0001-com-ubuntu-server-focal:20_04-lts:latest',
537+
'ubuntu22': 'Canonical:0001-com-ubuntu-server-jammy:22_04-lts:latest',
538+
'ubuntu24': 'Canonical:ubuntu-24_04-lts:server-gen1:latest',
534539
'centos6': 'OpenLogic:CentOS:6.10:latest',
535540
'centos7': 'OpenLogic:CentOS:7_9:latest',
536541
'centos8': 'OpenLogic:CentOS:8_4:latest',
@@ -547,16 +552,20 @@ def _select_distro_linux(distro):
547552
os_image_urn = distro
548553
else:
549554
logger.info('No specific distro was provided , using the default Ubuntu distro')
550-
os_image_urn = "Ubuntu2204"
555+
os_image_urn = "Canonical:ubuntu-24_04-lts:server-gen1:latest"
551556
return os_image_urn
552557

553558

554559
def _select_distro_linux_Arm64(distro):
560+
# 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
561+
# https://learn.microsoft.com/cli/azure/vm/repair?view=azure-cli-latest#az-vm-repair-create-optional-parameters
555562
image_lookup = {
556563
'rhel8': 'RedHat:rhel-arm64:8_8-arm64-gen2:latest',
557-
'rhel9': 'RedHat:rhel-arm64:9_2-arm64:latest',
564+
'rhel9': 'RedHat:rhel-arm64:9_3-arm64:latest',
558565
'ubuntu18': 'Canonical:UbuntuServer:18_04-lts-arm64:latest',
559566
'ubuntu20': 'Canonical:0001-com-ubuntu-server-focal:20_04-lts-arm64:latest',
567+
'ubuntu22': 'Canonical:0001-com-ubuntu-server-jammy:22_04-lts-arm64:latest',
568+
'ubuntu24': 'Canonical:ubuntu-24_04-lts:server-arm64:latest',
560569
'centos7': 'OpenLogic:CentOS:7_9-arm64:latest',
561570
}
562571
if distro in image_lookup:
@@ -567,23 +576,27 @@ def _select_distro_linux_Arm64(distro):
567576
os_image_urn = distro
568577
else:
569578
logger.info('No specific distro was provided , using the default ARM64 Ubuntu distro')
570-
os_image_urn = "Canonical:UbuntuServer:18_04-lts-arm64:latest"
579+
os_image_urn = "Canonical:ubuntu-24_04-lts:server-arm64:latest"
571580
return os_image_urn
572581

573582

574583
def _select_distro_linux_gen2(distro):
575-
# base on the document : https://learn.microsoft.com/en-us/azure/virtual-machines/generation-2#generation-2-vm-images-in-azure-marketplace
584+
# 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
585+
# https://learn.microsoft.com/cli/azure/vm/repair?view=azure-cli-latest#az-vm-repair-create-optional-parameters
576586
image_lookup = {
577587
'rhel7': 'RedHat:rhel-raw:7-raw-gen2:latest',
578588
'rhel8': 'RedHat:rhel-raw:8-raw-gen2:latest',
589+
'rhel9': 'RedHat:rhel-raw:9-raw-gen2:latest',
579590
'ubuntu18': 'Canonical:UbuntuServer:18_04-lts-gen2:latest',
580591
'ubuntu20': 'Canonical:0001-com-ubuntu-server-focal:20_04-lts-gen2:latest',
592+
'ubuntu22': 'Canonical:0001-com-ubuntu-server-jammy:22_04-lts-gen2:latest',
593+
'ubuntu24': 'Canonical:ubuntu-24_04-lts:server:latest',
581594
'centos7': 'OpenLogic:CentOS:7_9-gen2:latest',
582595
'centos8': 'OpenLogic:CentOS:8_4-gen2:latest',
583596
'oracle7': 'Oracle:Oracle-Linux:ol79-gen2:latest',
584597
'oracle8': 'Oracle:Oracle-Linux:ol82-gen2:latest',
585598
'sles12': 'SUSE:sles-12-sp5:gen2:latest',
586-
'sles15': 'SUSE:sles-15-sp3:gen2:latest',
599+
'sles15': 'SUSE:sles-15-sp6:gen2:latest',
587600
}
588601
if distro in image_lookup:
589602
os_image_urn = image_lookup[distro]
@@ -594,10 +607,10 @@ def _select_distro_linux_gen2(distro):
594607
os_image_urn = distro
595608
else:
596609
logger.info('The provided URN does not contain Gen2 in it and this VM is a gen2 , dropping to default image')
597-
os_image_urn = "Canonical:UbuntuServer:18_04-lts-gen2:latest"
610+
os_image_urn = "Canonical:ubuntu-24_04-lts:server:latest"
598611
else:
599612
logger.info('No specific distro was provided , using the default Ubuntu distro')
600-
os_image_urn = "Canonical:UbuntuServer:18_04-lts-gen2:latest"
613+
os_image_urn = "Canonical:ubuntu-24_04-lts:server:latest"
601614
return os_image_urn
602615

603616

@@ -809,4 +822,4 @@ def _make_public_ip_name(repair_vm_name, associate_public_ip):
809822
public_ip_name = '""'
810823
if associate_public_ip:
811824
public_ip_name = repair_vm_name + "PublicIP"
812-
return public_ip_name
825+
return public_ip_name

src/vm-repair/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from codecs import open
99
from setuptools import setup, find_packages
1010

11-
VERSION = "2.1.1"
11+
VERSION = "2.1.2"
1212

1313
CLASSIFIERS = [
1414
'Development Status :: 4 - Beta',

0 commit comments

Comments
 (0)