Support custom hostname for Portal UI

Change-Id: If315051577a3bf1367f779d6d1385b17e57c5dc3
Issue-ID: INT-774
Signed-off-by: Gary Wu <gary.i.wu@huawei.com>
diff --git a/deployment/heat/onap-oom/env/tlab/onap-oom.env b/deployment/heat/onap-oom/env/tlab/onap-oom.env
index 42726e5..a54a798 100644
--- a/deployment/heat/onap-oom/env/tlab/onap-oom.env
+++ b/deployment/heat/onap-oom/env/tlab/onap-oom.env
@@ -77,3 +77,19 @@
       aai-spike:
         liveness:
           initialDelaySeconds: 120
+    portal:
+      global:
+        portalHostName: "__portal_hostname__"
+      portal-mariadb:
+        config:
+          sdcFeHostName: "__portal_hostname__"
+          papHostName: "__portal_hostname__"
+          vidHostName: "__portal_hostname__"
+          aaiSparkyHostName: "__portal_hostname__"
+          cliHostName: "__portal_hostname__"
+          portalSdkHostName: "__portal_hostname__"
+          dmaapBcHostName: "__portal_hostname__"
+          msbHostName: "__portal_hostname__"
+    vid:
+      config:
+        portalhost: "__portal_hostname__"
diff --git a/deployment/heat/onap-oom/env/windriver/onap-oom.env b/deployment/heat/onap-oom/env/windriver/onap-oom.env
index 6d471ff..850a471 100644
--- a/deployment/heat/onap-oom/env/windriver/onap-oom.env
+++ b/deployment/heat/onap-oom/env/windriver/onap-oom.env
@@ -78,3 +78,19 @@
       aai-spike:
         liveness:
           initialDelaySeconds: 120
+    portal:
+      global:
+        portalHostName: "__portal_hostname__"
+      portal-mariadb:
+        config:
+          sdcFeHostName: "__portal_hostname__"
+          papHostName: "__portal_hostname__"
+          vidHostName: "__portal_hostname__"
+          aaiSparkyHostName: "__portal_hostname__"
+          cliHostName: "__portal_hostname__"
+          portalSdkHostName: "__portal_hostname__"
+          dmaapBcHostName: "__portal_hostname__"
+          msbHostName: "__portal_hostname__"
+    vid:
+      config:
+        portalhost: "__portal_hostname__"
diff --git a/deployment/heat/onap-oom/onap-oom.yaml b/deployment/heat/onap-oom/onap-oom.yaml
index 44b23e4..9745f62 100644
--- a/deployment/heat/onap-oom/onap-oom.yaml
+++ b/deployment/heat/onap-oom/onap-oom.yaml
@@ -100,6 +100,11 @@
     type: number
     default: 1500
 
+  portal_hostname:
+    type: string
+    description: The FQDN of the k8s host that will be used for the Portal UI component URLs; this needs to be resolveable at the client
+    default: "portal.api.simpledemo.onap.org"
+
 resources:
   random-str:
     type: OS::Heat::RandomString
@@ -222,6 +227,7 @@
             __helm_deploy_delay__: { get_param: helm_deploy_delay }
             __use_ramdisk__: { get_param: use_ramdisk }
             __mtu__: { get_param: mtu }
+            __portal_hostname__: { get_param: portal_hostname }
             __public_net_id__: { get_param: public_net_id }
             __oam_network_cidr__: { get_param: oam_network_cidr }
             __oam_network_id__: { get_resource: oam_network }
diff --git a/deployment/heat/onap-oom/parts/onap-oom-1.yaml b/deployment/heat/onap-oom/parts/onap-oom-1.yaml
index 1a9e33d..0b7ac43 100644
--- a/deployment/heat/onap-oom/parts/onap-oom-1.yaml
+++ b/deployment/heat/onap-oom/parts/onap-oom-1.yaml
@@ -97,6 +97,11 @@
     type: number
     default: 1500
 
+  portal_hostname:
+    type: string
+    description: The FQDN of the k8s host that will be used for the Portal UI component URLs; this needs to be resolveable at the client
+    default: "portal.api.simpledemo.onap.org"
+
 resources:
   random-str:
     type: OS::Heat::RandomString
diff --git a/deployment/heat/onap-oom/rancher_vm_entrypoint.sh b/deployment/heat/onap-oom/rancher_vm_entrypoint.sh
index 1ee29b0..8e6a36b 100644
--- a/deployment/heat/onap-oom/rancher_vm_entrypoint.sh
+++ b/deployment/heat/onap-oom/rancher_vm_entrypoint.sh
@@ -36,10 +36,12 @@
 echo "__helm_version__" > /opt/config/helm_version.txt
 echo "__helm_deploy_delay__" > /opt/config/helm_deploy_delay.txt
 echo "__mtu__" > /opt/config/mtu.txt
+echo "__portal_hostname__" > /opt/config/portal_hostname.txt
 
 cat <<EOF > /opt/config/integration-override.yaml
 __integration_override_yaml__
 EOF
