blob: 33d2c3db89b3e74b0e51b65bf4533d6b99e4baa7 [file] [log] [blame]
Gary Wu14a6b302018-05-01 15:59:28 -07001#!/bin/bash
Gary Wua3fb86f2018-06-04 16:23:54 -07002#
3# Copyright 2018 Huawei Technologies Co., Ltd.
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
Gary Wu14a6b302018-05-01 15:59:28 -070011
Gary Wu7d034582018-05-12 09:08:20 -070012if [ "$#" -ne 1 ]; then
13 echo This script generates the HEAT template for X number of k8s VMs
14 echo "$0 <num k8s vms>"
15 exit 1
16fi
17NUM_K8S_VMS=$1
18
Gary Wu14a6b302018-05-01 15:59:28 -070019
20if [ -z "$WORKSPACE" ]; then
21 export WORKSPACE=`git rev-parse --show-toplevel`
22fi
23PARTS_DIR=$WORKSPACE/deployment/heat/onap-oom/parts
24
Gary Wu11c98742018-05-02 16:19:04 -070025cat <<EOF
26#
27# Generated by scripts/gen-onap-oom-yaml.sh; MANUAL CHANGES WILL BE LOST
28#
29EOF
30
Gary Wu14a6b302018-05-01 15:59:28 -070031cat $PARTS_DIR/onap-oom-1.yaml
32
33cat <<EOF
34 rancher_vm:
35 type: OS::Nova::Server
36 properties:
37 name: rancher
38 image: { get_param: ubuntu_1604_image }
39 flavor: { get_param: rancher_vm_flavor }
gwu10db4622018-07-17 22:11:39 -070040 key_name: { get_param: key_name }
Gary Wu14a6b302018-05-01 15:59:28 -070041 networks:
42 - port: { get_resource: rancher_private_port }
43 user_data_format: RAW
44 user_data:
45 str_replace:
46 template:
47 get_file: rancher_vm_entrypoint.sh
48 params:
Gary Wu14a6b302018-05-01 15:59:28 -070049 __docker_proxy__: { get_param: docker_proxy }
50 __apt_proxy__: { get_param: apt_proxy }
51 __rancher_ip_addr__: { get_attr: [rancher_floating_ip, floating_ip_address] }
Gary Wuad513722018-07-26 13:08:47 -070052 __rancher_private_ip_addr__: { get_attr: [rancher_floating_ip, fixed_ip_address] }
Gary Wu11c98742018-05-02 16:19:04 -070053 __integration_override_yaml__: { get_param: integration_override_yaml }
Gary Wuc4749702018-06-26 14:27:41 -070054 __gerrit_branch__: { get_param: gerrit_branch }
55 __gerrit_refspec__: { get_param: gerrit_refspec }
56 __docker_manifest__: { get_param: docker_manifest }
Gary Wu978171e2018-07-24 11:56:01 -070057 __public_net_id__: { get_param: public_net_id }
58 __oam_network_cidr__: { get_param: oam_network_cidr }
Gary Wu11c98742018-05-02 16:19:04 -070059 __oam_network_id__: { get_resource: oam_network }
60 __oam_subnet_id__: { get_resource: oam_subnet }
Gary Wu276d5a42018-06-05 11:26:44 -070061 __k8s_1_vm_ip__: { get_attr: [k8s_1_floating_ip, floating_ip_address] }
Gary Wu14a6b302018-05-01 15:59:28 -070062 __k8s_vm_ips__: [
63EOF
64
65for VM_NUM in $(seq $NUM_K8S_VMS); do
66 K8S_VM_NAME=k8s_$VM_NUM
67 cat <<EOF
68 get_attr: [${K8S_VM_NAME}_floating_ip, floating_ip_address],
69EOF
70done
71
72cat <<EOF
73 ]
Gary Wuad513722018-07-26 13:08:47 -070074 __k8s_private_ips__: [
75EOF
76
77for VM_NUM in $(seq $NUM_K8S_VMS); do
78 K8S_VM_NAME=k8s_$VM_NUM
79 cat <<EOF
80 get_attr: [${K8S_VM_NAME}_floating_ip, fixed_ip_address],
81EOF
82done
83
84cat <<EOF
85 ]
Gary Wu14a6b302018-05-01 15:59:28 -070086EOF
87
88for VM_NUM in $(seq $NUM_K8S_VMS); do
89 K8S_VM_NAME=k8s_$VM_NUM envsubst < $PARTS_DIR/onap-oom-2.yaml
90done
91
92cat $PARTS_DIR/onap-oom-3.yaml
Gary Wu36e42dd2018-05-03 07:29:53 -070093
94for VM_NUM in $(seq $NUM_K8S_VMS); do
95 K8S_VM_NAME=k8s_$VM_NUM
96 cat <<EOF
97 ${K8S_VM_NAME}_vm_ip:
98 description: The IP address of the ${K8S_VM_NAME} instance
99 value: { get_attr: [${K8S_VM_NAME}_floating_ip, floating_ip_address] }
100
101EOF
102done