include the mutiple Ubuntu distro and architecture
[releng.git] / jjb / joid / joid-deploy.sh
index 51ddb31..6cd2ee3 100644 (file)
@@ -1,4 +1,12 @@
 #!/bin/bash
+# SPDX-license-identifier: Apache-2.0
+##############################################################################
+# Copyright (c) 2016 Orange and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
 set +e
 set -o nounset
 
@@ -42,13 +50,27 @@ fi
     case $NODE_NAME in
         orange-fr-pod2)
             POD=orange-pod2 ;;
-        juniper-us-test-1)
-            POD=juniper-pod1 ;;
+        *virtual*)
+            POD=default ;;
         *)
             POD=$NODE_NAME ;;
     esac
     export POD_NAME=${POD/-}
 
+##
+## Parse Network config
+##
+
+EXTERNAL_NETWORK=${EXTERNAL_NETWORK:-}
+# split EXTERNAL_NETWORK=name;type;first ip;last ip; gateway;network
+IFS=';' read -r -a EXTNET <<< "$EXTERNAL_NETWORK"
+EXTNET_NAME=${EXTNET[0]}
+EXTNET_TYPE=${EXTNET[1]}
+EXTNET_FIP=${EXTNET[2]}
+EXTNET_LIP=${EXTNET[3]}
+EXTNET_GW=${EXTNET[4]}
+EXTNET_NET=${EXTNET[5]}
+
 ##
 ## Redeploy MAAS or recover the previous config
 ##
@@ -101,21 +123,18 @@ SRCBUNDLE="${WORKSPACE}/ci/${SDN_CONTROLLER}/juju-deployer/"
 SRCBUNDLE="${SRCBUNDLE}/ovs-${SDN_CONTROLLER}-${HA_MODE}.yaml"
 
 
-# Modify files
-
+# Modify Bundle
 echo "------ Set openstack password ------"
-sed -i -- "s/\"admin-password\": openstack/\"admin-password\": $OS_ADMIN_PASSWORD/" $SRCBUNDLE
+sed -i -- "s/admin-password: openstack/admin-password: $OS_ADMIN_PASSWORD/" $SRCBUNDLE
 
-echo "------ Set ceph disks ------"
-CEPH_DISKS_CONTROLLERS=${CEPH_DISKS_CONTROLLERS:-}
-if [ -z "$CEPH_DISKS_CONTROLLERS" ]; then
-    CEPH_DISKS_CONTROLLERS=$CEPH_DISKS
+if [ -n "$EXTNET_NAME" ]; then
+    echo "------ Set openstack default network ------"
+    sed -i -- "s/neutron-external-network: ext_net/neutron-external-network: $EXTNET_NAME/" $SRCBUNDLE
 fi
 
+echo "------ Set ceph disks ------"
 #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_CONTROLLERS@" $SRCBUNDLE
+sed -i -- "s@osd-devices: /srv@osd-devices: $CEPH_DISKS@" $SRCBUNDLE
 sed -i -r -- "s/^(\s+osd-reformat: )'no'/\1'$CEPH_REFORMAT'/" $SRCBUNDLE
 
 ##
@@ -123,9 +142,9 @@ sed -i -r -- "s/^(\s+osd-reformat: )'no'/\1'$CEPH_REFORMAT'/" $SRCBUNDLE
 ##
 
 echo "------ Deploy with juju ------"
-echo "Execute: ./deploy.sh -t $HA_MODE -o $OS_RELEASE -s $SDN_CONTROLLER -l $POD_NAME"
+echo "Execute: ./deploy.sh -t $HA_MODE -o $OS_RELEASE -s $SDN_CONTROLLER -l $POD_NAME -d $UBUNTU_DISTRO"
 
-./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 -d $UBUNTU_DISTRO
 exit_on_error $? "Main deploy FAILED"
 
 ##
@@ -133,7 +152,31 @@ exit_on_error $? "Main deploy FAILED"
 ##
 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)
+
+# get Keystone ip
+case "$HA_MODE" in
+    "ha")
+        KEYSTONE=$(cat bundles.yaml |shyaml get-value openstack-phase2.services.keystone.options.vip)
+        ;;
+    *)
+        KEYSTONE=$(juju status keystone |grep public-address|sed -- 's/.*\: //')
+        ;;
+esac
+
+
+# get controller IP
+case "$SDN_CONTROLLER" in
+    "odl")
+        SDN_CONTROLLER_IP=$(juju status odl-controller/0 |grep public-address|sed -- 's/.*\: //')
+        ;;
+    "onos")
+        SDN_CONTROLLER_IP=$(juju status onos-controller/0 |grep public-address|sed -- 's/.*\: //')
+        ;;
+    *)
+        SDN_CONTROLLER_IP='none'
+        ;;
+esac
+SDN_PASSWORD='admin'
 
 # export the openrc file
 cat << EOF > $JOID_ADMIN_OPENRC
@@ -142,6 +185,8 @@ export OS_PASSWORD=$OS_ADMIN_PASSWORD
 export OS_TENANT_NAME=admin
 export OS_AUTH_URL=http://$KEYSTONE:5000/v2.0
 export OS_REGION_NAME=Canonical
+export SDN_CONTROLLER=$SDN_CONTROLLER_IP
+export SDN_PASSWORD=$SDN_PASSWORD
 EOF
 
 ##
@@ -178,18 +223,11 @@ exit_on_error $? "Deploy FAILED to auth to openstack"
 ## Create external network if needed
 ##
 
-EXTERNAL_NETWORK=${EXTERNAL_NETWORK:-}
-# split EXTERNAL_NETWORK=name;type;first ip;last ip; gateway;network
-IFS=';' read -r -a EXTNET <<< "$EXTERNAL_NETWORK"
-EXTNET_NAME=${EXTNET[0]}
-EXTNET_TYPE=${EXTNET[1]}
-EXTNET_FIP=${EXTNET[2]}
-EXTNET_LIP=${EXTNET[3]}
-EXTNET_GW=${EXTNET[4]}
-EXTNET_NET=${EXTNET[5]}
 # If we have more information than only the name, try to create it
 if [ -z "$EXTNET_TYPE" ]; then
     echo "------ No data for external network creation, pass ------"
+elif [[ "$DEPLOY_SCENARIO" =~ "onos" ]]; then
+    echo "------ ONOS have created the external network, pass ------"
 else
     echo "------ External network creation ------"
     neutron net-create $EXTNET_NAME --router:external True \