82 lines
2.9 KiB
Bash
Executable File
82 lines
2.9 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
set -x
|
|
set -u
|
|
|
|
# This is a simple script to automate the deploy of the plugin used
|
|
# for testing until we have a full CI
|
|
|
|
# Run it on the master node after copying the plugin into this
|
|
# directory
|
|
|
|
# This is a work in progress
|
|
|
|
MASTER_IP="10.20.0.2"
|
|
MASTER_ADDR="http://10.20.0.2:8000"
|
|
MASTER_USER="admin"
|
|
MASTER_PASS="admin"
|
|
MASTER_SSH_USER="root"
|
|
MASTER_SSH_PASS="r00tme"
|
|
# 1 means redhat (usually)!
|
|
# 2 means ubuntu (usually)!
|
|
RELEASE_ID="2"
|
|
# keep in sync with release id!
|
|
RELEASE_NAME="ubuntu"
|
|
|
|
# scp fuel-plugin-calamari-*.noarch.rpm ${MASTER_IP}:
|
|
# ssh ${MASTER_SSH_USER}@${MASTER_IP}:
|
|
|
|
fuel plugins --install fuel-plugin-calamari-*.noarch.rpm
|
|
|
|
# Create a new env
|
|
# rel 2 means ubuntu (usually)!
|
|
fuel env create --name test1 --rel ${RELEASE_ID} --mode ha --net neutron --nst gre
|
|
|
|
# Get the new (the last) env id
|
|
FUEL_ENV=`fuel env | sed -ne '3,$p' | cut -d '|' -f 1 | sort -rn | head -n1 | tr -d ' '`
|
|
|
|
# Get the first node (we assume all nodes are for ours and unallocated)
|
|
FIRST_NODE=`fuel node | sed -ne '3,$p' | cut -d '|' -f 1 | sort -n | head -n1 | tr -d ' '`
|
|
|
|
# Get the CALAMARI_PLUGIN_ID, for settings workaround
|
|
CALAMARI_PLUGIN_ID=`fuel plugins | sed -ne '3,$p' | grep fuel-plugin-calamari | cut -d '|' -f 1 | sort -n | head -n1 | tr -d ' '`
|
|
|
|
# Upload network settings
|
|
if [ -e 'network_default.yaml' ]
|
|
then
|
|
cp network_default.yaml network_${FUEL_ENV}.yaml
|
|
fuel --env $FUEL_ENV network upload
|
|
rm network_${FUEL_ENV}.yaml
|
|
fi
|
|
|
|
# Copy the default settings for the env with proper plugin id assuming
|
|
# that calamari is the only plugin enabled here!
|
|
sed -e "s/plugin_id:.*/plugin_id: $CALAMARI_PLUGIN_ID/" < settings_default_${RELEASE_NAME}.yaml > settings_${FUEL_ENV}.yaml
|
|
|
|
# Upload the settings
|
|
fuel --env $FUEL_ENV settings upload
|
|
|
|
# Remove the temp file for the env
|
|
rm settings_${FUEL_ENV}.yaml
|
|
|
|
# Add the nodes
|
|
fuel node set --env $FUEL_ENV --node $FIRST_NODE --role controller
|
|
fuel node set --env $FUEL_ENV --node $(($FIRST_NODE + 1)) --role compute,ceph-osd
|
|
fuel node set --env $FUEL_ENV --node $(($FIRST_NODE + 2)) --role compute,ceph-osd
|
|
fuel node set --env $FUEL_ENV --node $(($FIRST_NODE + 3)) --role base-os
|
|
|
|
# Workaround for setting the base-os name to calamari (there is no api yet)
|
|
AUTH=`curl -s -H "Content-Type: application/json" -X POST -d '{"auth":{"passwordCredentials":{"username":"admin","password":"admin"},"tenantName":"admin"}}' ${MASTER_ADDR}/keystone/v2.0/tokens | python -c 'import sys, json; j=json.load(sys.stdin); print j["access"]["token"]["id"]'`
|
|
|
|
curl -s -H "X-Auth-Token: $AUTH" -X PUT -d '{"name":"calamari"}' ${MASTER_ADDR}/api/nodes/$(($FIRST_NODE + 3))
|
|
|
|
# Node provisioning
|
|
fuel --env $FUEL_ENV node --provision --node $FIRST_NODE,$(($FIRST_NODE + 1)),$(($FIRST_NODE + 2)),$(($FIRST_NODE + 3))
|
|
|
|
# Wait for provisioning to complete
|
|
sleep 5;
|
|
while fuel node | grep -q provisioning; do date ; sleep 10; done
|
|
|
|
# Node deploy
|
|
fuel --env $FUEL_ENV node --deploy --node $FIRST_NODE,$(($FIRST_NODE + 1)),$(($FIRST_NODE + 2)),$(($FIRST_NODE + 3))
|