Drop OS_ prefix from OS_TEST_HTTP_PROXY

As part of this change also switch to using deployment_env.
This commit is contained in:
Corey Bryant
2020-06-12 01:58:10 +00:00
parent 5a94e4a52d
commit de893b66b8
2 changed files with 11 additions and 7 deletions
@@ -293,8 +293,9 @@ class TestOpenStackUtils(ut_utils.BaseTestCase):
self.patch_object(openstack_utils.urllib.request, "ProxyHandler")
self.patch_object(openstack_utils.urllib.request, "HTTPHandler")
self.patch_object(openstack_utils.urllib.request, "build_opener")
self.patch_object(openstack_utils.os, "getenv")
self.getenv.return_value = None
self.patch_object(openstack_utils.deployment_env,
"get_deployment_context",
return_value=dict(TEST_HTTP_PROXY=None))
HTTPHandler_mock = mock.MagicMock()
self.HTTPHandler.return_value = HTTPHandler_mock
openstack_utils.get_urllib_opener()
@@ -305,8 +306,9 @@ class TestOpenStackUtils(ut_utils.BaseTestCase):
self.patch_object(openstack_utils.urllib.request, "ProxyHandler")
self.patch_object(openstack_utils.urllib.request, "HTTPHandler")
self.patch_object(openstack_utils.urllib.request, "build_opener")
self.patch_object(openstack_utils.os, "getenv")
self.getenv.return_value = 'http://squidy'
self.patch_object(openstack_utils.deployment_env,
"get_deployment_context",
return_value=dict(TEST_HTTP_PROXY='http://squidy'))
ProxyHandler_mock = mock.MagicMock()
self.ProxyHandler.return_value = ProxyHandler_mock
openstack_utils.get_urllib_opener()
+5 -3
View File
@@ -39,6 +39,7 @@ from keystoneauth1.identity import (
v2,
)
import zaza.openstack.utilities.cert as cert
import zaza.utilities.deployment_env as deployment_env
from novaclient import client as novaclient_client
from neutronclient.v2_0 import client as neutronclient
from neutronclient.common import exceptions as neutronexceptions
@@ -1749,14 +1750,15 @@ def get_urllib_opener():
Using urllib.request.urlopen will automatically handle proxies so none
of this function is needed except we are currently specifying proxies
via OS_TEST_HTTP_PROXY rather than http_proxy so a ProxyHandler is needed
via TEST_HTTP_PROXY rather than http_proxy so a ProxyHandler is needed
explicitly stating the proxies.
:returns: An opener which opens URLs via BaseHandlers chained together
:rtype: urllib.request.OpenerDirector
"""
http_proxy = os.getenv('OS_TEST_HTTP_PROXY')
logging.debug('OS_TEST_HTTP_PROXY: {}'.format(http_proxy))
deploy_env = deployment_env.get_deployment_context()
http_proxy = deploy_env.get('TEST_HTTP_PROXY')
logging.debug('TEST_HTTP_PROXY: {}'.format(http_proxy))
if http_proxy:
handler = urllib.request.ProxyHandler({'http': http_proxy})