mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-25 06:10:22 -07:00
vmware_guest: Rename existing VM, or mark as template (#20018)
* vmware_guest: Add rename feature * vmware_guest: Add feature to mark an existing VM as template
This commit is contained in:
parent
d9ced3f4d1
commit
8241675095
1 changed files with 21 additions and 0 deletions
|
@ -51,6 +51,12 @@ options:
|
||||||
description:
|
description:
|
||||||
- Name of the newly deployed guest
|
- Name of the newly deployed guest
|
||||||
required: True
|
required: True
|
||||||
|
new_name:
|
||||||
|
description:
|
||||||
|
- Rename a VM
|
||||||
|
- New Name of the exising VM
|
||||||
|
required: False
|
||||||
|
version_added: "2.3"
|
||||||
name_match:
|
name_match:
|
||||||
description:
|
description:
|
||||||
- If multiple vms matching the name, use the first or last found
|
- If multiple vms matching the name, use the first or last found
|
||||||
|
@ -1399,6 +1405,20 @@ class PyVmomiHelper(object):
|
||||||
|
|
||||||
change_applied = True
|
change_applied = True
|
||||||
|
|
||||||
|
# Mark VM as Template
|
||||||
|
if self.params['is_template']:
|
||||||
|
task = self.current_vm_obj.MarkAsTemplate()
|
||||||
|
change_applied = True
|
||||||
|
|
||||||
|
# Rename VM
|
||||||
|
if self.params['new_name']:
|
||||||
|
task = self.current_vm_obj.Rename_Task(self.params['new_name'])
|
||||||
|
|
||||||
|
if task.info.state == 'error':
|
||||||
|
return {'changed': False, 'failed': True, 'msg': task.info.error.msg}
|
||||||
|
|
||||||
|
change_applied = True
|
||||||
|
|
||||||
vm_facts = self.gather_facts(self.current_vm_obj)
|
vm_facts = self.gather_facts(self.current_vm_obj)
|
||||||
return {'changed': change_applied, 'failed': False, 'instance': vm_facts}
|
return {'changed': change_applied, 'failed': False, 'instance': vm_facts}
|
||||||
|
|
||||||
|
@ -1733,6 +1753,7 @@ def main():
|
||||||
is_template=dict(required=False, type='bool', default=False),
|
is_template=dict(required=False, type='bool', default=False),
|
||||||
annotation=dict(required=False, type='str', aliases=['notes']),
|
annotation=dict(required=False, type='str', aliases=['notes']),
|
||||||
name=dict(required=True, type='str'),
|
name=dict(required=True, type='str'),
|
||||||
|
new_name=dict(required=False, type='str'),
|
||||||
name_match=dict(required=False, type='str', default='first'),
|
name_match=dict(required=False, type='str', default='first'),
|
||||||
snapshot_op=dict(required=False, type='dict', default={}),
|
snapshot_op=dict(required=False, type='dict', default={}),
|
||||||
uuid=dict(required=False, type='str'),
|
uuid=dict(required=False, type='str'),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue