Last active
July 6, 2020 07:14
-
-
Save tai271828/b0c00a611e703046dd52da12a66226b0 to your computer and use it in GitHub Desktop.
Re-deploy the whole openstack model with juju tool chain (openstack-base-testing-toolbox)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# remember to activate your python openstack venv first | |
echo "============= START: Begin to deploy the whole stack... ===============" | |
time ./01-re-deploy.sh | |
echo "============= DONE: Deployed the whole stack. =========================" | |
echo "============= START: Begin to test the whole stack... =================" | |
time ./02-basic-test-just-deployed.sh | |
echo "============= DONE: Tested the whole stack. =========================" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
JUJU_CONTROLLER="maas" | |
JUJU_USERNAME="admin" | |
JUJU_MODEL="openstack-test" | |
MIN_RECOMMISIONING=20 | |
MIN_DEPLOYMENT=45 | |
BUNDLE_PATH="${HOME}/work/openstack-juju-projects/openstack-bundles/development/openstack-base-bionic-train/bundle.yaml" | |
function run_juju { | |
juju switch ${JUJU_CONTROLLER}:${JUJU_USERNAME}/${JUJU_MODEL} | |
juju $@ | |
} | |
echo | |
echo "START: " `date +%y%m%d-%H%M%S` | |
echo | |
echo "Destroying model..." | |
run_juju destroy-model openstack-test -y --force | |
# for re-commissioning | |
echo "Waiting for a bit to make sure all nodes are released." | |
sleep 30 | |
echo "All nodes should be release. Please re-commission all nodes..." | |
for (( c=0; c<=${MIN_RECOMMISIONING}; c++ )) | |
do | |
echo ${c} min passed. | |
echo "Waiting for re-commissioning..." | |
sleep 60 | |
done | |
echo "Re-deploying..." | |
juju switch ${JUJU_CONTROLLER} | |
juju add-model openstack-test | |
sleep 3 | |
run_juju deploy ${BUNDLE_PATH} | |
for (( c=0; c<=${MIN_DEPLOYMENT}; c++ )) | |
do | |
echo ${c} min passed. | |
run_juju status | |
sleep 60 | |
done | |
echo | |
echo "END: " `date +%y%m%d-%H%M%S` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
ROOT_SCRIPTS="/home/tai271828/work/openstack-juju-projects/openstack-base-65" | |
OPENRC_PATH="${ROOT_SCRIPTS}/openrc" | |
IMAGE_TO_UPLOAD="${HOME}/work/kupeng920/openstack-base-files/bionic-server-cloudimg-arm64.img" | |
TIMESTAMP=`date +%y%m%d-%H%M%S` | |
IMAGE_UPLOADED_NAME="bionic-arm64-${TIMESTAMP}" | |
NEUTRON_CREATE_NET_EXT=${ROOT_SCRIPTS}/neutron-ext-net-ksv3 | |
NEUTRON_CREATE_NET_INT=${ROOT_SCRIPTS}/neutron-tenant-net-ksv3 | |
NETWORK_EXT_NAME="ext_net-${TIMESTAMP}" | |
NETWORK_EXT_GATEWAY="10.228.68.2" | |
NETWORK_EXT_RANGE_CIDR="10.228.68.0/24" | |
NETWORK_EXT_RANGE_FLOATING="10.228.68.170:10.228.68.179" | |
NETWORK_INT_NAME="internal-${TIMESTAMP}" | |
NETWORK_INT_RANGE_CIDR="10.5.5.0/24" | |
FLAVOR_NAME="m1.small-${TIMESTAMP}" | |
INSTANCE_NAME="bionic-arm64-${TIMESTAMP}" | |
KEY_FILE=${HOME}/.ssh/id_rsa_cloud_${TIMESTAMP} | |
KEY_NAME="mykey-${TIMESTAMP}" | |
VOLUME_NAME="myvolume-${TIMESTAMP}" | |
TIME_WAIT_FOR_INSTANCE_UP="360" | |
JUJU_CONTROLLER="maas" | |
JUJU_USERNAME="admin" | |
JUJU_MODEL="openstack-test" | |
# openrc will use juju manipulation so we need to operate in the expected model | |
juju switch ${JUJU_CONTROLLER}:${JUJU_USERNAME}/${JUJU_MODEL} | |
source ${OPENRC_PATH} | |
function run_juju { | |
juju switch ${JUJU_CONTROLLER}:${JUJU_USERNAME}/${JUJU_MODEL} | |
juju $@ | |
} | |
echo "Besides, please make sure your python environment has been installed the corresponding client tools" | |
sleep 3 | |
echo "========= Login Credential ================" | |
echo ${OS_PROJECT_DOMAIN_NAME} | |
echo ${OS_PROJECT_NAME} | |
echo ${_password} | |
echo http://`run_juju run --unit openstack-dashboard/0 'unit-get public-address'`/horizon | |
#juju run --unit keystone/0 leader-get admin_passwd | |
echo "===========================================" | |
echo "Query catalog list" | |
cmd="time openstack catalog list" | |
echo ${cmd} | |
${cmd} | |
echo "Creating images..." | |
echo "Upload image ${IMAGE_TO_UPLOAD} and name it ${IMAGE_UPLOADED_NAME}" | |
echo "This may take a while (15 minutes, depends on your uploading bandwidth)" | |
cmd="time openstack image create --public --container-format=bare --disk-format=qcow2 --property hw_firmware_type=uefi --file ${IMAGE_TO_UPLOAD} ${IMAGE_UPLOADED_NAME}" | |
echo ${cmd} | |
${cmd} | |
echo "Creating external network... ${NETWORK_EXT_NAME}" | |
cmd="${NEUTRON_CREATE_NET_EXT} --network-type flat \ | |
-g ${NETWORK_EXT_GATEWAY} \ | |
-c ${NETWORK_EXT_RANGE_CIDR} \ | |
-f ${NETWORK_EXT_RANGE_FLOATING} \ | |
${NETWORK_EXT_NAME}" | |
echo ${cmd} | |
${cmd} | |
echo "Creating private network... ${NEUTRON_CREATE_NET_INT}" | |
cmd="${NEUTRON_CREATE_NET_INT} -p admin -r provider-router ${NETWORK_INT_NAME} ${NETWORK_INT_RANGE_CIDR}" | |
echo ${cmd} | |
${cmd} | |
echo "Creating a flavor... ${FLAVOR_NAME}" | |
cmd="openstack flavor create --ram 2048 --disk 20 --ephemeral 20 ${FLAVOR_NAME}" | |
echo ${cmd} | |
${cmd} | |
echo "Prepare keypair... ${KEY_NAME}" | |
mkdir -p ${HOME}/.ssh | |
touch ${KEY_FILE} | |
chmod 600 ${KEY_FILE} | |
cmd="openstack keypair create ${KEY_NAME}" | |
echo ${cmd} '>' ${KEY_FILE} | |
${cmd} > ${KEY_FILE} | |
echo "Creating instance... ${INSTANCE_NAME} in flavor ${FLAVOR_NAME} and key ${KEY_NAME}" | |
net_id=$(openstack network list | grep internal | awk '{ print $2 }') | |
cmd="openstack server create --image ${IMAGE_UPLOADED_NAME} --flavor ${FLAVOR_NAME} --key-name ${KEY_NAME} \ | |
--nic net-id=${net_id} \ | |
${INSTANCE_NAME}" | |
echo ${cmd} | |
${cmd} | |
echo "Waiting for the instance up... ( ${TIME_WAIT_FOR_INSTANCE_UP} sec )" | |
sleep ${TIME_WAIT_FOR_INSTANCE_UP} | |
echo "Creating volume: ${VOLUME_NAME}" | |
cmd="openstack volume create --size=10 ${VOLUME_NAME}" | |
echo ${cmd} | |
${cmd} | |
echo "Attaching the volume ${VOLUME_NAME} to the instance ${INSTANCE_NAME}" | |
cmd="openstack server add volume ${INSTANCE_NAME} ${VOLUME_NAME}" | |
echo ${cmd} | |
${cmd} | |
echo "========= Login Credential ================" | |
echo openrc path: ${OPENRC_PATH} | |
echo ${OS_PROJECT_DOMAIN_NAME} | |
echo ${OS_PROJECT_NAME} | |
echo ${_password} | |
echo http://`run_juju run --unit openstack-dashboard/0 'unit-get public-address'`/horizon | |
echo "===========================================" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
OPENRC_PATH="${HOME}/work/openstack-juju-projects/openstack-bundles/development/openstack-base-bionic-train/openrc" | |
UNIQUE_IDENTIFIER="200528-233637" | |
INSTANCE_NAME="bionic-arm64-debugging"-${UNIQUE_IDENTIFIER} | |
FLAVOR_NAME="m1.small"-${UNIQUE_IDENTIFIER} | |
KEY_NAME="mykey"-${UNIQUE_IDENTIFIER} | |
IMAGE_UPLOADED_NAME="bionic-arm64"-${UNIQUE_IDENTIFIER} | |
COMPUTE_NODE="nova-compute/0" | |
COMPUTE_SERVICE_NAME="nova-compute" | |
WAITING_TIME="3600" | |
#WAITING_TIME="1800" | |
JUJU_CONTROLLER="tremont-maas-default" | |
JUJU_USERNAME="tai" | |
JUJU_MODEL="openstack-test" | |
# openrc will use juju manipulation so we need to operate in the expected model | |
juju switch ${JUJU_CONTROLLER}:${JUJU_USERNAME}/${JUJU_MODEL} | |
source ${OPENRC_PATH} | |
function run_juju { | |
juju switch ${JUJU_CONTROLLER}:${JUJU_USERNAME}/${JUJU_MODEL} | |
juju $@ | |
} | |
function create_instance() | |
{ | |
echo "Creating instance... ${INSTANCE_NAME} in flavor ${FLAVOR_NAME} and key ${KEY_NAME}" | |
net_id=$(openstack network list | grep internal | awk '{ print $2 }') | |
cmd="openstack server create --image ${IMAGE_UPLOADED_NAME} --flavor ${FLAVOR_NAME} --key-name ${KEY_NAME} \ | |
--nic net-id=${net_id} \ | |
${INSTANCE_NAME}-$1" | |
echo ${cmd} | |
${cmd} | |
} | |
for i in {1..5} | |
do | |
create_instance ${i} | |
echo "${WAITING_TIME} sec ..." | |
sleep ${WAITING_TIME} | |
echo "Create another instance after ${WAITING_TIME} sec..." | |
create_instance ${i}-${WAITING_TIME}-on-restart | |
echo "Restarting ${COMPUTE_SERVICE_NAME} ..." | |
echo "juju ssh ${COMPUTE_NODE} sudo service ${COMPUTE_SERVICE_NAME} restart" | |
run_juju ssh ${COMPUTE_NODE} sudo service ${COMPUTE_SERVICE_NAME} restart | |
echo "Restarted." | |
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
CURRENT_DAILY_DATE="200617" | |
function dl { | |
mkdir -p ./$2 | |
wget $1/$2/$3 -O ./$2/$3 | |
wget $1/$2/MD5SUMS -O ./$2/MD5SUMS.orig | |
echo | |
#set -x | |
grep $3 ./$2/MD5SUMS.orig > ./$2/MD5SUMS | |
pushd ./$2 | |
md5sum -c ./MD5SUMS | |
popd | |
#set +x | |
echo | |
} | |
rm -rf ./daily-* ./release-* | |
ls -alh | |
echo | |
echo | |
# bionic | |
dl http://cloud-images.ubuntu.com/bionic current bionic-server-cloudimg-arm64.img | |
mv ./current ./daily-${CURRENT_DAILY_DATE} | |
dl http://cloud-images.ubuntu.com/releases/bionic release-20200518.1 ubuntu-18.04-server-cloudimg-arm64.img | |
dl http://cloud-images.ubuntu.com/releases/bionic release-20200519.1 ubuntu-18.04-server-cloudimg-arm64.img | |
dl http://cloud-images.ubuntu.com/releases/bionic release-20200610 ubuntu-18.04-server-cloudimg-arm64.img | |
dl http://cloud-images.ubuntu.com/releases/bionic release-20200610.1 ubuntu-18.04-server-cloudimg-arm64.img | |
# xenial | |
dl http://cloud-images.ubuntu.com/releases/xenial release-20200522 ubuntu-16.04-server-cloudimg-arm64-uefi1.img | |
dl http://cloud-images.ubuntu.com/releases/xenial release-20200529 ubuntu-16.04-server-cloudimg-arm64-uefi1.img | |
dl http://cloud-images.ubuntu.com/releases/xenial release-20200610 ubuntu-16.04-server-cloudimg-arm64-uefi1.img |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
ROOT_SCRIPTS="${HOME}/openstack/openstack-bundles/development/openstack-base-bionic-train" | |
OPENRC_PATH="${ROOT_SCRIPTS}/openrc" | |
BASE_COMMAND="openstack image create --public --container-format=bare --disk-format=qcow2 --property hw_firmware_type=uefi --file /home/ubuntu/openstack/openstack-base-files/" | |
CURRENT_DAILY_DATE="200617" | |
source ${OPENRC_PATH} | |
${BASE_COMMAND}/daily-${CURRENT_DAILY_DATE}/bionic-server-cloudimg-arm64.img bionic-daily-${CURRENT_DAILY_DATE} | |
for release in "release-20200518.1" "release-20200519.1" "release-20200610" "release-20200610.1" | |
do | |
${BASE_COMMAND}/${release}/ubuntu-18.04-server-cloudimg-arm64.img bionic-${release} | |
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
JUJU_CONTROLLER="cloud-default" | |
JUJU_USERNAME="admin" | |
JUJU_MODEL="openstack-test" | |
MIN_WATCH=60 | |
function run_juju { | |
juju switch ${JUJU_CONTROLLER}:${JUJU_USERNAME}/${JUJU_MODEL} | |
juju $@ | |
} | |
echo | |
echo "START: " `date +%y%m%d-%H%M%S` | |
echo | |
for (( c=0; c<=${MIN_WATCH}; c++ )) | |
do | |
echo ${c} min passed. | |
run_juju status | |
sleep 60 | |
done | |
echo | |
echo "END: " `date +%y%m%d-%H%M%S` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment