dont think all files are valid cause libs present (#50103)
verify_file was improperly always returning true if pyvimomi and requests libs were correct moved library checking to parse, avoid unneded errors unless the file is actually meant for this plugin
This commit is contained in:
parent
1a9fcd9a10
commit
49993a55e5
1 changed files with 7 additions and 8 deletions
|
@ -229,13 +229,19 @@ class InventoryModule(BaseInventoryPlugin, Cacheable):
|
||||||
if path.endswith(('vmware.yaml', 'vmware.yml')):
|
if path.endswith(('vmware.yaml', 'vmware.yml')):
|
||||||
valid = True
|
valid = True
|
||||||
|
|
||||||
|
return valid
|
||||||
|
|
||||||
|
def parse(self, inventory, loader, path, cache=True):
|
||||||
|
"""
|
||||||
|
Parses the inventory file
|
||||||
|
"""
|
||||||
|
|
||||||
if not HAS_REQUESTS:
|
if not HAS_REQUESTS:
|
||||||
raise AnsibleParserError('Please install "requests" Python module as this is required'
|
raise AnsibleParserError('Please install "requests" Python module as this is required'
|
||||||
' for VMware Guest dynamic inventory plugin.')
|
' for VMware Guest dynamic inventory plugin.')
|
||||||
elif not HAS_PYVMOMI:
|
elif not HAS_PYVMOMI:
|
||||||
raise AnsibleParserError('Please install "PyVmomi" Python module as this is required'
|
raise AnsibleParserError('Please install "PyVmomi" Python module as this is required'
|
||||||
' for VMware Guest dynamic inventory plugin.')
|
' for VMware Guest dynamic inventory plugin.')
|
||||||
|
|
||||||
if HAS_REQUESTS:
|
if HAS_REQUESTS:
|
||||||
# Pyvmomi 5.5 and onwards requires requests 2.3
|
# Pyvmomi 5.5 and onwards requires requests 2.3
|
||||||
# https://github.com/vmware/pyvmomi/blob/master/requirements.txt
|
# https://github.com/vmware/pyvmomi/blob/master/requirements.txt
|
||||||
|
@ -250,14 +256,7 @@ class InventoryModule(BaseInventoryPlugin, Cacheable):
|
||||||
raise AnsibleParserError("'requests' library version should"
|
raise AnsibleParserError("'requests' library version should"
|
||||||
" be >= %s, found: %s." % (".".join([str(w) for w in required_version]),
|
" be >= %s, found: %s." % (".".join([str(w) for w in required_version]),
|
||||||
requests.__version__))
|
requests.__version__))
|
||||||
valid = True
|
|
||||||
|
|
||||||
return valid
|
|
||||||
|
|
||||||
def parse(self, inventory, loader, path, cache=True):
|
|
||||||
"""
|
|
||||||
Parses the inventory file
|
|
||||||
"""
|
|
||||||
super(InventoryModule, self).parse(inventory, loader, path, cache=cache)
|
super(InventoryModule, self).parse(inventory, loader, path, cache=cache)
|
||||||
|
|
||||||
cache_key = self.get_cache_key(path)
|
cache_key = self.get_cache_key(path)
|
||||||
|
|
Loading…
Reference in a new issue