Merge "Auto Generated INFO.yaml file"
[joid.git] / ci / openstack.sh
index a32bb99..139a0df 100755 (executable)
@@ -17,8 +17,6 @@ opnfvlab=$2
 opnfvdistro=$3
 opnfvos=$4
 
-jujuver=`juju --version`
-
 if [ -f ./deployconfig.yaml ];then
     EXTERNAL_NETWORK=`grep floating-ip-range deployconfig.yaml | cut -d ' ' -f 4 `
 
@@ -49,38 +47,22 @@ update_gw_mac() {
     ## get gateway mac
     EXTNET_GW_MAC=$(juju ssh nova-compute/0 "arp -a ${EXTNET_GW} | grep -Eo '([0-9a-fA-F]{2})(([/\s:-][0-9a-fA-F]{2}){5})'")
     ## set external gateway mac in onos
-    if [[ "$jujuver" < "2" ]]; then
-        juju set onos-controller gateway-mac=$EXTNET_GW_MAC
-    else
-        juju config onos-controller gateway-mac=$EXTNET_GW_MAC
-    fi
+    juju config onos-controller gateway-mac=$EXTNET_GW_MAC
 }
 
 unitAddress() {
-    if [[ "$jujuver" < "2" ]]; then
-        juju status --format yaml | python -c "import yaml; import sys; print yaml.load(sys.stdin)[\"services\"][\"$1\"][\"units\"][\"$1/$2\"][\"public-address\"]" 2> /dev/null
-    else
-        juju status --format yaml | python -c "import yaml; import sys; print yaml.load(sys.stdin)[\"applications\"][\"$1\"][\"units\"][\"$1/$2\"][\"public-address\"]" 2> /dev/null
-    fi
+    juju status --format yaml | python -c "import yaml; import sys; print yaml.load(sys.stdin)[\"applications\"][\"$1\"][\"units\"][\"$1/$2\"][\"public-address\"]" 2> /dev/null
 }
 
 unitMachine() {
-    if [[ "$jujuver" < "2" ]]; then
-        juju status --format yaml | python -c "import yaml; import sys; print yaml.load(sys.stdin)[\"services\"][\"$1\"][\"units\"][\"$1/$2\"][\"machine\"]" 2> /dev/null
-    else
-        juju status --format yaml | python -c "import yaml; import sys; print yaml.load(sys.stdin)[\"applications\"][\"$1\"][\"units\"][\"$1/$2\"][\"machine\"]" 2> /dev/null
-    fi
+    juju status --format yaml | python -c "import yaml; import sys; print yaml.load(sys.stdin)[\"applications\"][\"$1\"][\"units\"][\"$1/$2\"][\"machine\"]" 2> /dev/null
 }
 
 keystoneIp() {
     if [ $(juju status keystone --format=short | grep " keystone"|wc -l) == 1 ];then
         unitAddress keystone 0
     else
-        if [[ "$jujuver" < "2" ]]; then
-            juju get keystone | python -c "import yaml; import sys; print yaml.load(sys.stdin)['settings']['vip']['value']" | cut -d " " -f 1
-        else
-            juju config keystone | python -c "import yaml; import sys; print yaml.load(sys.stdin)['settings']['vip']['value']" | cut -d " " -f 1
-        fi
+        juju config keystone vip | cut -d " " -f 1
     fi
 }
 
