blob: 61d5f9f701544d7f7d1a02f86598721fa368b7ed [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 -070019if [ -z "$WORKSPACE" ]; then
20 export WORKSPACE=`git rev-parse --show-toplevel`
21fi
22PARTS_DIR=$WORKSPACE/deployment/heat/onap-oom/parts
23
Gary Wu11c98742018-05-02 16:19:04 -070024cat <<EOF
25#
26# Generated by scripts/gen-onap-oom-yaml.sh; MANUAL CHANGES WILL BE LOST
27#
28EOF
29
Gary Wu14a6b302018-05-01 15:59:28 -070030cat $PARTS_DIR/onap-oom-1.yaml
31
32cat <<EOF
33 rancher_vm:
34 type: OS::Nova::Server
35 properties:
eHanan97b7a9c2018-09-05 14:09:19 +010036 name:
37 list_join: ['-', [{ get_param: 'OS::stack_name' }, 'rancher']]
Gary Wu14a6b302018-05-01 15:59:28 -070038 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 Wu87aa8b52018-08-09 08:10:24 -070054 __integration_gerrit_branch__: { get_param: integration_gerrit_branch }
55 __integration_gerrit_refspec__: { get_param: integration_gerrit_refspec }
56 __oom_gerrit_branch__: { get_param: oom_gerrit_branch }
57 __oom_gerrit_refspec__: { get_param: oom_gerrit_refspec }
Gary Wuc4749702018-06-26 14:27:41 -070058 __docker_manifest__: { get_param: docker_manifest }
Gary Wu7a04b3d2018-08-15 12:31:46 -070059 __docker_version__: { get_param: docker_version }
60 __rancher_version__: { get_param: rancher_version }
61 __rancher_agent_version__: { get_param: rancher_agent_version }
62 __kubectl_version__: { get_param: kubectl_version }
63 __helm_version__: { get_param: helm_version }
Gary Wu48a32942018-11-08 07:34:49 -080064 __helm_deploy_delay__: { get_param: helm_deploy_delay }
65 __use_ramdisk__: { get_param: use_ramdisk }
Gary Wub8be70a2018-11-17 17:14:38 -080066 __mtu__: { get_param: mtu }
Gary Wu978171e2018-07-24 11:56:01 -070067 __public_net_id__: { get_param: public_net_id }
68 __oam_network_cidr__: { get_param: oam_network_cidr }
Gary Wu11c98742018-05-02 16:19:04 -070069 __oam_network_id__: { get_resource: oam_network }
70 __oam_subnet_id__: { get_resource: oam_subnet }
Gary Wu17440fe2018-10-22 15:12:07 -070071 __sec_group__: { get_resource: onap_sg }
Gary Wu48a32942018-11-08 07:34:49 -080072 __k8s_01_vm_ip__: { get_attr: [k8s_01_floating_ip, floating_ip_address] }
Gary Wu14a6b302018-05-01 15:59:28 -070073 __k8s_vm_ips__: [
74EOF
75
Gary Wu48a32942018-11-08 07:34:49 -080076for VM_NUM in $(seq -f %02g $NUM_K8S_VMS); do
Gary Wu14a6b302018-05-01 15:59:28 -070077 K8S_VM_NAME=k8s_$VM_NUM
78 cat <<EOF
79 get_attr: [${K8S_VM_NAME}_floating_ip, floating_ip_address],
80EOF
81done
82
83cat <<EOF
84 ]
Gary Wuad513722018-07-26 13:08:47 -070085 __k8s_private_ips__: [
86EOF
87
Gary Wu48a32942018-11-08 07:34:49 -080088for VM_NUM in $(seq -f %02g $NUM_K8S_VMS); do
Gary Wuad513722018-07-26 13:08:47 -070089 K8S_VM_NAME=k8s_$VM_NUM
90 cat <<EOF
91 get_attr: [${K8S_VM_NAME}_floating_ip, fixed_ip_address],
92EOF
93done
94
95cat <<EOF
96 ]
Gary Wu14a6b302018-05-01 15:59:28 -070097EOF
98
Gary Wu48a32942018-11-08 07:34:49 -080099for VM_NUM in $(seq -f %02g $NUM_K8S_VMS); do
Gary Wu3fd6c2a2018-10-28 21:44:00 -0700100 VM_TYPE=k8s HOST_LABEL=compute VM_NUM=$VM_NUM envsubst < $PARTS_DIR/onap-oom-2.yaml
Gary Wu14a6b302018-05-01 15:59:28 -0700101done
102
Gary Wu3fd6c2a2018-10-28 21:44:00 -0700103for VM_NUM in $(seq 3); do
104 VM_TYPE=etcd HOST_LABEL=etcd VM_NUM=$VM_NUM envsubst < $PARTS_DIR/onap-oom-2.yaml
105done
106
Gary Wu6e662012018-11-13 18:41:45 -0800107for VM_NUM in $(seq 2); do
Gary Wu3fd6c2a2018-10-28 21:44:00 -0700108 VM_TYPE=orch HOST_LABEL=orchestration VM_NUM=$VM_NUM envsubst < $PARTS_DIR/onap-oom-2.yaml
109done
110
111
Gary Wu14a6b302018-05-01 15:59:28 -0700112cat $PARTS_DIR/onap-oom-3.yaml
Gary Wu36e42dd2018-05-03 07:29:53 -0700113
Gary Wu48a32942018-11-08 07:34:49 -0800114for VM_NUM in $(seq -f %02g $NUM_K8S_VMS); do
Gary Wu36e42dd2018-05-03 07:29:53 -0700115 K8S_VM_NAME=k8s_$VM_NUM
116 cat <<EOF
117 ${K8S_VM_NAME}_vm_ip:
118 description: The IP address of the ${K8S_VM_NAME} instance
119 value: { get_attr: [${K8S_VM_NAME}_floating_ip, floating_ip_address] }
120
121EOF
122done