Refactor heat template for ONAP OOM

Change-Id: I6883aaf59510a9b8d426523ea1c3a15504a120c5
Issue-ID: INT-381
Signed-off-by: Gary Wu <gary.i.wu@huawei.com>
diff --git a/test/ete/labs/huawei/k8s_vm_entrypoint.sh b/test/ete/labs/huawei/k8s_vm_entrypoint.sh
index 0dc432b..8a34b8e 100644
--- a/test/ete/labs/huawei/k8s_vm_entrypoint.sh
+++ b/test/ete/labs/huawei/k8s_vm_entrypoint.sh
@@ -91,7 +91,7 @@
 
 # Update values.yaml to point to docker-proxy instead of nexus3:
 cd ~/oom/kubernetes
-perl -p -i -e 's/nexus3.onap.org:10001/__docker_proxy__/g' `find ./ -name values.yaml`
+perl -p -i -e 's/nexus3.onap.org:10001/__docker_proxy__/g' `find ./ -name values.yaml` oneclick/setenv.bash
 
 KUBETOKEN=$(echo -n 'Basic '$(echo -n "$RANCHER_ACCESS_KEY:$RANCHER_SECRET_KEY" | base64 -w 0) | base64 -w 0)
 
@@ -116,41 +116,38 @@
   user:
     token: "$KUBETOKEN"
 EOF
-cat ~/.kube/config
-
-# Update ~/oom/kubernetes/kube2msb/values.yaml kubeMasterAuthToken to use the token from ~/.kube/config
-sed -i "s/kubeMasterAuthToken:.*/kubeMasterAuthToken: $KUBETOKEN/" ~/oom/kubernetes/kube2msb/values.yaml
 
 export KUBECONFIG=/root/.kube/config
 kubectl config view
 
-# wait for kubernetes to initialze
-sleep 100
-until [ $(kubectl get pods --all-namespaces | tail -n +2 | grep -c Running) -ge 6 ]; do
-    sleep 10
-done
+# Update ~/oom/kubernetes/kube2msb/values.yaml kubeMasterAuthToken to use the token from ~/.kube/config
+sed -i "s/kubeMasterAuthToken:.*/kubeMasterAuthToken: $KUBETOKEN/" ~/oom/kubernetes/kube2msb/values.yaml
 
 # Put your onap_key ssh private key in ~/.ssh/onap_key
 
 # Create or edit ~/oom/kubernetes/config/onap-parameters.yaml
 cp ~/oom/kubernetes/config/onap-parameters-sample.yaml ~/oom/kubernetes/config/onap-parameters.yaml
 cat >> ~/oom/kubernetes/config/onap-parameters.yaml <<EOF
-OPENSTACK_UBUNTU_14_IMAGE: "trusty"
-OPENSTACK_PUBLIC_NET_ID: "024582bd-ef9b-48b9-9e70-e6732559d9df"
-OPENSTACK_OAM_NETWORK_ID: "a899f36c-28e1-4aa9-9451-1b9f41feefa5"
-OPENSTACK_OAM_SUBNET_ID: "b9627602-2908-4aee-94b5-4f1dc92017df"
-OPENSTACK_OAM_NETWORK_CIDR: "172.16.1.0/24"
-OPENSTACK_USERNAME: "demo"
-OPENSTACK_API_KEY: "demo"
-OPENSTACK_TENANT_NAME: "demo"
-OPENSTACK_TENANT_ID: "__public_net_id__"
-OPENSTACK_REGION: "RegionOne"
-OPENSTACK_KEYSTONE_URL: "http://192.168.1.11:5000"
-OPENSTACK_FLAVOUR_MEDIUM: "m1.medium"
-OPENSTACK_SERVICE_TENANT_NAME: "service"
-DMAAP_TOPIC: "AUTO"
-DEMO_ARTIFACTS_VERSION: "1.1.0-SNAPSHOT"
+OPENSTACK_UBUNTU_14_IMAGE: "__ubuntu_1404_image__"
+OPENSTACK_PUBLIC_NET_ID: "__public_net_id__"
+OPENSTACK_OAM_NETWORK_ID: "__oam_network_id__"
+OPENSTACK_OAM_SUBNET_ID: "__oam_subnet_id__"
+OPENSTACK_OAM_NETWORK_CIDR: "__oam_network_cidr__"
+OPENSTACK_TENANT_NAME: "__openstack_tenant_name__"
+OPENSTACK_TENANT_ID: "__openstack_tenant_id__"
+OPENSTACK_USERNAME: "__openstack_username__"
+OPENSTACK_API_KEY: "__openstack_api_key__"
+OPENSTACK_KEYSTONE_URL: "__keystone_url__"
+DEPLOY_DCAE: "false"
 EOF
