Skip to content

Commit

Permalink
ansible-test - Remove azure support for Sherlock.
Browse files Browse the repository at this point in the history
  • Loading branch information
mattclay committed Jan 13, 2022
1 parent c8dd96b commit 7fff408
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 45 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/ansible-test-azure-sherlock.yml
@@ -0,0 +1,2 @@
minor_changes:
- ansible-test - Removed support for Sherlock from the Azure provisioning plugin.
Expand Up @@ -2,14 +2,8 @@
from __future__ import annotations

import configparser
import os
import urllib.parse
import typing as t

from ....io import (
read_text_file,
)

from ....util import (
ApplicationError,
display,
Expand All @@ -23,10 +17,6 @@
IntegrationTarget,
)

from ....http import (
HttpClient,
)

from ....core_ci import (
AnsibleCoreCI,
)
Expand All @@ -40,8 +30,6 @@

class AzureCloudProvider(CloudProvider):
"""Azure cloud provider plugin. Sets up cloud resources before delegation."""
SHERLOCK_CONFIG_PATH = os.path.expanduser('~/.ansible-sherlock-ci.cfg')

def __init__(self, args): # type: (IntegrationConfig) -> None
super().__init__(args)

Expand All @@ -56,9 +44,6 @@ def filter(self, targets, exclude): # type: (t.Tuple[IntegrationTarget, ...], t
if aci.available:
return

if os.path.isfile(self.SHERLOCK_CONFIG_PATH):
return

super().filter(targets, exclude)

def setup(self): # type: () -> None
Expand All @@ -78,40 +63,19 @@ def cleanup(self): # type: () -> None
super().cleanup()

def _setup_dynamic(self): # type: () -> None
"""Request Azure credentials through Sherlock."""
"""Request Azure credentials through ansible-core-ci."""
display.info('Provisioning %s cloud environment.' % self.platform, verbosity=1)

config = self._read_config_template()
response = {}

if os.path.isfile(self.SHERLOCK_CONFIG_PATH):
sherlock_uri = read_text_file(self.SHERLOCK_CONFIG_PATH).splitlines()[0].strip() + '&rgcount=2'

parts = urllib.parse.urlparse(sherlock_uri)
query_string = urllib.parse.parse_qs(parts.query)
base_uri = urllib.parse.urlunparse(parts[:4] + ('', ''))

if 'code' not in query_string:
example_uri = 'https://example.azurewebsites.net/api/sandbox-provisioning'
raise ApplicationError('The Sherlock URI must include the API key in the query string. Example: %s?code=xxx' % example_uri)

display.info('Initializing azure/sherlock from: %s' % base_uri, verbosity=1)

http = HttpClient(self.args)
result = http.get(sherlock_uri)

display.info('Started azure/sherlock from: %s' % base_uri, verbosity=1)

if not self.args.explain:
response = result.json()
else:
aci = self._create_ansible_core_ci()
aci = self._create_ansible_core_ci()

aci_result = aci.start()
aci_result = aci.start()

if not self.args.explain:
response = aci_result['azure']
self.aci = aci
if not self.args.explain:
response = aci_result['azure']
self.aci = aci

if not self.args.explain:
values = dict(
Expand Down
4 changes: 1 addition & 3 deletions test/lib/ansible_test/config/cloud-config-azure.ini.template
Expand Up @@ -9,9 +9,7 @@
# fill in the values below and save this file without the .template extension.
# This will cause ansible-test to use the given configuration instead of temporary credentials.
#
# NOTE: Automatic provisioning of Azure credentials requires one of:
# 1) ansible-core-ci API key in ~/.ansible-core-ci.key
# 2) Sherlock URL (including API key) in ~/.ansible-sherlock-ci.cfg
# NOTE: Automatic provisioning of Azure credentials requires an ansible-core-ci API key in ~/.ansible-core-ci.key

[default]
# Provide either Service Principal or Active Directory credentials below.
Expand Down

0 comments on commit 7fff408

Please sign in to comment.