|
|
@ -36,7 +36,7 @@ AWS_ENDPOINTS = {
|
|
|
|
|
|
|
|
|
|
|
|
class AnsibleCoreCI(object):
|
|
|
|
class AnsibleCoreCI(object):
|
|
|
|
"""Client for Ansible Core CI services."""
|
|
|
|
"""Client for Ansible Core CI services."""
|
|
|
|
def __init__(self, args, platform, version, stage='prod', persist=True, load=True, name=None):
|
|
|
|
def __init__(self, args, platform, version, stage='prod', persist=True, load=True, name=None, provider=None):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
:type args: EnvironmentConfig
|
|
|
|
:type args: EnvironmentConfig
|
|
|
|
:type platform: str
|
|
|
|
:type platform: str
|
|
|
@ -57,8 +57,12 @@ class AnsibleCoreCI(object):
|
|
|
|
self.max_threshold = 1
|
|
|
|
self.max_threshold = 1
|
|
|
|
self.name = name if name else '%s-%s' % (self.platform, self.version)
|
|
|
|
self.name = name if name else '%s-%s' % (self.platform, self.version)
|
|
|
|
self.ci_key = os.path.expanduser('~/.ansible-core-ci.key')
|
|
|
|
self.ci_key = os.path.expanduser('~/.ansible-core-ci.key')
|
|
|
|
|
|
|
|
self.resource = 'jobs'
|
|
|
|
|
|
|
|
|
|
|
|
aws_platforms = (
|
|
|
|
# Assign each supported platform to one provider.
|
|
|
|
|
|
|
|
# This is used to determine the provider from the platform when no provider is specified.
|
|
|
|
|
|
|
|
providers = dict(
|
|
|
|
|
|
|
|
aws=(
|
|
|
|
'aws',
|
|
|
|
'aws',
|
|
|
|
'azure',
|
|
|
|
'azure',
|
|
|
|
'windows',
|
|
|
|
'windows',
|
|
|
@ -67,13 +71,28 @@ class AnsibleCoreCI(object):
|
|
|
|
'vyos',
|
|
|
|
'vyos',
|
|
|
|
'junos',
|
|
|
|
'junos',
|
|
|
|
'ios',
|
|
|
|
'ios',
|
|
|
|
)
|
|
|
|
),
|
|
|
|
|
|
|
|
azure=(
|
|
|
|
osx_platforms = (
|
|
|
|
),
|
|
|
|
|
|
|
|
parallels=(
|
|
|
|
'osx',
|
|
|
|
'osx',
|
|
|
|
|
|
|
|
),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
if self.platform in aws_platforms:
|
|
|
|
if provider:
|
|
|
|
|
|
|
|
# override default provider selection (not all combinations are valid)
|
|
|
|
|
|
|
|
self.provider = provider
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
for candidate in providers:
|
|
|
|
|
|
|
|
if platform in providers[candidate]:
|
|
|
|
|
|
|
|
# assign default provider based on platform
|
|
|
|
|
|
|
|
self.provider = candidate
|
|
|
|
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if self.provider in ('aws', 'azure'):
|
|
|
|
|
|
|
|
if self.provider != 'aws':
|
|
|
|
|
|
|
|
self.resource = self.provider
|
|
|
|
|
|
|
|
|
|
|
|
if args.remote_aws_region:
|
|
|
|
if args.remote_aws_region:
|
|
|
|
# permit command-line override of region selection
|
|
|
|
# permit command-line override of region selection
|
|
|
|
region = args.remote_aws_region
|
|
|
|
region = args.remote_aws_region
|
|
|
@ -97,7 +116,7 @@ class AnsibleCoreCI(object):
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
self.ssh_key = SshKey(args)
|
|
|
|
self.ssh_key = SshKey(args)
|
|
|
|
self.port = 22
|
|
|
|
self.port = 22
|
|
|
|
elif self.platform in osx_platforms:
|
|
|
|
elif self.provider == 'parallels':
|
|
|
|
self.endpoints = self._get_parallels_endpoints()
|
|
|
|
self.endpoints = self._get_parallels_endpoints()
|
|
|
|
self.max_threshold = 6
|
|
|
|
self.max_threshold = 6
|
|
|
|
|
|
|
|
|
|
|
@ -106,7 +125,7 @@ class AnsibleCoreCI(object):
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
raise ApplicationError('Unsupported platform: %s' % platform)
|
|
|
|
raise ApplicationError('Unsupported platform: %s' % platform)
|
|
|
|
|
|
|
|
|
|
|
|
self.path = os.path.expanduser('~/.ansible/test/instances/%s-%s' % (self.name, self.stage))
|
|
|
|
self.path = os.path.expanduser('~/.ansible/test/instances/%s-%s-%s' % (self.name, self.provider, self.stage))
|
|
|
|
|
|
|
|
|
|
|
|
if persist and load and self._load():
|
|
|
|
if persist and load and self._load():
|
|
|
|
try:
|
|
|
|
try:
|
|
|
@ -292,7 +311,7 @@ class AnsibleCoreCI(object):
|
|
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
@property
|
|
|
|
def _uri(self):
|
|
|
|
def _uri(self):
|
|
|
|
return '%s/%s/jobs/%s' % (self.endpoint, self.stage, self.instance_id)
|
|
|
|
return '%s/%s/%s/%s' % (self.endpoint, self.stage, self.resource, self.instance_id)
|
|
|
|
|
|
|
|
|
|
|
|
def _start(self, auth):
|
|
|
|
def _start(self, auth):
|
|
|
|
"""Start instance."""
|
|
|
|
"""Start instance."""
|
|
|
|