@@ -89,17 +71,26 @@ create_openrc() {
     echo_info "Creating the openrc (OpenStack client environment scripts)"
 
     mkdir -m 0700 -p cloud
-    keystoneIp=$(keystoneIp)
-    if [[ "$jujuver" < "2" ]]; then
-        adminPasswd=$(juju get keystone | grep admin-password -A 5 | grep value | awk '{print $2}' 2> /dev/null)
+    usessl=$(juju config keystone ssl_ca)
+    if [[ "$usessl" == "" ]]; then
+        usessl=no
     else
-        adminPasswd=$(juju config keystone | grep admin-password -A 5 | grep value | awk '{print $2}' 2> /dev/null)
+        usessl=yes
+    fi
+    keystoneIp=$(juju config keystone os-public-hostname | cut -d " " -f 1)
+    if [[ "$keystoneIp" == "" ]]; then
+        keystoneIp=$(keystoneIp)
     fi
+    adminPasswd=$(juju config keystone admin-password | cut -d " " -f 1)
 
-    v3api=`juju config keystone  preferred-api-version`
+    v3api=$(juju config keystone  preferred-api-version)
 
     if [[ "$v3api" == "3" ]]; then
-        configOpenrc admin $adminPasswd admin http://$keystoneIp:5000/v3 RegionOne publicURL > ~/joid_config/admin-openrc
+        if [ "$usessl" == "yes" ]; then
+            configOpenrc admin $adminPasswd admin https://$keystoneIp:5000/v3 RegionOne publicURL > ~/joid_config/admin-openrc
+        else
+            configOpenrc admin $adminPasswd admin http://$keystoneIp:5000/v3 RegionOne publicURL > ~/joid_config/admin-openrc
+        fi
         chmod 0600 ~/joid_config/admin-openrc
         source ~/joid_config/admin-openrc
         projectid=`openstack project show admin -c id -f value`
@@ -127,6 +118,7 @@ EOF
 }
 
 configOpenrc() {
+if [ "$usessl" == "yes" ]; then
 cat <<-EOF
 #export OS_NO_CACHE='true'
 export OS_AUTH_URL=$4
@@ -138,11 +130,32 @@ export OS_PROJECT_NAME=$3
 export OS_PASSWORD=$2
 export OS_IDENTITY_API_VERSION=3
 export OS_REGION_NAME=$5
-#export OS_INSECURE=true
-#export OS_CASSL=~/joid_config/ca.pem
+export OS_INTERFACE=public
+export OS_CACERT=~/joid_config/keystone_juju_ca_cert.crt
 EOF
+else
+cat <<-EOF
+#export OS_NO_CACHE='true'
+export OS_AUTH_URL=$4
+export OS_USER_DOMAIN_NAME=admin_domain
+export OS_PROJECT_DOMAIN_NAME=admin_domain
+export OS_USERNAME=$1
+export OS_TENANT_NAME=$3
+export OS_PROJECT_NAME=$3
+export OS_PASSWORD=$2
+export OS_IDENTITY_API_VERSION=3
+export OS_REGION_NAME=$5
+export OS_INTERFACE=public
+#export OS_CACERT=~/joid_config/bradm.etsi-ubuntu-jh.maas.pem
+EOF
+fi
 }
 
+
+if [ "$usessl" == "yes" ]; then
+    juju scp keystone/0:/usr/local/share/ca-certificates/keystone_juju_ca_cert.crt ~/joid_config/
+fi
+
 # Create an load openrc
 create_openrc
 
@@ -167,22 +180,22 @@ echo_info "Creating external network with neutron"
 
 if [ "onos" == "$opnfvsdn" ]; then
     launch_eth
-    neutron net-show ext-net > /dev/null 2>&1 || neutron net-create ext-net \
-                                                   --router:external=True
+    openstack network show ext-net > /dev/null 2>&1 || openstack network create \
+                                                   --external --share --enable ext-net
 elif [ "ocl" == "$opnfvsdn" ]; then
-    neutron net-show ext-net > /dev/null 2>&1 || neutron net-create ext-net \
-                                                   --router:external=True
+    openstack network show ext-net > /dev/null 2>&1 || openstack network create \
+                                                   --external --share --enable ext-net
 
 else
-    neutron net-show ext-net > /dev/null 2>&1 || neutron net-create ext-net \
-                                                   --router:external=True \
-                                                   --provider:network_type flat \
-                                                   --provider:physical_network physnet1
+    openstack network show ext-net > /dev/null 2>&1 || openstack network create \
+                                                   --provider-network-type flat \
+                                                   --provider-physical-network physnet1 \
+                                                   --external --share --enable  ext-net
 fi
 
-neutron subnet-show ext-subnet > /dev/null 2>&1 || neutron subnet-create ext-net \
-   --name ext-subnet --allocation-pool start=$EXTNET_FIP,end=$EXTNET_LIP \
-   --disable-dhcp --gateway $EXTNET_GW $EXTNET_NET
+openstack subnet show ext-subnet > /dev/null 2>&1 || openstack subnet create \
+   --allocation-pool start=$EXTNET_FIP,end=$EXTNET_LIP \
+   --no-dhcp --gateway $EXTNET_GW --network ext-net --subnet-range $EXTNET_NET ext-subnet
 
 # Ocl can push packets to the fabric network in order to reach a gateway if BGP/L3VPN hasn't been configured.
 if [ "ocl" == "$opnfvsdn" ]; then