#!/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_KEY=$HOME/.ssh/id_nodepool 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 -e $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 -e $DEST/diskimage-builder fi } # Install nodepool code function install_nodepool { virtualenv $NODEPOOL_INSTALL install_shade install_diskimage_builder setup_develop $DEST/nodepool $NODEPOOL_INSTALL/bin/pip install -e $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_create_keypairs { if [[ ! -f $NODEPOOL_KEY ]]; then ssh-keygen -f $NODEPOOL_KEY -P "" fi } function nodepool_write_prepare { sudo mkdir -p $(dirname $NODEPOOL_CONFIG)/scripts local pub_key=$(cat $NODEPOOL_PUBKEY) cat > /tmp/prepare_node_ubuntu.sh < tmp_authorized_keys << INNEREOF $pub_key INNEREOF sudo mv tmp_authorized_keys /home/jenkins/.ssh/authorized_keys sudo chmod 700 /home/jenkins/.ssh sudo chmod 600 /home/jenkins/.ssh/authorized_keys sudo chown -R jenkins:jenkins /home/jenkins sleep 5 sync EOF sudo mv /tmp/prepare_node_ubuntu.sh \ $(dirname $NODEPOOL_CONFIG)/scripts/prepare_node_ubuntu.sh sudo chmod a+x $(dirname $NODEPOOL_CONFIG)/scripts/prepare_node_ubuntu.sh sudo mkdir -p $(dirname $NODEPOOL_CONFIG)/elements/nodepool-setup/install.d cat > /tmp/01-nodepool-setup < /tmp/logging.conf < /tmp/secure.conf << EOF [database] # The mysql password here may be different depending on your # devstack install, you should double check it (the devstack var # is MYSQL_PASSWORD and if unset devstack should prompt you for # the value). dburi: $dburi EOF sudo mv /tmp/secure.conf $NODEPOOL_SECURE cat > /tmp/nodepool.yaml <> /tmp/nodepool.yaml <>/tmp/clouds.yaml <