From 905eeb11c4555655ac8819e74b8ae7384d18b2a1 Mon Sep 17 00:00:00 2001 From: Max Date: Thu, 14 Apr 2022 07:57:58 +0000 Subject: [PATCH] Fix os_type comparison in azure_rm_manageddisk with existing disk (#621) * 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> --- plugins/modules/azure_rm_manageddisk.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/plugins/modules/azure_rm_manageddisk.py b/plugins/modules/azure_rm_manageddisk.py index 4e6fe821b..cef701b1e 100644 --- a/plugins/modules/azure_rm_manageddisk.py +++ b/plugins/modules/azure_rm_manageddisk.py @@ -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 @@ -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: