Skip to content

Commit

Permalink
adds vmware_vm.get_mks_ticket saltstack#291
Browse files Browse the repository at this point in the history
  • Loading branch information
abhi1693 committed Oct 20, 2022
1 parent e854f69 commit 4cf0f34
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/saltext/vmware/modules/vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -648,3 +648,34 @@ def relocate(
if ret == "success":
return {"virtual_machine": "moved"}
return {"virtual_machine": "failed to move"}

def get_mks_ticket(vm_name, ticket_type, service_instance=None, profile=None):
"""
Get ticket of virtual machine of passed object type.
vm_name
The name of the virtual machine to relocate.
ticket_type
Type of ticket.
service_instance
(optional) The Service Instance from which to obtain managed object references.
profile
Profile to use (optional)
CLI Example:
.. code-block:: bash
salt '*' vmware_vm.get_mks_ticket vm_name=vm01 ticket_type=webmks
"""
if service_instance is None:
service_instance = connect.get_service_instance(config=__opts__, profile=profile)

log.info(f"Acquiring ticket {ticket_type} for {vm_name}")
vm_ref = utils_common.get_mor_by_property(service_instance, vim.VirtualMachine, vm_name)
ticket = vm_ref.AcquireTicket(ticket_type)

return {"host": ticket.host, "ticket": ticket.ticket}

0 comments on commit 4cf0f34

Please sign in to comment.