-
Notifications
You must be signed in to change notification settings - Fork 338
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
community.vmware.vmware_guest_file_operation: Fetch throw error "msg": "local file write exception : 'NoneType' object has no attribute 'read'", #485
Comments
I already change vmware_guest_file_operation.py line 351 to
Still getting the same error
|
Thank you @kpatelsp for reporting this issue. Haven't a problem of connection reachable to an ESXi host from Ansible host? |
@kpatelsp Please use the issue template. It helps to gather information about the issue. A simple one-liner in the issue is not going to take us anywhere. |
I did the open issues with the template but Bot closed it #72521. |
Connect to ESXi doesn't use a user. Temporary URL example
So the below error happens a lot when the module can't connect to ESXi.
|
@kpatelsp Can you please make the following change and let us know the result? diff --git a/plugins/modules/vmware_guest_file_operation.py b/plugins/modules/vmware_guest_file_operation.py
index 6eb20fa..707af31 100644
--- a/plugins/modules/vmware_guest_file_operation.py
+++ b/plugins/modules/vmware_guest_file_operation.py
@@ -349,6 +349,8 @@ class VmwareGuestFileManager(PyVmomi):
url = fileTransferInfo.url
url = url.replace("*", hostname)
resp, info = urls.fetch_url(self.module, url, method="GET")
+ if info['status'] != 200 or not resp:
+ self.module.fail_json(msg="Failed to fetch file : %s" % info['msg'], body=info['body'])
try:
with open(dest, "wb") as local_file:
local_file.write(resp.read()) I am able to reproduce this kind of error when I specify a invalid file name. - community.vmware.vmware_guest_file_operation:
datacenter: Asia-Datacenter1
cluster: Asia-Cluster1
folder: "/Asia-Datacenter1/vm/prod"
validate_certs: no
vm_id: "{{ vm_name }}"
vm_username: "{{ guest_username }}"
vm_password: "{{ guest_password }}"
fetch:
src: "../etc/passwd"
dest: "./1402.txt" Error looks like this -
|
Return useful error message when exception occurs while file operation. Partially fixes: ansible-collections#485 Signed-off-by: Abhijeet Kasurde <[email protected]>
@Akasurde Error:
|
How about this - diff --git a/plugins/modules/vmware_guest_file_operation.py b/plugins/modules/vmware_guest_file_operation.py
index 6eb20fa..58d5fb4 100644
--- a/plugins/modules/vmware_guest_file_operation.py
+++ b/plugins/modules/vmware_guest_file_operation.py
@@ -349,6 +349,8 @@ class VmwareGuestFileManager(PyVmomi):
url = fileTransferInfo.url
url = url.replace("*", hostname)
resp, info = urls.fetch_url(self.module, url, method="GET")
+ if info.get('status') != 200 or not resp:
+ self.module.fail_json(msg="Failed to fetch file : %s" % info.get('msg', ''), body=info.get('body', ''))
try:
with open(dest, "wb") as local_file:
local_file.write(resp.read()) |
@Akasurde |
@Akasurde |
I do not know what is 'urlopen error 0' and not able to reproduce this at my end. @sky-joker Do you know anything about this error? |
Umm... I seem the cause of the error is an environmental dependence. My lab doesn't the error occurs again... |
Issue Resolved. It was a proxy issue. I did have an entire management network to the environment file added no_proxy="*.domain.local,x.x.x.x/24" This did not work. I have to add each host IP address. Thanks for all your help. |
|
Please raise issues via the new interfaceSUMMARY
I am using community.vmware.vmware_guest_file_operation: fetch option getting error
I already change vmware_guest_file_operation.py line 355 to as per
Line 341 hostname = self.module.params['hostname']
Line 350-352
Still getting same error
I found old solution that suggest to change above line. however no luck.
ISSUE TYPE
COMPONENT NAME
vmware_guest_file_operation
ANSIBLE VERSION
CONFIGURATION
OS / ENVIRONMENT
Red Hat Enterprise Linux Server release 7.8 (Maipo)
STEPS TO REPRODUCE
EXPECTED RESULTS
ACTUAL RESULTS
Copied from original issue: ansible/ansible#72521
The text was updated successfully, but these errors were encountered: