mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02: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:
|
||||
- Name of the newly deployed guest
|
||||
required: True
|
||||
new_name:
|
||||
description:
|
||||
- Rename a VM
|
||||
- New Name of the exising VM
|
||||
required: False
|
||||
version_added: "2.3"
|
||||
name_match:
|
||||
description:
|
||||
- If multiple vms matching the name, use the first or last found
|
||||
|
@ -1399,6 +1405,20 @@ class PyVmomiHelper(object):
|
|||
|
||||
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)
|
||||
return {'changed': change_applied, 'failed': False, 'instance': vm_facts}
|
||||
|
||||
|
@ -1733,6 +1753,7 @@ def main():
|
|||
is_template=dict(required=False, type='bool', default=False),
|
||||
annotation=dict(required=False, type='str', aliases=['notes']),
|
||||
name=dict(required=True, type='str'),
|
||||
new_name=dict(required=False, type='str'),
|
||||
name_match=dict(required=False, type='str', default='first'),
|
||||
snapshot_op=dict(required=False, type='dict', default={}),
|
||||
uuid=dict(required=False, type='str'),
|
||||
|
|
Loading…
Reference in a new issue