+cat ~/oom/kubernetes/config/onap-parameters.yaml
+
+
+# wait for kubernetes to initialze
+sleep 100
+until [ $(kubectl get pods --namespace kube-system | tail -n +2 | grep -c Running) -ge 6 ]; do
+    sleep 10
+done
 
 # Source the environment file:
 cd ~/oom/kubernetes/oneclick/
@@ -171,3 +168,5 @@
 ./createAll.bash -n onap
 
 # Check ONAP status:
+sleep 30
+kubectl get pods --all-namespaces
diff --git a/test/ete/labs/huawei/onap-oom.env b/test/ete/labs/huawei/onap-oom.env
index b50244e..208cc6f 100644
--- a/test/ete/labs/huawei/onap-oom.env
+++ b/test/ete/labs/huawei/onap-oom.env
@@ -7,8 +7,13 @@
   ##############################################
 
   public_net_id: 3a6247f1-fac6-4167-a49f-33cc8415ccf4
-
   docker_proxy: 10.145.122.118:5000
-
   apt_proxy: 10.145.122.118:3142
-
+  dns_list: ["10.145.122.117", "10.145.122.118"]
+  oam_network_cidr: 172.16.0.0/16
+  ubuntu_1404_image: trusty
+  openstack_tenant_id: 3d228d2fcbb7447bbba3cde703431bc1
+  openstack_tenant_name: onap-ci-amsterdam-heat
+  openstack_username: demo
+  openstack_api_key: demo
+  keystone_url: http://10.145.122.117:5000
diff --git a/test/ete/labs/huawei/onap-oom.yaml b/test/ete/labs/huawei/onap-oom.yaml
index ff4d835..049e373 100644
--- a/test/ete/labs/huawei/onap-oom.yaml
+++ b/test/ete/labs/huawei/onap-oom.yaml
@@ -2,17 +2,88 @@
 description: ONAP on Kubernetes using OOM
 
 parameters:
-  public_net_id:
-    type: string
-    description: The ID of the Public network for floating IP address allocation
-
   docker_proxy:
     type: string
 
   apt_proxy:
     type: string
 
+  public_net_id:
+    type: string
+    description: The ID of the Public network for floating IP address allocation
+
+  dns_list:
+    type: comma_delimited_list
+    description: List of External DNS for OAM ONAP network
+
+  oam_network_cidr:
+    type: string
+    description: CIDR of the OAM ONAP network
+
+  keystone_url:
+    type: string
+    description: URL of OpenStack Keystone
+
+  openstack_tenant_id:
+    type: string
+    description: OpenStack tenant ID
+
+  openstack_tenant_name:
+    type: string
+    description: OpenStack tenant name (matching with the openstack_tenant_id)
+
+  openstack_username:
+    type: string
+    description: OpenStack username
+
+  openstack_api_key:
+    type: string
+    description: OpenStack password or API Key
+
+  ubuntu_1404_image:
+    type: string
+    description: Name of the Ubuntu 14.04 image
+
 resources:
+  random-str:
+    type: OS::Heat::RandomString
+    properties:
+      length: 4
+
+  # ONAP management private network
+  oam_network:
+    type: OS::Neutron::Net
+    properties:
+      name:
+        str_replace:
+          template: "oam_network_RAND"
+          params:
+            RAND: { get_resource: random-str }
+
+  oam_subnet:
+    type: OS::Neutron::Subnet
+    properties:
+      name:
+        str_replace:
+          template: "oam_subnet_RAND"
+          params:
+            RAND: { get_resource: random-str }
+      network_id: { get_resource: oam_network }
+      cidr: { get_param: oam_network_cidr }
+      dns_nameservers: { get_param: dns_list }
+
+  router:
+    type: OS::Neutron::Router
+    properties:
+      external_gateway_info:
+        network: { get_param: public_net_id }
+
+  router_interface:
+    type: OS::Neutron::RouterInterface
+    properties:
+      router_id: { get_resource: router }
+      subnet_id: { get_resource: oam_subnet }
+
   rancher_vm:
     type: OS::Nova::Server
     properties:
@@ -47,5 +118,15 @@
             __docker_proxy__: { get_param: docker_proxy }
             __apt_proxy__: { get_param: apt_proxy }
             __rancher_ip_addr__: { get_attr: [rancher_vm, first_address] }
+            __openstack_tenant_id__: { get_param: openstack_tenant_id }
+            __openstack_tenant_name__: { get_param: openstack_tenant_name }
+            __openstack_username__: { get_param: openstack_username }
+            __openstack_api_key__: { get_param : openstack_api_key }
+            __public_net_id__: { get_param: public_net_id }
+            __oam_network_id__: { get_resource: oam_network }
+            __oam_subnet_id__: { get_resource: oam_subnet }
+            __oam_network_cidr__: { get_param: oam_network_cidr }
+            __ubuntu_1404_image__: { get_param: ubuntu_1404_image }
+            __keystone_url__: { get_param: keystone_url }
           template:
             get_file: k8s_vm_entrypoint.sh