mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-04 15:34:01 -07:00
Overhaul ansible-test cloud test plugins. (#53044)
This commit is contained in:
parent
9c644d9bcc
commit
eeaff731de
34 changed files with 338 additions and 211 deletions
|
@ -11,6 +11,7 @@ from os.path import isfile
|
|||
from lib.cloud import (
|
||||
CloudProvider,
|
||||
CloudEnvironment,
|
||||
CloudEnvironmentConfig,
|
||||
)
|
||||
|
||||
from lib.util import ConfigParser, display
|
||||
|
@ -25,7 +26,7 @@ class CloudscaleCloudProvider(CloudProvider):
|
|||
"""
|
||||
:type args: TestConfig
|
||||
"""
|
||||
super(CloudscaleCloudProvider, self).__init__(args, config_extension='.ini')
|
||||
super(CloudscaleCloudProvider, self).__init__(args)
|
||||
|
||||
def filter(self, targets, exclude):
|
||||
"""Filter out the cloud tests when the necessary config and resources are not available.
|
||||
|
@ -38,6 +39,7 @@ class CloudscaleCloudProvider(CloudProvider):
|
|||
super(CloudscaleCloudProvider, self).filter(targets, exclude)
|
||||
|
||||
def setup(self):
|
||||
"""Setup the cloud resource before delegation and register a cleanup callback."""
|
||||
super(CloudscaleCloudProvider, self).setup()
|
||||
|
||||
if isfile(self.config_static_path):
|
||||
|
@ -46,28 +48,30 @@ class CloudscaleCloudProvider(CloudProvider):
|
|||
verbosity=1)
|
||||
self.config_path = self.config_static_path
|
||||
self.managed = False
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
|
||||
class CloudscaleCloudEnvironment(CloudEnvironment):
|
||||
"""Cloudscale cloud environment plugin. Updates integration test environment
|
||||
after delegation.
|
||||
"""
|
||||
def configure_environment(self, env, cmd):
|
||||
def get_environment_config(self):
|
||||
"""
|
||||
:type env: dict[str, str]
|
||||
:type cmd: list[str]
|
||||
:rtype: CloudEnvironmentConfig
|
||||
"""
|
||||
parser = ConfigParser()
|
||||
parser.read(self.config_path)
|
||||
|
||||
changes = dict(
|
||||
env_vars = dict(
|
||||
CLOUDSCALE_API_TOKEN=parser.get('default', 'cloudscale_api_token'),
|
||||
)
|
||||
|
||||
env.update(changes)
|
||||
ansible_vars = dict(
|
||||
cloudscale_resource_prefix=self.resource_prefix,
|
||||
)
|
||||
|
||||
cmd.append('-e')
|
||||
cmd.append('cloudscale_resource_prefix=%s' % self.resource_prefix)
|
||||
ansible_vars.update(dict((key.lower(), value) for key, value in env_vars.items()))
|
||||
|
||||
return CloudEnvironmentConfig(
|
||||
env_vars=env_vars,
|
||||
ansible_vars=ansible_vars,
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue