ansible-test: vcenter through a HTTP proxy
Give the ansible-test user the ability to target a lab behind a HTTP proxy.
This commit is contained in:
parent
617972499f
commit
31baab85f9
2 changed files with 11 additions and 2 deletions
|
@ -63,6 +63,7 @@ class VcenterProvider(CloudProvider):
|
||||||
self.endpoint = ''
|
self.endpoint = ''
|
||||||
self.hostname = ''
|
self.hostname = ''
|
||||||
self.port = 443
|
self.port = 443
|
||||||
|
self.proxy = None
|
||||||
|
|
||||||
def filter(self, targets, exclude):
|
def filter(self, targets, exclude):
|
||||||
"""Filter out the cloud tests when the necessary config and resources are not available.
|
"""Filter out the cloud tests when the necessary config and resources are not available.
|
||||||
|
@ -222,6 +223,10 @@ class VcenterProvider(CloudProvider):
|
||||||
|
|
||||||
if parser.get('DEFAULT', 'vmware_validate_certs').lower() in ('no', 'false'):
|
if parser.get('DEFAULT', 'vmware_validate_certs').lower() in ('no', 'false'):
|
||||||
self.insecure = True
|
self.insecure = True
|
||||||
|
proxy_host = parser.get('DEFAULT', 'vmware_proxy_host')
|
||||||
|
proxy_port = int(parser.get('DEFAULT', 'vmware_proxy_port'))
|
||||||
|
if proxy_host and proxy_port:
|
||||||
|
self.proxy = 'http://%s:%d' % (proxy_host, proxy_port)
|
||||||
|
|
||||||
self._wait_for_service()
|
self._wait_for_service()
|
||||||
|
|
||||||
|
@ -230,7 +235,7 @@ class VcenterProvider(CloudProvider):
|
||||||
if self.args.explain:
|
if self.args.explain:
|
||||||
return
|
return
|
||||||
|
|
||||||
client = HttpClient(self.args, always=True, insecure=self.insecure)
|
client = HttpClient(self.args, always=True, insecure=self.insecure, proxy=self.proxy)
|
||||||
endpoint = 'https://%s:%s' % (self.endpoint, self.port)
|
endpoint = 'https://%s:%s' % (self.endpoint, self.port)
|
||||||
|
|
||||||
for i in range(1, 30):
|
for i in range(1, 30):
|
||||||
|
|
|
@ -35,7 +35,7 @@ from lib.util_common import (
|
||||||
|
|
||||||
class HttpClient(object):
|
class HttpClient(object):
|
||||||
"""Make HTTP requests via curl."""
|
"""Make HTTP requests via curl."""
|
||||||
def __init__(self, args, always=False, insecure=False):
|
def __init__(self, args, always=False, insecure=False, proxy=None):
|
||||||
"""
|
"""
|
||||||
:type args: CommonConfig
|
:type args: CommonConfig
|
||||||
:type always: bool
|
:type always: bool
|
||||||
|
@ -44,6 +44,7 @@ class HttpClient(object):
|
||||||
self.args = args
|
self.args = args
|
||||||
self.always = always
|
self.always = always
|
||||||
self.insecure = insecure
|
self.insecure = insecure
|
||||||
|
self.proxy = proxy
|
||||||
|
|
||||||
self.username = None
|
self.username = None
|
||||||
self.password = None
|
self.password = None
|
||||||
|
@ -102,6 +103,9 @@ class HttpClient(object):
|
||||||
if data is not None:
|
if data is not None:
|
||||||
cmd += ['-d', data]
|
cmd += ['-d', data]
|
||||||
|
|
||||||
|
if self.proxy:
|
||||||
|
cmd += ['-x', self.proxy]
|
||||||
|
|
||||||
cmd += [url]
|
cmd += [url]
|
||||||
|
|
||||||
attempts = 0
|
attempts = 0
|
||||||
|
|
Loading…
Reference in a new issue