From c29b03e77b244300b446fa2b7e6bbeb518ed8e63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Travassac?= Date: Tue, 22 May 2018 14:10:47 +0200 Subject: [PATCH] VMware: Fix file operation to work with ESXi directly (#40148) Now, file_operation module can be used with both vCenter and Standalone ESXi server. --- .../modules/cloud/vmware/vmware_guest_file_operation.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/ansible/modules/cloud/vmware/vmware_guest_file_operation.py b/lib/ansible/modules/cloud/vmware/vmware_guest_file_operation.py index 535e002839..536dab25ac 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_guest_file_operation.py +++ b/lib/ansible/modules/cloud/vmware/vmware_guest_file_operation.py @@ -277,6 +277,7 @@ class VmwareGuestFileManager(PyVmomi): result = dict(changed=True, uuid=self.vm.summary.config.uuid) vm_username = self.module.params['vm_username'] vm_password = self.module.params['vm_password'] + hostname = self.module.params['hostname'] dest = self.module.params["fetch"]['dest'] src = self.module.params['fetch']['src'] creds = vim.vm.guest.NamePasswordAuthentication(username=vm_username, password=vm_password) @@ -286,6 +287,7 @@ class VmwareGuestFileManager(PyVmomi): fileTransferInfo = file_manager.InitiateFileTransferFromGuest(vm=self.vm, auth=creds, guestFilePath=src) url = fileTransferInfo.url + url = url.replace("*", hostname) resp, info = urls.fetch_url(self.module, url, method="GET") try: with open(dest, "wb") as local_file: @@ -316,6 +318,7 @@ class VmwareGuestFileManager(PyVmomi): result = dict(changed=True, uuid=self.vm.summary.config.uuid) vm_username = self.module.params['vm_username'] vm_password = self.module.params['vm_password'] + hostname = self.module.params['hostname'] overwrite = self.module.params["copy"]["overwrite"] dest = self.module.params["copy"]['dest'] src = self.module.params['copy']['src'] @@ -340,6 +343,7 @@ class VmwareGuestFileManager(PyVmomi): url = file_manager.InitiateFileTransferToGuest(vm=self.vm, auth=creds, guestFilePath=dest, fileAttributes=file_attributes, overwrite=overwrite, fileSize=file_size) + url = url.replace("*", hostname) resp, info = urls.fetch_url(self.module, url, data=data, method="PUT") status_code = info["status"]