Support for generalizing VMs (#49704)

This commit is contained in:
Zim Kalinowski 2018-12-10 16:21:09 +08:00 committed by GitHub
commit b89eb7a8c9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 60 additions and 7 deletions

View file

@ -305,6 +305,9 @@ class AzureRMVirtualMachineFacts(AzureRMModuleBase):
code = instance['statuses'][index]['code'].split('/')
if code[0] == 'PowerState':
power_state = code[1]
elif code[0] == 'OSState' and code[1] == 'generalized':
power_state = 'generalized'
break
new_result = {}
new_result['power_state'] = power_state
@ -317,12 +320,17 @@ class AzureRMVirtualMachineFacts(AzureRMModuleBase):
new_result['admin_username'] = result['properties']['osProfile']['adminUsername']
image = result['properties']['storageProfile'].get('imageReference')
if image is not None:
new_result['image'] = {
'publisher': image['publisher'],
'sku': image['sku'],
'offer': image['offer'],
'version': image['version']
}
if image.get('publisher', None) is not None:
new_result['image'] = {
'publisher': image['publisher'],
'sku': image['sku'],
'offer': image['offer'],
'version': image['version']
}
else:
new_result['image'] = {
'id': image.get('id', None)
}
vhd = result['properties']['storageProfile']['osDisk'].get('vhd')
if vhd is not None: