Add the way to create a VM with the image id (#58106)
This commit is contained in:
parent
cc7bea2100
commit
3a3465c47d
2 changed files with 17 additions and 2 deletions
|
@ -510,6 +510,16 @@ EXAMPLES = '''
|
|||
name: customimage001
|
||||
resource_group: myResourceGroup
|
||||
|
||||
- name: Create a VM with an image id
|
||||
azure_rm_virtualmachine:
|
||||
resource_group: myResourceGroup
|
||||
name: testvm001
|
||||
vm_size: Standard_DS1_v2
|
||||
admin_username: adminUser
|
||||
admin_password: password01
|
||||
image:
|
||||
id: '{{image_id}}'
|
||||
|
||||
- name: Create VM with spcified OS disk size
|
||||
azure_rm_virtualmachine:
|
||||
resource_group: myResourceGroup
|
||||
|
@ -988,8 +998,13 @@ class AzureRMVirtualMachine(AzureRMModuleBase):
|
|||
image_reference = self.get_custom_image_reference(
|
||||
self.image.get('name'),
|
||||
self.image.get('resource_group'))
|
||||
elif self.image.get('id'):
|
||||
try:
|
||||
image_reference = self.compute_models.ImageReference(id=self.image['id'])
|
||||
except Exception as exc:
|
||||
self.fail("id Error: Cannot get image from the reference id - {0}".format(self.image['id']))
|
||||
else:
|
||||
self.fail("parameter error: expecting image to contain [publisher, offer, sku, version] or [name, resource_group]")
|
||||
self.fail("parameter error: expecting image to contain [publisher, offer, sku, version], [name, resource_group] or [id]")
|
||||
elif self.image and isinstance(self.image, str):
|
||||
custom_image = True
|
||||
image_reference = self.get_custom_image_reference(self.image)
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
image:
|
||||
offer: UbuntuServer
|
||||
register: fail_invalid_image_dict
|
||||
failed_when: 'fail_invalid_image_dict.msg != "parameter error: expecting image to contain [publisher, offer, sku, version] or [name, resource_group]"'
|
||||
failed_when: 'fail_invalid_image_dict.msg != "parameter error: expecting image to contain [publisher, offer, sku, version], [name, resource_group] or [id]"'
|
||||
|
||||
- name: Assert error thrown with invalid image type
|
||||
azure_rm_virtualmachine:
|
||||
|
|
Loading…
Reference in a new issue