mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-26 12:21:26 -07:00
Add support for cloud tests to ansible-test. (#24315)
* Split out ansible-test docker functions. * Add cloud support to ansible-test.
This commit is contained in:
parent
986765312f
commit
a07d42e16d
19 changed files with 1059 additions and 135 deletions
|
@ -5,6 +5,7 @@ from __future__ import absolute_import, print_function
|
|||
import errno
|
||||
import os
|
||||
import pipes
|
||||
import pkgutil
|
||||
import shutil
|
||||
import subprocess
|
||||
import re
|
||||
|
@ -505,4 +506,45 @@ def parse_to_dict(pattern, value):
|
|||
return match.groupdict()
|
||||
|
||||
|
||||
def get_subclasses(class_type):
|
||||
"""
|
||||
:type class_type: type
|
||||
:rtype: set[str]
|
||||
"""
|
||||
subclasses = set()
|
||||
queue = [class_type]
|
||||
|
||||
while queue:
|
||||
parent = queue.pop()
|
||||
|
||||
for child in parent.__subclasses__():
|
||||
if child not in subclasses:
|
||||
subclasses.add(child)
|
||||
queue.append(child)
|
||||
|
||||
return subclasses
|
||||
|
||||
|
||||
def import_plugins(directory):
|
||||
"""
|
||||
:type directory: str
|
||||
"""
|
||||
path = os.path.join(os.path.dirname(__file__), directory)
|
||||
prefix = 'lib.%s.' % directory
|
||||
|
||||
for (_, name, _) in pkgutil.iter_modules([path], prefix=prefix):
|
||||
__import__(name)
|
||||
|
||||
|
||||
def load_plugins(base_type, database):
|
||||
"""
|
||||
:type base_type: type
|
||||
:type database: dict[str, type]
|
||||
"""
|
||||
plugins = dict((sc.__module__.split('.')[2], sc) for sc in get_subclasses(base_type)) # type: dict [str, type]
|
||||
|
||||
for plugin in plugins:
|
||||
database[plugin] = plugins[plugin]
|
||||
|
||||
|
||||
display = Display() # pylint: disable=locally-disabled, invalid-name
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue