5 PWD_FILENAME="passwords.sh"
8 ## Create LAB_CONFIG folder if not exists
13 ## Override default passwords with local settings if needed
16 if [ -e "$LAB_CONFIG/$PWD_FILENAME" ]; then
17 echo "------ Load local passwords ------"
18 source $LAB_CONFIG/$PWD_FILENAME
20 export MAAS_USER=ubuntu
21 export MAAS_PASSWORD=ubuntu
22 export OS_ADMIN_PASSWORD=openstack
26 ## Set Joid pod config name
28 # This part will be removed when pod names will be synced between jenkins and joid config
35 export POD_NAME=${POD/-}
38 ## Redeploy MAAS or recover the previous config
42 if [ -e "$LAB_CONFIG/environments.yaml" ] && [ "$MAAS_REINSTALL" == "false" ]; then
43 echo "------ Recover Juju environment to use MAAS ------"
44 cp $LAB_CONFIG/environments.yaml .
46 MAASCONFIG=$WORKSPACE/ci/maas/${POD/-*}/${POD/*-}/deployment.yaml
47 echo "------ Set MAAS password ------"
48 sed -i -- "s/user: ubuntu/user: $MAAS_USER/" $MAASCONFIG
49 sed -i -- "s/password: ubuntu/password: $MAAS_PASSWORD/" $MAASCONFIG
50 echo "------ Redeploy MAAS ------"
51 ./02-maasdeploy.sh $POD_NAME
53 if [ $RES != 0 ]; then
54 echo "MAAS Deploy FAILED"
60 ## Configure Joid deployment
63 # Get juju deployer file
64 if [ "$HA_MODE" == 'nonha' ]; then
65 SRCBUNDLE=$WORKSPACE/ci/$SDN_CONTROLLER/juju-deployer/ovs-$SDN_CONTROLLER.yaml
67 SRCBUNDLE=$WORKSPACE/ci/$SDN_CONTROLLER/juju-deployer/ovs-$SDN_CONTROLLER-$HA_MODE.yaml
72 echo "------ Set openstack password ------"
73 sed -i -- "s/\"admin-password\": openstack/\"admin-password\": $OS_ADMIN_PASSWORD/" $SRCBUNDLE
75 echo "------ Set ceph disks ------"
76 CEPH_DISKS_CONTROLLERS=${CEPH_DISKS_CONTROLLERS:-}
77 if [ -z "$CEPH_DISKS_CONTROLLERS" ]; then
78 CEPH_DISKS_CONTROLLERS=$CEPH_DISKS
81 #Find the first line of osd-devices to change the one for ceph, then the other for ceph-osd
82 CEPH_DEV_LINE=$(grep -nr osd-devices $SRCBUNDLE |head -n1|cut -d: -f1)
83 sed -i -- "${CEPH_DEV_LINE}s@osd-devices: /srv@osd-devices: $CEPH_DISKS@" $SRCBUNDLE
84 sed -i -- "s@osd-devices: /srv@osd-devices: $CEPH_DISKS_CONTROLLERS@" $SRCBUNDLE
85 sed -i -r -- "s/^(\s+osd-reformat: )'no'/\1'$CEPH_REFORMAT'/" $SRCBUNDLE
88 ## Configure Joid deployment
91 echo "------ Deploy with juju ------"
92 echo "Execute: ./deploy.sh -t $HA_MODE -o $OS_RELEASE -s $SDN_CONTROLLER -l $POD_NAME"
94 ./deploy.sh -t $HA_MODE -o $OS_RELEASE -s $SDN_CONTROLLER -l $POD_NAME
96 if [ $RES != 0 ]; then
104 JOID_ADMIN_OPENRC=$LAB_CONFIG/admin-openrc
105 echo "------ Create OpenRC file [$JOID_ADMIN_OPENRC] ------"
106 KEYSTONE=$(cat bundles.yaml |shyaml get-value openstack-phase2.services.keystone.options.vip)
108 # export the openrc file
109 cat << EOF > $JOID_ADMIN_OPENRC
110 export OS_USERNAME=admin
111 export OS_PASSWORD=$OS_ADMIN_PASSWORD
112 export OS_TENANT_NAME=admin
113 export OS_AUTH_URL=http://$KEYSTONE:5000/v2.0
114 export OS_REGION_NAME=Canonical
118 ## Backup local juju env
121 echo "------ Backup Juju environment ------"
122 cp environments.yaml $LAB_CONFIG/
125 ## Basic test to return a realistic result to jenkins
128 echo "------ Do basic test ------"
129 source $JOID_ADMIN_OPENRC
130 curl -i -sw '%{http_code}' -H "Content-Type: application/json" -d "
133 \"methods\": [\"password\"],
137 \"domain\": { \"id\": \"default\" },
138 \"password\": \"$OS_ADMIN_PASSWORD\"
143 }" http://$KEYSTONE:5000/v3/auth/tokens |grep "HTTP/1.1 20" 2>&1 >/dev/null;
145 if [ $RES == 0 ]; then
146 echo "Deploy SUCCESS"
148 echo "Deploy FAILED to auth to openstack"