Skip to content

Commit

Permalink
Fix os_type comparison in azure_rm_manageddisk with existing disk (#621)
Browse files Browse the repository at this point in the history
* Fix os_type comparison in azure_rm_manageddisk with existing disk

* Update str to OperatingSystemTypes conversion, leveraging the sdk capabilities

* Fix bug in os_type comparison when curren os_type is None

Co-authored-by: xuzhang3 <57888764+xuzhang3@users.noreply.github.com>
  • Loading branch information
nbr23 and xuzhang3 authored Apr 14, 2022
1 parent ebd9cde commit 905eeb1
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions plugins/modules/azure_rm_manageddisk.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,11 +455,7 @@ def generate_managed_disk_property(self):
creation_data['create_option'] = self.compute_models.DiskCreateOption.copy
creation_data['source_resource_id'] = self.source_uri
if self.os_type:
typecon = {
'linux': self.compute_models.OperatingSystemTypes.linux,
'windows': self.compute_models.OperatingSystemTypes.windows
}
disk_params['os_type'] = typecon[self.os_type]
disk_params['os_type'] = self.compute_models.OperatingSystemTypes(self.os_type.capitalize())
else:
disk_params['os_type'] = None
disk_params['creation_data'] = creation_data
Expand All @@ -483,7 +479,7 @@ def is_different(self, found_disk, new_disk):
if not found_disk['disk_size_gb'] == new_disk['disk_size_gb']:
resp = True
if new_disk.get('os_type'):
if not found_disk['os_type'] == new_disk['os_type']:
if found_disk['os_type'] is None or not self.compute_models.OperatingSystemTypes(found_disk['os_type'].capitalize()) == new_disk['os_type']:
resp = True
if new_disk.get('sku'):
if not found_disk['storage_account_type'] == new_disk['sku'].name:
Expand Down

0 comments on commit 905eeb1

Please sign in to comment.