summaryrefslogtreecommitdiffstats
path: root/apex
diff options
context:
space:
mode:
authorDan Radez <dradez@redhat.com>2017-12-05 16:33:13 -0500
committerDan Radez <dradez@redhat.com>2018-02-16 12:29:56 -0500
commit5443898e7a1927d8e3cd35e70e3872ed5d9a6d97 (patch)
tree6c1bd62f6e44738ac13c40c69d9ddfbbf957192d /apex
parentd75cbb74191e32e3ff996604e30a2954d889687b (diff)
Add http(s)_proxy handling to apex
JIRA: APEX-512 Change-Id: I875bd99203b425e448e7a3f64eb9a8f99d03ddaf Signed-off-by: Dan Radez <dradez@redhat.com>
Diffstat (limited to 'apex')
-rw-r--r--apex/deploy.py6
-rw-r--r--apex/overcloud/deploy.py15
-rw-r--r--apex/tests/test_apex_overcloud_deploy.py17
-rw-r--r--apex/undercloud/undercloud.py3
4 files changed, 32 insertions, 9 deletions
diff --git a/apex/deploy.py b/apex/deploy.py
index 5171c5c..fe25634 100644
--- a/apex/deploy.py
+++ b/apex/deploy.py
@@ -411,8 +411,8 @@ def main():
if not upstream:
oc_deploy.prep_env(deploy_settings, net_settings, inventory,
opnfv_env, net_env_target, APEX_TEMP_DIR)
- oc_deploy.prep_image(deploy_settings, sdn_image, APEX_TEMP_DIR,
- root_pw=root_pw)
+ oc_deploy.prep_image(deploy_settings, net_settings, sdn_image,
+ APEX_TEMP_DIR, root_pw=root_pw)
else:
shutil.copyfile(sdn_image, os.path.join(APEX_TEMP_DIR,
'overcloud-full.qcow2'))
@@ -449,6 +449,8 @@ def main():
deploy_vars['overcloudrc'] = 'source /home/stack/overcloudrc'
deploy_vars['upstream'] = upstream
deploy_vars['os_version'] = os_version
+ deploy_vars['http_proxy'] = net_settings.get('http_proxy', '')
+ deploy_vars['https_proxy'] = net_settings.get('https_proxy', '')
for dns_server in net_settings['dns_servers']:
deploy_vars['dns_server_args'] += " --dns-nameserver {}".format(
dns_server)
diff --git a/apex/overcloud/deploy.py b/apex/overcloud/deploy.py
index 19d46e1..5bbcaed 100644
--- a/apex/overcloud/deploy.py
+++ b/apex/overcloud/deploy.py
@@ -186,10 +186,11 @@ def create_deploy_cmd(ds, ns, inv, tmp_dir,
return cmd
-def prep_image(ds, img, tmp_dir, root_pw=None):
+def prep_image(ds, ns, img, tmp_dir, root_pw=None):
"""
Locates sdn image and preps for deployment.
:param ds: deploy settings
+ :param ns: network settings
:param img: sdn image
:param tmp_dir: dir to store modified sdn image
:param root_pw: password to configure for overcloud image
@@ -219,6 +220,18 @@ def prep_image(ds, img, tmp_dir, root_pw=None):
".service"
}])
+ if ns.get('http_proxy', ''):
+ virt_cmds.append({
+ con.VIRT_RUN_CMD:
+ "echo 'http_proxy={}' >> /etc/environment".format(
+ ns['http_proxy'])})
+
+ if ns.get('https_proxy', ''):
+ virt_cmds.append({
+ con.VIRT_RUN_CMD:
+ "echo 'https_proxy={}' >> /etc/environment".format(
+ ns['https_proxy'])})
+
if ds_opts['vpn']:
virt_cmds.append({con.VIRT_RUN_CMD: "chmod +x /etc/rc.d/rc.local"})
virt_cmds.append({
diff --git a/apex/tests/test_apex_overcloud_deploy.py b/apex/tests/test_apex_overcloud_deploy.py
index 8ff98a8..420a70d 100644
--- a/apex/tests/test_apex_overcloud_deploy.py
+++ b/apex/tests/test_apex_overcloud_deploy.py
@@ -154,7 +154,8 @@ class TestOvercloudDeploy(unittest.TestCase):
'global_params': MagicMock()}
ds['deploy_options'].__getitem__.side_effect = \
lambda i: ds_opts.get(i, MagicMock())
- prep_image(ds, 'undercloud.qcow2', '/tmp', root_pw='test')
+ ns = MagicMock()
+ prep_image(ds, ns, 'undercloud.qcow2', '/tmp', root_pw='test')
mock_virt_utils.virt_customize.assert_called()
@patch('apex.overcloud.deploy.virt_utils')
@@ -169,7 +170,8 @@ class TestOvercloudDeploy(unittest.TestCase):
'global_params': MagicMock()}
ds['deploy_options'].__getitem__.side_effect = \
lambda i: ds_opts.get(i, MagicMock())
- prep_image(ds, 'undercloud.qcow2', '/tmp', root_pw='test')
+ ns = MagicMock()
+ prep_image(ds, ns, 'undercloud.qcow2', '/tmp', root_pw='test')
mock_virt_utils.virt_customize.assert_called()
@patch('apex.overcloud.deploy.virt_utils')
@@ -188,7 +190,8 @@ class TestOvercloudDeploy(unittest.TestCase):
lambda i: ds_opts.get(i, MagicMock())
ds['deploy_options'].__contains__.side_effect = \
lambda i: True if i in ds_opts else MagicMock()
- prep_image(ds, 'undercloud.qcow2', '/tmp', root_pw='test')
+ ns = MagicMock()
+ prep_image(ds, ns, 'undercloud.qcow2', '/tmp', root_pw='test')
mock_virt_utils.virt_customize.assert_called()
@patch('apex.overcloud.deploy.virt_utils')
@@ -204,7 +207,8 @@ class TestOvercloudDeploy(unittest.TestCase):
'global_params': MagicMock()}
ds['deploy_options'].__getitem__.side_effect = \
lambda i: ds_opts.get(i, MagicMock())
- prep_image(ds, 'undercloud.qcow2', '/tmp', root_pw='test')
+ ns = MagicMock()
+ prep_image(ds, ns, 'undercloud.qcow2', '/tmp', root_pw='test')
mock_virt_utils.virt_customize.assert_called()
@patch('apex.overcloud.deploy.virt_utils')
@@ -219,14 +223,15 @@ class TestOvercloudDeploy(unittest.TestCase):
'global_params': MagicMock()}
ds['deploy_options'].__getitem__.side_effect = \
lambda i: ds_opts.get(i, MagicMock())
- prep_image(ds, 'undercloud.qcow2', '/tmp', root_pw='test')
+ ns = MagicMock()
+ prep_image(ds, ns, 'undercloud.qcow2', '/tmp', root_pw='test')
mock_virt_utils.virt_customize.assert_called()
@patch('apex.overcloud.deploy.os.path.isfile')
def test_prep_image_no_image(self, mock_isfile):
mock_isfile.return_value = False
assert_raises(ApexDeployException, prep_image,
- {}, 'undercloud.qcow2', '/tmp')
+ {}, {}, 'undercloud.qcow2', '/tmp')
def test_make_ssh_key(self):
priv, pub = make_ssh_key()
diff --git a/apex/undercloud/undercloud.py b/apex/undercloud/undercloud.py
index d28ed98..63f9183 100644
--- a/apex/undercloud/undercloud.py
+++ b/apex/undercloud/undercloud.py
@@ -236,4 +236,7 @@ class Undercloud:
"enabled": ns_external['enabled']
}
+ config['http_proxy'] = ns.get('http_proxy', '')
+ config['https_proxy'] = ns.get('https_proxy', '')
+
return config