+sed -i 's/\_\_portal_hostname__/__portal_hostname__/g' /opt/config/integration-override.yaml
 sed -i 's/\_\_public_net_id__/__public_net_id__/g' /opt/config/integration-override.yaml
 sed -i 's|\_\_oam_network_cidr__|__oam_network_cidr__|g' /opt/config/integration-override.yaml
 sed -i 's/\_\_oam_network_id__/__oam_network_id__/g' /opt/config/integration-override.yaml
@@ -295,6 +297,14 @@
 cd ~/oom
 git diff
 git commit -a -m "apply manifest versions"
+
+cd ~/oom
+# workaround to change onap portal cookie domain
+sed -i "s/^cookie_domain.*=.*/cookie_domain = __portal_hostname__/g" ./kubernetes/portal/charts/portal-app/resources/config/deliveries/properties/ONAPPORTAL/system.properties
+sed -i "s/^cookie_domain.*=.*/cookie_domain = __portal_hostname__/g" ./kubernetes/portal/charts/portal-sdk/resources/config/deliveries/properties/ONAPPORTALSDK/system.properties
+git diff
+git commit -a -m "set portal cookie domain"
+
 git tag -a "deploy0" -m "initial deployment"
 
 
diff --git a/deployment/heat/onap-oom/scripts/deploy.sh b/deployment/heat/onap-oom/scripts/deploy.sh
index 4387bbe..7977c6a 100755
--- a/deployment/heat/onap-oom/scripts/deploy.sh
+++ b/deployment/heat/onap-oom/scripts/deploy.sh
@@ -10,6 +10,7 @@
 #
 
 stack_name="oom"
+portal_hostname="portal.api.simpledemo.onap.org"
 full_deletion=false
 
 if [ -z "$WORKSPACE" ]; then
@@ -17,10 +18,11 @@
 fi
 
 usage() {
-    echo "Usage: $0 [ -n <number of VMs {2-15}> ][ -s <stack name> ][ -m <manifest> ][ -r ][ -q ] <env>" 1>&2;
+    echo "Usage: $0 [ -n <number of VMs {2-15}> ][ -s <stack name> ][ -m <manifest> ][ -d <domain> ][ -r ][ -q ] <env>" 1>&2;
 
     echo "n:    Set the number of VM's that will be installed. This number must be between 2 and 15" 1>&2;
     echo "s:    Set the name to be used for stack. This name will be used for naming of resources" 1>&2;
+    echo "d:    Set the base domain name to be used in portal UI URLs" 1>&2;
     echo "m:    The docker manifest to apply; must be either \"docker-manifest-staging.csv\" or \"docker-manifest.csv\"." 1>&2;
     echo "r:    Delete all resources relating to ONAP within enviroment." 1>&2;
     echo "q:    Quiet Delete of all ONAP resources." 1>&2;
@@ -29,7 +31,7 @@
 }
 
 
-while getopts ":n:s:m:rq" o; do
+while getopts ":n:s:d:m:rq" o; do
     case "${o}" in
         n)
             if [[ ${OPTARG} =~ ^[0-9]+$ ]];then
@@ -49,6 +51,13 @@
                 usage
             fi
             ;;
+        d)
+            if [[ ! ${OPTARG} =~ ^[0-9]+$ ]];then
+                portal_hostname=${OPTARG}
+            else
+                usage
+            fi
+            ;;
         m)
             if [ -f $WORKSPACE/version-manifest/src/main/resources/${OPTARG} ]; then
                 docker_manifest=${OPTARG}
@@ -120,7 +129,7 @@
         ./scripts/gen-onap-oom-yaml.sh $vm_num > onap-oom.yaml~
     fi
 
-    if ! openstack stack create -t ./onap-oom.yaml~ -e $ENV_FILE~ $stack_name --parameter docker_manifest=$docker_manifest; then
+    if ! openstack stack create -t ./onap-oom.yaml~ -e $ENV_FILE~ $stack_name --parameter docker_manifest=$docker_manifest --parameter portal_hostname=$portal_hostname; then
         break
     fi
 
diff --git a/deployment/heat/onap-oom/scripts/gen-onap-oom-yaml.sh b/deployment/heat/onap-oom/scripts/gen-onap-oom-yaml.sh
index 61d5f9f..6117801 100755
--- a/deployment/heat/onap-oom/scripts/gen-onap-oom-yaml.sh
+++ b/deployment/heat/onap-oom/scripts/gen-onap-oom-yaml.sh
@@ -64,6 +64,7 @@
             __helm_deploy_delay__: { get_param: helm_deploy_delay }
             __use_ramdisk__: { get_param: use_ramdisk }
             __mtu__: { get_param: mtu }
+            __portal_hostname__: { get_param: portal_hostname }
             __public_net_id__: { get_param: public_net_id }
             __oam_network_cidr__: { get_param: oam_network_cidr }
             __oam_network_id__: { get_resource: oam_network }