From f0a5854e396c9ec3e091f386d54b676e875c9ba0 Mon Sep 17 00:00:00 2001 From: Abhijeet Kasurde Date: Fri, 30 Jun 2017 19:58:08 +0530 Subject: [PATCH] Fix unresolved import in vmware module_utils (#25288) Signed-off-by: Abhijeet Kasurde --- lib/ansible/module_utils/vmware.py | 17 +++++++++-------- test/sanity/pep8/legacy-files.txt | 1 - 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/ansible/module_utils/vmware.py b/lib/ansible/module_utils/vmware.py index 3a0acc85faf..a428e015750 100644 --- a/lib/ansible/module_utils/vmware.py +++ b/lib/ansible/module_utils/vmware.py @@ -17,8 +17,10 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +from ansible.module_utils.urls import fetch_url from ansible.module_utils.six import iteritems import atexit +import os import ssl import time @@ -94,7 +96,7 @@ def find_entity_child_by_path(content, entityRootFolder, path): paths = path.split("/") try: for path in paths: - entity = searchIndex.FindChild (entity, path) + entity = searchIndex.FindChild(entity, path) if entity.name == paths[-1]: return entity @@ -139,6 +141,7 @@ def find_datacenter_by_name(content, datacenter_name): return None + def find_datastore_by_name(content, datastore_name): datastores = get_all_objs(content, [vim.Datastore]) @@ -381,8 +384,7 @@ def get_all_objs(content, vimtype, folder=None, recurse=True): return obj -def fetch_file_from_guest(content, vm, username, password, src, dest): - +def fetch_file_from_guest(module, content, vm, username, password, src, dest): """ Use VMWare's filemanager api to fetch a file over http """ result = {'failed': False} @@ -406,7 +408,7 @@ def fetch_file_from_guest(content, vm, username, password, src, dest): result['url'] = fti.url # Use module_utils to fetch the remote url returned from the api - rsp, info = fetch_url(self.module, fti.url, use_proxy=False, + rsp, info = fetch_url(module, fti.url, use_proxy=False, force=True, last_mod_time=None, timeout=10, headers=None) @@ -430,8 +432,7 @@ def fetch_file_from_guest(content, vm, username, password, src, dest): return result -def push_file_to_guest(content, vm, username, password, src, dest, overwrite=True): - +def push_file_to_guest(module, content, vm, username, password, src, dest, overwrite=True): """ Use VMWare's filemanager api to fetch a file over http """ result = {'failed': False} @@ -467,7 +468,7 @@ def push_file_to_guest(content, vm, username, password, src, dest, overwrite=Tru filesize, overwrite) # PUT the filedata to the url ... - rsp, info = fetch_url(self.module, url, method="put", data=fdata, + rsp, info = fetch_url(module, url, method="put", data=fdata, use_proxy=False, force=True, last_mod_time=None, timeout=10, headers=None) @@ -486,7 +487,7 @@ def run_command_in_guest(content, vm, username, password, program_path, program_ tools_status = vm.guest.toolsStatus if (tools_status == 'toolsNotInstalled' or - tools_status == 'toolsNotRunning'): + tools_status == 'toolsNotRunning'): result['failed'] = True result['msg'] = "VMwareTools is not installed or is not running in the guest" return result diff --git a/test/sanity/pep8/legacy-files.txt b/test/sanity/pep8/legacy-files.txt index 371200c1ea9..8aaf6983202 100644 --- a/test/sanity/pep8/legacy-files.txt +++ b/test/sanity/pep8/legacy-files.txt @@ -2,7 +2,6 @@ hacking/conf2yaml.py lib/ansible/cli/config.py lib/ansible/config/data.py lib/ansible/config/manager.py -lib/ansible/module_utils/vmware.py lib/ansible/modules/cloud/amazon/_ec2_ami_search.py lib/ansible/modules/cloud/amazon/_ec2_remote_facts.py lib/ansible/modules/cloud/amazon/_ec2_vpc.py