INNER CODE UNIT · Python
_establish_vm
ansible-collections/community.vmware · plugins/connection/vmware_tools.py:317
def _establish_vm(self, check_vm_credentials=True):
searchIndex = self._si.content.searchIndex
self.vm = None
if self.get_option("vm_path") is not None:
self.vm = searchIndex.FindByInventoryPath(self.get_option("vm_path"))
if self.vm is None:
raise AnsibleError("Unable to find VM by path '%s'" % to_native(self.get_option("vm_path")))
elif self.get_option("vm_uuid") is not None:
self.vm = searchIndex.FindByUuid(None, self.get_option("vm_uuid"), True)
if self.vm is None:
raise AnsibleError("Unable to find VM by uuid '%s'" % to_native(self.get_option("vm_uuid")))
self.vm_auth = vim.NamePasswordAuthentication(
username=self.get_option("vm_user"), password=self.get_option("vm_password"), interactiveSession=False
)
try:
if check_vm_credentials: