summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apex/common/utils.py10
-rw-r--r--apex/deploy.py9
-rw-r--r--apex/overcloud/deploy.py15
-rw-r--r--apex/tests/test_apex_overcloud_deploy.py17
-rw-r--r--apex/tests/test_apex_undercloud.py15
-rw-r--r--apex/undercloud/undercloud.py23
-rw-r--r--config/network/network_settings.yaml4
-rw-r--r--config/network/network_settings_v6.yaml4
-rw-r--r--config/network/network_settings_vlans.yaml4
-rw-r--r--config/network/network_settings_vpp.yaml4
-rw-r--r--lib/ansible/playbooks/configure_undercloud.yml12
11 files changed, 106 insertions, 11 deletions
diff --git a/apex/common/utils.py b/apex/common/utils.py
index 0328a3b5..b727b11a 100644
--- a/apex/common/utils.py
+++ b/apex/common/utils.py
@@ -13,6 +13,7 @@ import json
import logging
import os
import pprint
+import socket
import subprocess
import tarfile
import time
@@ -210,3 +211,12 @@ def install_ansible():
subprocess.check_call([pkg_mgr, '-y', 'install', 'ansible'])
except subprocess.CalledProcessError:
logging.warning('Unable to install Ansible')
+
+
+def internet_connectivity():
+ try:
+ urllib.request.urlopen('http://opnfv.org', timeout=3)
+ return True
+ except (urllib.request.URLError, socket.timeout):
+ logging.debug('No internet connectivity detected')
+ return False
diff --git a/apex/deploy.py b/apex/deploy.py
index 5171c5cd..5703e081 100644
--- a/apex/deploy.py
+++ b/apex/deploy.py
@@ -382,7 +382,8 @@ def main():
args.deploy_dir,
root_pw=root_pw,
external_network=uc_external,
- image_name=os.path.basename(uc_image))
+ image_name=os.path.basename(uc_image),
+ os_version=os_version)
undercloud.start()
# Generate nic templates
@@ -411,8 +412,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 +450,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 19d46e15..5bbcaede 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 8ff98a8d..420a70d6 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/tests/test_apex_undercloud.py b/apex/tests/test_apex_undercloud.py
index c821ade5..0df785f9 100644
--- a/apex/tests/test_apex_undercloud.py
+++ b/apex/tests/test_apex_undercloud.py
@@ -197,3 +197,18 @@ class TestUndercloud(unittest.TestCase):
ds = {'global_params': {}}
Undercloud('img_path', 'tplt_path').generate_config(ns, ds)
+
+ @patch.object(Undercloud, '_get_vm', return_value=None)
+ @patch.object(Undercloud, 'create')
+ @patch('apex.undercloud.undercloud.virt_utils')
+ def test_update_delorean(self, mock_vutils, mock_uc_create, mock_get_vm):
+ uc = Undercloud('img_path', 'tmplt_path', external_network=True)
+ uc._update_delorean_repo()
+ download_cmd = (
+ "curl -L -f -o "
+ "/etc/yum.repos.d/deloran.repo "
+ "https://trunk.rdoproject.org/centos7-{}"
+ "/current-tripleo/delorean.repo".format(
+ constants.DEFAULT_OS_VERSION))
+ test_ops = {'--run-command': download_cmd}
+ mock_vutils.virt_customize.assert_called_with(test_ops, uc.volume)
diff --git a/apex/undercloud/undercloud.py b/apex/undercloud/undercloud.py
index d28ed981..a70c465a 100644
--- a/apex/undercloud/undercloud.py
+++ b/apex/undercloud/undercloud.py
@@ -31,8 +31,10 @@ class Undercloud:
"""
def __init__(self, image_path, template_path,
root_pw=None, external_network=False,
- image_name='undercloud.qcow2'):
+ image_name='undercloud.qcow2',
+ os_version=constants.DEFAULT_OS_VERSION):
self.ip = None
+ self.os_version = os_version
self.root_pw = root_pw
self.external_net = external_network
self.volume = os.path.join(constants.LIBVIRT_VOLUME_PATH,
@@ -73,6 +75,7 @@ class Undercloud:
template_dir=self.template_path)
self.setup_volumes()
self.inject_auth()
+ self._update_delorean_repo()
def _set_ip(self):
ip_out = self.vm.interfaceAddresses(
@@ -236,4 +239,22 @@ class Undercloud:
"enabled": ns_external['enabled']
}
+ config['http_proxy'] = ns.get('http_proxy', '')
+ config['https_proxy'] = ns.get('https_proxy', '')
+
return config
+
+ def _update_delorean_repo(self):
+ if utils.internet_connectivity():
+ logging.info('Updating delorean repo on Undercloud')
+ delorean_repo = (
+ "https://trunk.rdoproject.org/centos7-{}"
+ "/current-tripleo/delorean.repo".format(self.os_version))
+ cmd = ("curl -L -f -o "
+ "/etc/yum.repos.d/deloran.repo {}".format(delorean_repo))
+ try:
+ virt_utils.virt_customize({constants.VIRT_RUN_CMD: cmd},
+ self.volume)
+ except Exception:
+ logging.warning("Failed to download and update delorean repo "
+ "for Undercloud")
diff --git a/config/network/network_settings.yaml b/config/network/network_settings.yaml
index fe11a9b5..ffe3a18e 100644
--- a/config/network/network_settings.yaml
+++ b/config/network/network_settings.yaml
@@ -57,6 +57,10 @@ syslog:
server: 10.128.1.24
transport: 'tcp'
+# http(s) proxy settings added to /etc/environment of uc and oc nodes
+# http_proxy: http://proxy.server:8080
+# https_proxy: https://proxy.server:8081
+
# Common network settings
networks:
# Admin configuration (pxe and jumpstart)
diff --git a/config/network/network_settings_v6.yaml b/config/network/network_settings_v6.yaml
index 7dddf343..176bc7ca 100644
--- a/config/network/network_settings_v6.yaml
+++ b/config/network/network_settings_v6.yaml
@@ -57,6 +57,10 @@ syslog:
server: 10.128.1.24
transport: 'tcp'
+# http(s) proxy settings added to /etc/environment of uc and oc nodes
+# http_proxy: http://proxy.server:8080
+# https_proxy: https://proxy.server:8081
+
# Common network settings
networks:
# Admin configuration (pxe and jumpstart)
diff --git a/config/network/network_settings_vlans.yaml b/config/network/network_settings_vlans.yaml
index 345dbbde..29cd193d 100644
--- a/config/network/network_settings_vlans.yaml
+++ b/config/network/network_settings_vlans.yaml
@@ -57,6 +57,10 @@ syslog:
server: 10.128.1.24
transport: 'tcp'
+# http(s) proxy settings added to /etc/environment of uc and oc nodes
+# http_proxy: http://proxy.server:8080
+# https_proxy: https://proxy.server:8081
+
# Common network settings
networks:
# Admin configuration (pxe and jumpstart)
diff --git a/config/network/network_settings_vpp.yaml b/config/network/network_settings_vpp.yaml
index 2f6bba5e..a40158ea 100644
--- a/config/network/network_settings_vpp.yaml
+++ b/config/network/network_settings_vpp.yaml
@@ -57,6 +57,10 @@ syslog:
server: 10.128.1.24
transport: 'tcp'
+# http(s) proxy settings added to /etc/environment of uc and oc nodes
+# http_proxy: http://proxy.server:8080
+# https_proxy: https://proxy.server:8081
+
# Common network settings
networks:
# Admin configuration (pxe and jumpstart)
diff --git a/lib/ansible/playbooks/configure_undercloud.yml b/lib/ansible/playbooks/configure_undercloud.yml
index 60afca9d..e9ce8754 100644
--- a/lib/ansible/playbooks/configure_undercloud.yml
+++ b/lib/ansible/playbooks/configure_undercloud.yml
@@ -32,6 +32,18 @@
regexp: 'Defaults\s*requiretty'
state: absent
become: yes
+ - lineinfile:
+ path: /etc/environment
+ regexp: '^http_proxy'
+ line: "http_proxy={{ http_proxy }}"
+ become: yes
+ when: http_proxy
+ - lineinfile:
+ path: /etc/environment
+ regexp: '^https_proxy'
+ line: "https_proxy={{ https_proxy }}"
+ become: yes
+ when: https_proxy
- name: openstack-configs undercloud
shell: openstack-config --set undercloud.conf DEFAULT {{ item }}
with_items: "{{ undercloud_config }}"