Skip to content

Commit

Permalink
Fix UUID issue for data disk (#4479)
Browse files Browse the repository at this point in the history
* new version 0.4.2

* new version 0.4.2

* Fixed an UUID issue by getting the data disk attached to the VM after VM creation

* Fixed an UUID issue by getting the data disk attached to the VM after VM creation

* Fixed an UUID issue by getting the data disk attached to the VM after VM creation

* Fixed an UUID issue by getting the data disk attached to the VM after VM creation

* Fixed an UUID issue by getting the data disk attached to the VM after VM creation

* Fixed an UUID issue by getting the data disk attached to the VM after VM creation

* Update src/vm-repair/azext_vm_repair/custom.py

Co-authored-by: ZelinWang <zelinwang@microsoft.com>

Co-authored-by: ZelinWang <zelinwang@microsoft.com>
  • Loading branch information
malachma and wangzelin007 committed Mar 8, 2022
1 parent f77b373 commit b68739c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
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

0 comments on commit b68739c

Please sign in to comment.