Backport/2.7/49704 (#52467)

* backport image crash fix

* adding changelog fragment
This commit is contained in:
Zim Kalinowski 2019-02-19 00:47:35 +08:00 committed by Toshio Kuratomi
parent 2800f23274
commit f85cd0b0c2
2 changed files with 13 additions and 6 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- azure_rm_virtualmachine_facts - fix crash when vm created from custom image

View file

@ -299,12 +299,17 @@ class AzureRMVirtualMachineFacts(AzureRMModuleBase):
new_result['admin_username'] = os_profile.get('adminUsername') new_result['admin_username'] = os_profile.get('adminUsername')
image = result['properties']['storageProfile'].get('imageReference') image = result['properties']['storageProfile'].get('imageReference')
if image is not None: if image is not None:
if image.get('publisher', None) is not None:
new_result['image'] = { new_result['image'] = {
'publisher': image['publisher'], 'publisher': image['publisher'],
'sku': image['sku'], 'sku': image['sku'],
'offer': image['offer'], 'offer': image['offer'],
'version': image['version'] 'version': image['version']
} }
else:
new_result['image'] = {
'id': image.get('id', None)
}
vhd = result['properties']['storageProfile']['osDisk'].get('vhd') vhd = result['properties']['storageProfile']['osDisk'].get('vhd')
if vhd is not None: if vhd is not None: