#!/bin/bash # # Copyright 2015 Hewlett-Packard Development Company, L.P. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. NODEPOOL_PUBKEY=$HOME/.ssh/id_nodepool.pub NODEPOOL_INSTALL=$HOME/nodepool-venv NODEPOOL_CACHE_GET_PIP=/opt/stack/cache/files/get-pip.py # Install shade from git if requested. If not requested # nodepool install will pull it in. function install_shade { if use_library_from_git "shade"; then GITREPO["shade"]=$SHADE_REPO_URL GITDIR["shade"]=$DEST/shade GITBRANCH["shade"]=$SHADE_REPO_REF git_clone_by_name "shade" # Install shade globally, because the job config has LIBS_FROM_GIT # and if we don't install it globally, all hell breaks loose setup_dev_lib "shade" # BUT - install shade into a virtualenv so that we don't have issues # with OpenStack constraints affecting the shade dependency install. # This particularly shows up with os-client-config $NODEPOOL_INSTALL/bin/pip install $DEST/shade fi } function install_diskimage_builder { if use_library_from_git "diskimage-builder"; then GITREPO["diskimage-builder"]=$DISKIMAGE_BUILDER_REPO_URL GITDIR["diskimage-builder"]=$DEST/diskimage-builder GITBRANCH["diskimage-builder"]=$DISKIMAGE_BUILDER_REPO_REF git_clone_by_name "diskimage-builder" setup_dev_lib "diskimage-builder" $NODEPOOL_INSTALL/bin/pip install $DEST/diskimage-builder fi } function install_glean { if use_library_from_git "glean"; then GITREPO["glean"]=$GLEAN_REPO_URL GITDIR["glean"]=$DEST/glean GITBRANCH["glean"]=$GLEAN_REPO_REF git_clone_by_name "glean" setup_dev_lib "glean" $NODEPOOL_INSTALL/bin/pip install $DEST/glean fi } # Install nodepool code function install_nodepool { if python3_enabled; then VENV="virtualenv -p python${PYTHON3_VERSION}" else VENV="virtualenv -p python${PYTHON2_VERSION}" fi $VENV $NODEPOOL_INSTALL install_shade install_diskimage_builder install_glean setup_develop $DEST/nodepool $NODEPOOL_INSTALL/bin/pip install $DEST/nodepool } # requires some globals from devstack, which *might* not be stable api # points. If things break, investigate changes in those globals first. function nodepool_write_elements { sudo mkdir -p $(dirname $NODEPOOL_CONFIG)/elements/nodepool-setup/install.d sudo mkdir -p $(dirname $NODEPOOL_CONFIG)/elements/nodepool-setup/root.d cat > /tmp/01-nodepool-setup < /tmp/50-apt-allow-unauthenticated < /tmp/logging.conf < /tmp/secure.conf << EOF # Empty EOF sudo mv /tmp/secure.conf $NODEPOOL_SECURE if use_library_from_git "glean"; then git --git-dir=$DEST/glean/.git checkout -b devstack DIB_GLEAN_INSTALLTYPE="DIB_INSTALLTYPE_simple_init: 'repo'" DIB_GLEAN_REPOLOCATION="DIB_REPOLOCATION_glean: '$DEST/glean'" DIB_GLEAN_REPOREF="DIB_REPOREF_glean: 'devstack'" fi if [ -f $NODEPOOL_CACHE_GET_PIP ] ; then DIB_GET_PIP="DIB_REPOLOCATION_pip_and_virtualenv: file://$NODEPOOL_CACHE_GET_PIP" fi if [ -f /etc/nodepool/provider ] ; then source /etc/nodepool/provider NODEPOOL_MIRROR_HOST=${NODEPOOL_MIRROR_HOST:-mirror.$NODEPOOL_REGION.$NODEPOOL_CLOUD.openstack.org} NODEPOOL_MIRROR_HOST=$(echo $NODEPOOL_MIRROR_HOST|tr '[:upper:]' '[:lower:]') NODEPOOL_CENTOS_MIRROR=${NODEPOOL_CENTOS_MIRROR:-http://$NODEPOOL_MIRROR_HOST/centos} NODEPOOL_DEBIAN_MIRROR=${NODEPOOL_DEBIAN_MIRROR:-http://$NODEPOOL_MIRROR_HOST/debian} NODEPOOL_UBUNTU_MIRROR=${NODEPOOL_UBUNTU_MIRROR:-http://$NODEPOOL_MIRROR_HOST/ubuntu} DIB_DISTRIBUTION_MIRROR_CENTOS="DIB_DISTRIBUTION_MIRROR: $NODEPOOL_CENTOS_MIRROR" DIB_DISTRIBUTION_MIRROR_DEBIAN="DIB_DISTRIBUTION_MIRROR: $NODEPOOL_DEBIAN_MIRROR" DIB_DISTRIBUTION_MIRROR_UBUNTU="DIB_DISTRIBUTION_MIRROR: $NODEPOOL_UBUNTU_MIRROR" DIB_DEBOOTSTRAP_EXTRA_ARGS="DIB_DEBOOTSTRAP_EXTRA_ARGS: '--no-check-gpg'" fi NODEPOOL_CENTOS_7_MIN_READY=1 NODEPOOL_DEBIAN_JESSIE_MIN_READY=1 NODEPOOL_FEDORA_25_MIN_READY=1 NODEPOOL_UBUNTU_TRUSTY_MIN_READY=1 NODEPOOL_UBUNTU_XENIAL_MIN_READY=1 if $NODEPOOL_PAUSE_CENTOS_7_DIB ; then NODEPOOL_CENTOS_7_MIN_READY=0 fi if $NODEPOOL_PAUSE_DEBIAN_JESSIE_DIB ; then NODEPOOL_DEBIAN_JESSIE_MIN_READY=0 fi if $NODEPOOL_PAUSE_FEDORA_25_DIB ; then NODEPOOL_FEDORA_25_MIN_READY=0 fi if $NODEPOOL_PAUSE_UBUNTU_TRUSTY_DIB ; then NODEPOOL_UBUNTU_TRUSTY_MIN_READY=0 fi if $NODEPOOL_PAUSE_UBUNTU_XENIAL_DIB ; then NODEPOOL_UBUNTU_XENIAL_MIN_READY=0 fi cat > /tmp/nodepool.yaml <>/tmp/clouds.yaml <