Merge "cleanup code"
[joid.git] / ci / openstack.sh
index 6b819cd..a7d91fb 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 | python -c "import yaml; import sys; print yaml.load(sys.stdin)['settings']['vip']['value']" | cut -d " " -f 1
     fi
 }
 
@@ -90,11 +72,7 @@ create_openrc() {
 
     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)
-    else
-        adminPasswd=$(juju config keystone | grep admin-password -A 5 | grep value | awk '{print $2}' 2> /dev/null)
-    fi
+    adminPasswd=$(juju config keystone | grep admin-password -A 5 | grep value | awk '{print $2}' 2> /dev/null)
 
     v3api=`juju config keystone  preferred-api-version`
 
@@ -106,8 +84,7 @@ create_openrc() {
         projectdomainid=`openstack domain show admin_domain -c id -f value`
         userdomainid=`openstack user show admin -c domain_id -f value`
         urlapi=`openstack catalog show keystone --format yaml | python -c "import yaml; import sys; print yaml.load(sys.stdin)['endpoints']" | grep public | cut -d " " -f 4`
-        configOpenrc admin $adminPasswd admin $urlapi > ~/joid_config/admin-openrcinternal
-        configOpenrc admin $adminPasswd admin $urlapi > ~/joid_config/admin-openrc
+        configOpenrc admin $adminPasswd admin $urlapi RegionOne > ~/joid_config/admin-openrc
     else
         configOpenrc2 admin $adminPasswd admin http://$keystoneIp:5000/v2.0 RegionOne > ~/joid_config/admin-openrc
         chmod 0600 ~/joid_config/admin-openrc
@@ -137,9 +114,10 @@ export OS_USERNAME=$1
 export OS_TENANT_NAME=$3
 export OS_PROJECT_NAME=$3
 export OS_PASSWORD=$2
-export OS_VOLUME_API_VERSION=2
 export OS_IDENTITY_API_VERSION=3
-export OS_IMAGE_API_VERSION=2
+export OS_REGION_NAME=$5
+#export OS_INSECURE=true
+#export OS_CASSL=~/joid_config/ca.pem
 EOF
 }
 
@@ -169,6 +147,10 @@ if [ "onos" == "$opnfvsdn" ]; then
     launch_eth
     neutron net-show ext-net > /dev/null 2>&1 || neutron net-create ext-net \
                                                    --router:external=True
+elif [ "ocl" == "$opnfvsdn" ]; then
+    neutron net-show ext-net > /dev/null 2>&1 || neutron net-create ext-net \
+                                                   --router:external=True
+
 else
     neutron net-show ext-net > /dev/null 2>&1 || neutron net-create ext-net \
                                                    --router:external=True \
@@ -180,6 +162,14 @@ 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
 
+# 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
+    echo "Creating simple gateway functions on ocl vRouters"
+      juju run --application nova-compute "sudo \
+        python /opt/contrail/utils/provision_vgw_interface.py \
+         --oper create --interface vgw1 --subnets $EXTNET_NET --routes 0.0.0.0/24 --vrf default-domain:admin:ext-net:ext-net" 
+fi
+
 #congress team is not updating and supporting charm anymore so defer it.
 
 # Create Congress datasources