adding space variable for K8 scenarios.
[joid.git] / ci / openstack.sh
index 118be99..98ebb14 100755 (executable)
@@ -1,5 +1,4 @@
 #!/bin/bash -ex
-
 ##############################################################################
 # All rights reserved. This program and the accompanying materials
 # are made available under the terms of the Apache License, Version 2.0
@@ -7,6 +6,10 @@
 # http://www.apache.org/licenses/LICENSE-2.0
 ##############################################################################
 
+set -ex
+
+source tools.sh
+
 #./openstack.sh "$opnfvsdn" "$opnfvlab" "$opnfvdistro" "$openstack" || true
 
 opnfvsdn=$1
@@ -84,6 +87,8 @@ keystoneIp() {
 
 # create external network and subnet in openstack
 create_openrc() {
+    echo_info "Creating the openrc (OpenStack client environment scripts)"
+
     mkdir -m 0700 -p cloud
     keystoneIp=$(keystoneIp)
     if [[ "$jujuver" < "2" ]]; then
@@ -99,7 +104,11 @@ create_openrc() {
         chmod 0600 ~/joid_config/admin-openrc
         source ~/joid_config/admin-openrc
         projectid=`openstack project show admin -c id -f value`
-        configOpenrc admin $adminPasswd admin http://$keystoneIp:5000/v3 RegionOne publicURL $projectid > ~/joid_config/admin-openrcpublic
+        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 RegionOne publicURL $projectid $projectdomainid $userdomainid > ~/joid_config/admin-openrcinternal
+        configOpenrc admin $adminPasswd admin $urlapi RegionOne publicURL $projectid $projectdomainid $userdomainid > ~/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
@@ -130,7 +139,9 @@ export OS_PASSWORD=$2
 export OS_IDENTITY_API_VERSION=3
 export OS_DEFAULT_DOMAIN=admin_domain
 export OS_USER_DOMAIN_NAME=admin_domain
+export OS_USER_DOMAIN_ID=$9
 export OS_PROJECT_DOMAIN_NAME=admin_domain
+export OS_PROJECT_DOMAIN_ID=$8
 export OS_AUTH_STRATEGY='keystone'
 export OS_REGION_NAME=$5
 export CINDER_ENDPOINT_TYPE=$6
@@ -144,7 +155,9 @@ export OS_AUTH_URL=$4
 EOF
 }
 
-if [ "$API_FQDN" != "None" ]; then
+if ([ $API_FQDN ] && [ $API_FQDN != "null" ] && [ $API_FQDN != "None" ]); then
+    echo_info "OS domain name was specified - injecting API FQDN to nodes"
+
     # Push api fqdn local ip to all /etc/hosts
     if [[ "$jujuver" < "2" ]]; then
         API_FQDN=$(juju get keystone | python -c "import yaml; import sys;\
@@ -164,7 +177,7 @@ if [ "$API_FQDN" != "None" ]; then
                     fi"
 
     # remove this enhancement for heat that does not manage endpoints
-    juju run --service=heat "cp /etc/hosts /tmp/hosts ; \
+    juju run --application=heat "cp /etc/hosts /tmp/hosts ; \
                              grep -v $API_FQDN /tmp/hosts > /etc/hosts"
 
     #change in jumphost as well as below commands will run on jumphost
@@ -181,13 +194,13 @@ create_openrc
 
 . ~/joid_config/admin-openrc
 
-echo "...... deploy public api proxy ......"
-
 if ([ "$opnfvlab" == "orangepod1" ] \
     || [ "$opnfvlab" == "intelpod6" ]) \
     && [ "$opnfvsdn" == "nosdn" ] \
     && [ "$API_FQDN" != "None" ]; then # only for first test phase
     if [ -e ./labconfig.yaml ]; then
+        echo_info "Deploying public API proxy"
+
         PUB_API_MASK=$(grep floating-ip-range ./labconfig.yaml |cut -d/ -f2)
         PUB_API_NET=$(grep floating-ip-range ./labconfig.yaml |cut -d, -f4)
         PUB_API_IP=$(grep public-api-ip ./labconfig.yaml |cut -d: -f2)
@@ -212,10 +225,11 @@ if ([ "$opnfvlab" == "orangepod1" ] \
         juju run --unit nodes/0 "sudo ip l set dev br-ex up" || true
         python genPublicAPIProxyBundle.py -l labconfig.yaml >> bundles.yaml
         juju-deployer -vW -d -t 7200 -r 5 -c bundles.yaml $opnfvdistro-"$opnfvos" || true
+
+        echo_info "Public API proxy deployed!"
     fi
 fi
 
-echo "...... deploy end public api proxy ......"
 
 ##
 ## removing the swift API endpoint which is created by radosgw.
@@ -232,6 +246,8 @@ echo "...... deploy end public api proxy ......"
 ## Create external subnet Network
 ##
 
+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 \