Skip to content
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

Cleanup provisioning code in ansible-test. #73207

Merged
merged 5 commits into from
Jan 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelogs/fragments/ansible-test-cleanup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- ansible-test - Refactor code to remove unused logic for obsolete support of multiple provisioning endpoints.
2 changes: 2 additions & 0 deletions changelogs/fragments/ansible-test-code-cleanup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- ansible-test - Removed unused provisioning code and cleaned up remote provider management logic.
3 changes: 3 additions & 0 deletions changelogs/fragments/ansible-test-remote-aws-region.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
minor_changes:
- ansible-test - Removed the obsolete ``--remote-aws-region`` provisioning option.
- ansible-test - Files used to track remote instances no longer have a region suffix.
2 changes: 1 addition & 1 deletion test/lib/ansible_test/_internal/ci/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class ChangeDetectionNotSupported(ApplicationError):
class AuthContext:
"""Context information required for Ansible Core CI authentication."""
def __init__(self): # type: () -> None
self.region = None # type: t.Optional[str]
pass


class CIProvider(ABC):
Expand Down
10 changes: 3 additions & 7 deletions test/lib/ansible_test/_internal/ci/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,12 @@ def detect_changes(self, args): # type: (TestConfig) -> t.Optional[t.List[str]]

def supports_core_ci_auth(self, context): # type: (AuthContext) -> bool
"""Return True if Ansible Core CI is supported."""
path = self._get_aci_key_path(context)
path = self._get_aci_key_path()
return os.path.exists(path)

def prepare_core_ci_auth(self, context): # type: (AuthContext) -> t.Dict[str, t.Any]
"""Return authentication details for Ansible Core CI."""
path = self._get_aci_key_path(context)
path = self._get_aci_key_path()
auth_key = read_text_file(path).strip()

request = dict(
Expand All @@ -143,12 +143,8 @@ def get_git_details(self, args): # type: (CommonConfig) -> t.Optional[t.Dict[st
"""Return details about git in the current environment."""
return None # not yet implemented for local

def _get_aci_key_path(self, context): # type: (AuthContext) -> str
def _get_aci_key_path(self): # type: () -> str
path = os.path.expanduser('~/.ansible-core-ci.key')

if context.region:
path += '.%s' % context.region

return path


Expand Down
17 changes: 5 additions & 12 deletions test/lib/ansible_test/_internal/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@
walk_sanity_targets,
)

from .core_ci import (
AWS_ENDPOINTS,
)

from .cloud import (
initialize_cloud_plugins,
)

from .core_ci import (
AnsibleCoreCI,
)

from .data import (
data_context,
)
Expand Down Expand Up @@ -924,7 +924,6 @@ def add_environments(parser, isolated_delegation=True):
remote=None,
remote_stage=None,
remote_provider=None,
remote_aws_region=None,
remote_terminate=None,
remote_endpoint=None,
python_interpreter=None,
Expand Down Expand Up @@ -954,20 +953,14 @@ def add_environments(parser, isolated_delegation=True):
remote.add_argument('--remote-provider',
metavar='PROVIDER',
help='remote provider to use: %(choices)s',
choices=['default', 'aws', 'azure', 'parallels', 'ibmvpc', 'ibmps'],
choices=['default'] + sorted(AnsibleCoreCI.PROVIDERS.keys()),
default='default')

remote.add_argument('--remote-endpoint',
metavar='ENDPOINT',
help='remote provisioning endpoint to use (default: auto)',
default=None)

remote.add_argument('--remote-aws-region',
metavar='REGION',
help='remote aws region to use: %(choices)s (default: auto)',
choices=sorted(AWS_ENDPOINTS),
default=None)

remote.add_argument('--remote-terminate',
metavar='WHEN',
help='terminate remote instance: %(choices)s (default: %(default)s)',
Expand Down
2 changes: 1 addition & 1 deletion test/lib/ansible_test/_internal/cloud/aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def _create_ansible_core_ci(self):
"""
:rtype: AnsibleCoreCI
"""
return AnsibleCoreCI(self.args, 'aws', 'sts', persist=False, stage=self.args.remote_stage, provider=self.args.remote_provider)
return AnsibleCoreCI(self.args, 'aws', 'aws', persist=False, stage=self.args.remote_stage, provider='aws', internal=True)


class AwsCloudEnvironment(CloudEnvironment):
Expand Down
2 changes: 1 addition & 1 deletion test/lib/ansible_test/_internal/cloud/azure.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def _create_ansible_core_ci(self):
"""
:rtype: AnsibleCoreCI
"""
return AnsibleCoreCI(self.args, 'azure', 'azure', persist=False, stage=self.args.remote_stage, provider=self.args.remote_provider)
return AnsibleCoreCI(self.args, 'azure', 'azure', persist=False, stage=self.args.remote_stage, provider='azure', internal=True)


class AzureCloudEnvironment(CloudEnvironment):
Expand Down
2 changes: 1 addition & 1 deletion test/lib/ansible_test/_internal/cloud/hcloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def _create_ansible_core_ci(self):
"""
:rtype: AnsibleCoreCI
"""
return AnsibleCoreCI(self.args, 'hetzner', 'hetzner', persist=False, stage=self.args.remote_stage, provider=self.args.remote_provider)
return AnsibleCoreCI(self.args, 'hetzner', 'hetzner', persist=False, stage=self.args.remote_stage, provider='hetzner', internal=True)


class HcloudCloudEnvironment(CloudEnvironment):
Expand Down
1 change: 0 additions & 1 deletion test/lib/ansible_test/_internal/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ def __init__(self, args, command):
self.remote_stage = args.remote_stage # type: str
self.remote_provider = args.remote_provider # type: str
self.remote_endpoint = args.remote_endpoint # type: t.Optional[str]
self.remote_aws_region = args.remote_aws_region # type: str
self.remote_terminate = args.remote_terminate # type: str

if self.remote_provider == 'default':
Expand Down