blob: 41d5113912a24eaf4b0053d3b959ac95893e1c17 [file] [log] [blame]
Gary Wu14a6b302018-05-01 15:59:28 -07001#!/bin/bash
2
Gary Wu7d034582018-05-12 09:08:20 -07003if [ "$#" -ne 1 ]; then
4 echo This script generates the HEAT template for X number of k8s VMs
5 echo "$0 <num k8s vms>"
6 exit 1
7fi
8NUM_K8S_VMS=$1
9
Gary Wu14a6b302018-05-01 15:59:28 -070010
11if [ -z "$WORKSPACE" ]; then
12 export WORKSPACE=`git rev-parse --show-toplevel`
13fi
14PARTS_DIR=$WORKSPACE/deployment/heat/onap-oom/parts
15
Gary Wu11c98742018-05-02 16:19:04 -070016cat <<EOF
17#
18# Generated by scripts/gen-onap-oom-yaml.sh; MANUAL CHANGES WILL BE LOST
19#
20EOF
21
Gary Wu14a6b302018-05-01 15:59:28 -070022cat $PARTS_DIR/onap-oom-1.yaml
23
24cat <<EOF
25 rancher_vm:
26 type: OS::Nova::Server
27 properties:
28 name: rancher
29 image: { get_param: ubuntu_1604_image }
30 flavor: { get_param: rancher_vm_flavor }
31 key_name: onap_key
32 networks:
33 - port: { get_resource: rancher_private_port }
34 user_data_format: RAW
35 user_data:
36 str_replace:
37 template:
38 get_file: rancher_vm_entrypoint.sh
39 params:
Gary Wu14a6b302018-05-01 15:59:28 -070040 __docker_proxy__: { get_param: docker_proxy }
41 __apt_proxy__: { get_param: apt_proxy }
42 __rancher_ip_addr__: { get_attr: [rancher_floating_ip, floating_ip_address] }
Gary Wu11c98742018-05-02 16:19:04 -070043 __integration_override_yaml__: { get_param: integration_override_yaml }
44 __oam_network_id__: { get_resource: oam_network }
45 __oam_subnet_id__: { get_resource: oam_subnet }
Gary Wu14a6b302018-05-01 15:59:28 -070046 __k8s_vm_ips__: [
47EOF
48
49for VM_NUM in $(seq $NUM_K8S_VMS); do
50 K8S_VM_NAME=k8s_$VM_NUM
51 cat <<EOF
52 get_attr: [${K8S_VM_NAME}_floating_ip, floating_ip_address],
53EOF
54done
55
56cat <<EOF
57 ]
58EOF
59
60for VM_NUM in $(seq $NUM_K8S_VMS); do
61 K8S_VM_NAME=k8s_$VM_NUM envsubst < $PARTS_DIR/onap-oom-2.yaml
62done
63
64cat $PARTS_DIR/onap-oom-3.yaml
Gary Wu36e42dd2018-05-03 07:29:53 -070065
66for VM_NUM in $(seq $NUM_K8S_VMS); do
67 K8S_VM_NAME=k8s_$VM_NUM
68 cat <<EOF
69 ${K8S_VM_NAME}_vm_ip:
70 description: The IP address of the ${K8S_VM_NAME} instance
71 value: { get_attr: [${K8S_VM_NAME}_floating_ip, floating_ip_address] }
72
73EOF
74done