summaryrefslogtreecommitdiffstats
path: root/jjb/joid/joid-deploy.sh
diff options
context:
space:
mode:
authorDavid Blaisonneau <david.blaisonneau@orange.com>2016-01-06 18:02:49 +0100
committerFatih Degirmenci <fatih.degirmenci@ericsson.com>2016-01-08 12:41:03 +0000
commit95bcdcbf6d2e2fb7aa3f0bdb8a1cd56d50db9731 (patch)
tree757f1414d2b877afe7c8e86fff43c9c35b877ea3 /jjb/joid/joid-deploy.sh
parentf7d2f66f5a986cf25ccdb7f6bdf2cbd709202266 (diff)
Merge joid pod builders and add projet and pod default parameters
Change-Id: Ifeb2086eaaee7ecf95044bf9e6abf83b4b7bfae6 Signed-off-by: David Blaisonneau <david.blaisonneau@orange.com>
Diffstat (limited to 'jjb/joid/joid-deploy.sh')
-rw-r--r--jjb/joid/joid-deploy.sh96
1 files changed, 55 insertions, 41 deletions
diff --git a/jjb/joid/joid-deploy.sh b/jjb/joid/joid-deploy.sh
index c7e5ba8fd..ad4248954 100644
--- a/jjb/joid/joid-deploy.sh
+++ b/jjb/joid/joid-deploy.sh
@@ -2,51 +2,58 @@
set +e
set -o nounset
-JOID_LOCAL_CONFIG_FOLDER=$HOME/joid_config
-JOID_ADMIN_OPENRC=$JOID_LOCAL_CONFIG_FOLDER/admin-openrc
+PWD_FILENAME="passwords.sh"
##
-## Load local config or defaults
+## Create LAB_CONFIG folder if not exists
##
+mkdir -p $LAB_CONFIG
-if [ -e "$JOID_LOCAL_CONFIG_FOLDER/config.sh" ]; then
- echo "------ Load local config ------"
- source $JOID_LOCAL_CONFIG_FOLDER/config.sh
-else
- echo "------ No local config, load default ------"
- # link NODE_NAME to joid node config names
+##
+## Override default passwords with local settings if needed
+##
+
+if [ -e "$LAB_CONFIG/$PWD_FILENAME" ]; then
+ echo "------ Load local passwords ------"
+ source $LAB_CONFIG/$PWD_FILENAME
+fi
+
+##
+## Set Joid pod config name
+##
+ # This part will be removed when pod names will be synced between jenkins and joid config
case $NODE_NAME in
orange-fr-pod2)
POD=orange-pod2 ;;
*)
POD=$NODE_NAME ;;
esac
- export POD_DC=$(echo $POD |cut -d\- -f1)
- export POD_NUM=$(echo $POD |cut -d\- -f2)
- export POD_NAME=$POD_DC$POD_NUM
- export MAAS_REINSTALL=true
- export MAAS_USER=ubuntu
- export MAAS_PASSWORD=ubuntu
- export OS_ADMIN_PASSWORD=openstack
- export CEPH_DISKS=/srv
- export CEPH_REFORMAT=no
-fi
+ export POD_NAME=${POD/-}
##
## Redeploy MAAS or recover the previous config
##
cd $WORKSPACE/ci
-if [ -e "$JOID_LOCAL_CONFIG_FOLDER/environments.yaml" ] && [ "$MAAS_REINSTALL" == "false" ]; then
+if [ -e "$LAB_CONFIG/environments.yaml" ] && [ "$MAAS_REINSTALL" == "false" ]; then
echo "------ Recover Juju environment to use MAAS ------"
- cp $JOID_LOCAL_CONFIG_FOLDER/environments.yaml .
+ cp $LAB_CONFIG/environments.yaml .
else
- MAASCONFIG=$WORKSPACE/ci/maas/$POD_DC/$POD_NUM/deployment.yaml
+ MAASCONFIG=$WORKSPACE/ci/maas/${POD/-*}/${POD/*-}/deployment.yaml
echo "------ Set MAAS password ------"
- sed -i -- "s/user: ubuntu/user: $MAAS_USER/" $MAASCONFIG
- sed -i -- "s/password: ubuntu/password: $MAAS_PASSWORD/" $MAASCONFIG
+ if [ -n "$MAAS_USER" ]; then
+ sed -i -- "s/user: ubuntu/user: $MAAS_USER/" $MAASCONFIG
+ fi
+ if [ -n "$MAAS_PASSWORD" ]; then
+ sed -i -- "s/password: ubuntu/password: $MAAS_PASSWORD/" $MAASCONFIG
+ fi
echo "------ Redeploy MAAS ------"
./02-maasdeploy.sh $POD_NAME
+ RES=$?
+ if [ $RES != 0 ]; then
+ echo "MAAS Deploy FAILED"
+ exit $RES
+ fi
fi
##
@@ -63,10 +70,18 @@ fi
# Modify files
echo "------ Set openstack password ------"
-sed -i -- "s/\"admin-password\": openstack/\"admin-password\": $OS_ADMIN_PASSWORD/" $SRCBUNDLE
+if [ -n "$OS_ADMIN_PASSWORD" ]; then
+ sed -i -- "s/\"admin-password\": openstack/\"admin-password\": $OS_ADMIN_PASSWORD/" $SRCBUNDLE
+fi
echo "------ Set ceph disks ------"
-sed -i -- "s@osd-devices: /srv@osd-devices: $CEPH_DISKS@" $SRCBUNDLE
+if [ -z "$CEPH_DISKS_CONTROLLERS" ]; then
+ CEPH_DISKS_CONTROLLERS=$CEPH_DISKS
+fi
+#Find the first line of osd-devices to change the one for ceph, then the other for ceph-osd
+CEPH_DEV_LINE=$(grep -nr osd-devices $SRCBUNDLE |head -n1|cut -d: -f1)
+sed -i -- "${CEPH_DEV_LINE}s@osd-devices: /srv@osd-devices: $CEPH_DISKS@" $SRCBUNDLE
+sed -i -- "s@osd-devices: /srv@osd-devices: $CEPH_DISKS_CONTROLERS@" $SRCBUNDLE
sed -i -r -- "s/^(\s+osd-reformat: )'no'/\1'$CEPH_REFORMAT'/" $SRCBUNDLE
##
@@ -77,20 +92,19 @@ echo "------ Deploy with juju ------"
echo "Execute: ./deploy.sh -t $HA_MODE -o $OS_RELEASE -s $SDN_CONTROLLER -l $POD_NAME"
./deploy.sh -t $HA_MODE -o $OS_RELEASE -s $SDN_CONTROLLER -l $POD_NAME
+RES=$?
+if [ $RES != 0 ]; then
+ echo "Deploy FAILED"
+ exit $RES
+fi
##
## Set Admin RC
##
-
+JOID_ADMIN_OPENRC=$LAB_CONFIG/admin-openrc
echo "------ Create OpenRC file [$JOID_ADMIN_OPENRC] ------"
KEYSTONE=$(cat bundles.yaml |shyaml get-value openstack-phase2.services.keystone.options.vip)
-# create the folder if needed
-JOID_ADMIN_OPENRC_FOLDER=$(echo $JOID_ADMIN_OPENRC | perl -pe "s|^(.*/).*?$|\1|")
-if [ ! -d "$JOID_ADMIN_OPENRC_FOLDER" ]; then
- mkdir -p $JOID_ADMIN_OPENRC_FOLDER
-fi
-
# export the openrc file
cat << EOF > $JOID_ADMIN_OPENRC
export OS_USERNAME=admin
@@ -104,14 +118,14 @@ EOF
## Backup local juju env
##
-if [ -d "$JOID_LOCAL_CONFIG_FOLDER" ]; then
- echo "------ Backup Juju environment ------"
- cp environments.yaml $JOID_LOCAL_CONFIG_FOLDER/
-fi
+echo "------ Backup Juju environment ------"
+cp environments.yaml $LAB_CONFIG/
##
## Basic test to return a realistic result to jenkins
##
+
+echo "------ Do basic test ------"
source $JOID_ADMIN_OPENRC
curl -i -sw '%{http_code}' -H "Content-Type: application/json" -d "
{ \"auth\": {
@@ -119,18 +133,18 @@ curl -i -sw '%{http_code}' -H "Content-Type: application/json" -d "
\"methods\": [\"password\"],
\"password\": {
\"user\": {
- \"name\": \"$OS_TENANT_NAME\",
+ \"name\": \"admin\",
\"domain\": { \"id\": \"default\" },
- \"password\": \"$OS_PASSWORD\"
+ \"password\": \"$OS_ADMIN_PASSWORD\"
}
}
}
}
-}" http://$KEYSTONE:5000/v3/auth/tokens |grep "HTTP/1.1 20" 2>&1 >/dev/null; echo $?;
+}" http://$KEYSTONE:5000/v3/auth/tokens |grep "HTTP/1.1 20" 2>&1 >/dev/null;
RES=$?
if [ $RES == 0 ]; then
echo "Deploy SUCCESS"
else
- echo "Deploy FAILED"
+ echo "Deploy FAILED to auth to openstack"
fi
exit $RES