Fixes and cleans up build/cache directory usage
[apex.git] / build / undercloud.sh
index d0bab52..5352ac7 100755 (executable)
@@ -7,22 +7,27 @@
 # which accompanies this distribution, and is available at
 # http://www.apache.org/licenses/LICENSE-2.0
 ##############################################################################
-set -e
+set -xe
 source ./cache.sh
 source ./variables.sh
 source ./functions.sh
 
 populate_cache "$rdo_images_uri/undercloud.qcow2"
-if [ ! -d images ]; then mkdir images/; fi
-cp -f cache/undercloud.qcow2 images/undercloud_build.qcow2
+if [ ! -d "$BUILD_DIR" ]; then mkdir ${BUILD_DIR}; fi
+cp -f ${CACHE_DIR}/undercloud.qcow2 ${BUILD_DIR}/undercloud_build.qcow2
+
+pushd ${BUILD_DIR} > /dev/null
 
 # prep opnfv-tht for undercloud
 clone_fork opnfv-tht
 pushd opnfv-tht > /dev/null
-git archive --format=tar.gz --prefix=openstack-tripleo-heat-templates/ HEAD > ../opnfv-tht.tar.gz
+git archive --format=tar.gz --prefix=openstack-tripleo-heat-templates/ HEAD > ${BUILD_DIR}/opnfv-tht.tar.gz
 popd > /dev/null
 
-pushd images > /dev/null
+# Add custom IPA to allow kernel params
+curl -fO https://raw.githubusercontent.com/trozet/ironic-python-agent/opnfv_kernel/ironic_python_agent/extensions/image.py
+python3 -c 'import py_compile; py_compile.compile("image.py", cfile="image.pyc")'
+
 # installing forked opnfv-tht
 # enabling ceph OSDs to live on the controller
 # OpenWSMan package update supports the AMT Ironic driver for the TealBox
@@ -31,10 +36,11 @@ pushd images > /dev/null
 # add congress password to python-tripleoclient
 # add tacker password to python-tripleoclient
 # upload tacker repo and install the client package
+# Add performance image scripts
 LIBGUESTFS_BACKEND=direct virt-customize \
     --run-command "sed -i 's/^#UseDNS.*$/UseDNS no/' /etc/ssh/sshd_config" \
     --run-command "sed -i 's/^GSSAPIAuthentication.*$/GSSAPIAuthentication no/' /etc/ssh/sshd_config" \
-    --upload ../opnfv-tht.tar.gz:/usr/share \
+    --upload ${BUILD_DIR}/opnfv-tht.tar.gz:/usr/share \
     --install "openstack-utils" \
     --install "ceph-common" \
     --run-command "cd /usr/share && rm -rf openstack-tripleo-heat-templates && tar xzf opnfv-tht.tar.gz" \
@@ -43,8 +49,8 @@ LIBGUESTFS_BACKEND=direct virt-customize \
     --run-command "curl -f http://download.opensuse.org/repositories/Openwsman/CentOS_CentOS-7/Openwsman.repo > /etc/yum.repos.d/wsman.repo" \
     --run-command "yum update -y openwsman*" \
     --run-command "cp /usr/share/instack-undercloud/undercloud.conf.sample /home/stack/undercloud.conf && chown stack:stack /home/stack/undercloud.conf" \
-    --upload ../opnfv-environment.yaml:/home/stack/ \
-    --upload ../virtual-environment.yaml:/home/stack/ \
+    --upload ${BUILD_ROOT}/opnfv-environment.yaml:/home/stack/ \
+    --upload ${BUILD_ROOT}/virtual-environment.yaml:/home/stack/ \
     --install "python2-congressclient" \
     --run-command "sed -i '/SERVICE_LIST/a\\    \x27congress\x27: {\x27password_field\x27: \x27OVERCLOUD_CONGRESS_PASSWORD\x27},' /usr/lib/python2.7/site-packages/tripleoclient/constants.py" \
     --run-command "sed -i '/PASSWORD_NAMES =/a\\    \"OVERCLOUD_CONGRESS_PASSWORD\",' /usr/lib/python2.7/site-packages/tripleoclient/utils.py" \
@@ -54,24 +60,17 @@ LIBGUESTFS_BACKEND=direct virt-customize \
     --run-command "sed -i '/PASSWORD_NAMES =/a\\    \"OVERCLOUD_TACKER_PASSWORD\",' /usr/lib/python2.7/site-packages/tripleoclient/utils.py" \
     --run-command "sed -i '/AodhPassword/a\\        parameters\[\x27TackerPassword\x27\] = passwords\[\x27OVERCLOUD_TACKER_PASSWORD\x27\]' /usr/lib/python2.7/site-packages/tripleoclient/v1/overcloud_deploy.py" \
     --run-command "sed -i '/^SERVICES/a\    \x27tacker\x27: {\x27description\x27: \x27Tacker Service\x27, \x27type\x27: \x27servicevm\x27, \x27path\x27: \x27/\x27, \x27port\x27: 8888 },' /usr/lib/python2.7/site-packages/os_cloud_config/keystone.py" \
-    --upload ../noarch/$tackerclient_pkg:/root/ \
+    --upload ${BUILD_DIR}/noarch/$tackerclient_pkg:/root/ \
     --install /root/$tackerclient_pkg \
     --install "python2-aodhclient" \
     --install "openstack-heat-engine" \
     --install "openstack-heat-api-cfn" \
     --install "openstack-heat-api" \
+    --upload ${BUILD_ROOT}/build_perf_image.sh:/home/stack \
+    --upload ${BUILD_ROOT}/set_perf_images.sh:/home/stack \
+    --upload ${BUILD_DIR}/image.py:/root \
+    --upload ${BUILD_DIR}/image.pyc:/root \
     -a undercloud_build.qcow2
 
-# Add custom IPA to allow kernel params
-curl -fO https://raw.githubusercontent.com/trozet/ironic-python-agent/opnfv_kernel/ironic_python_agent/extensions/image.py
-python3 -c 'import py_compile; py_compile.compile("image.py", cfile="image.pyc")'
-
-# Add performance image scripts
-LIBGUESTFS_BACKEND=direct virt-customize --upload ../build_perf_image.sh:/home/stack \
-                                         --upload ../set_perf_images.sh:/home/stack \
-                                         --upload image.py:/root \
-                                         --upload image.pyc:/root \
-                                         -a undercloud_build.qcow2
-
 mv -f undercloud_build.qcow2 undercloud.qcow2
 popd > /dev/null