Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix UUID issue for data disk #4479

Merged
merged 9 commits into from
Mar 8, 2022
6 changes: 5 additions & 1 deletion src/vm-repair/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
Release History
===============

0.4.2
++++++
Linux only: Fixing duplicated UUID issue. Data disk gets attached only after VM got created.

0.4.1
++++++
Fixing bug in preview parameter
Expand All @@ -26,4 +30,4 @@ build environment for Rust.
0.3.5
++++++

Add support for nested VMs
Add support for nested VMs
12 changes: 10 additions & 2 deletions src/vm-repair/azext_vm_repair/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,10 @@ def create(cmd, vm_name, resource_group_name, repair_password=None, repair_usern
# Copy OS Disk
logger.info('Copying OS disk of source VM...')
copy_disk_id = _call_az_command(copy_disk_command).strip('\n')
# Add copied OS Disk to VM creat command so that the VM is created with the disk attached
create_repair_vm_command += ' --attach-data-disks {id}'.format(id=copy_disk_id)
# For Linux the disk gets not attached at VM creation time. To prevent an incorrect boot state it is required to attach the disk after the VM got created.
if not is_linux:
# Add copied OS Disk to VM creat command so that the VM is created with the disk attached
create_repair_vm_command += ' --attach-data-disks {id}'.format(id=copy_disk_id)
# Validate create vm create command to validate parameters before runnning copy disk command
validate_create_vm_command = create_repair_vm_command + ' --validate'
logger.info('Validating VM template before continuing...')
Expand All @@ -122,6 +124,12 @@ def create(cmd, vm_name, resource_group_name, repair_password=None, repair_usern
logger.info('Creating repair VM...')
_call_az_command(create_repair_vm_command, secure_params=[repair_password, repair_username])

if is_linux:
# Attach copied managed disk to new vm
logger.info('Attaching copied disk to repair VM as data disk...')
attach_disk_command = "az vm disk attach -g {g} --name {disk_id} --vm-name {vm_name} ".format(g=repair_group_name, disk_id=copy_disk_id, vm_name=repair_vm_name)
_call_az_command(attach_disk_command)

# Handle encrypted VM cases
if unlock_encrypted_vm:
stdout, stderr = _unlock_singlepass_encrypted_disk(repair_vm_name, repair_group_name, is_linux)
Expand Down
2 changes: 1 addition & 1 deletion src/vm-repair/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from codecs import open
from setuptools import setup, find_packages

VERSION = "0.4.1"
VERSION = "0.4.2"

CLASSIFIERS = [
'Development Status :: 4 - Beta',
Expand Down