Increase to 11 k8s VMs for stability
[integration.git] / deployment / heat / onap-oom / scripts / gen-onap-oom-yaml.sh
1 #!/bin/bash
2 #
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 #
11
12 if [ "$#" -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
16 fi
17 NUM_K8S_VMS=$1
18
19
20 if [ -z "$WORKSPACE" ]; then
21     export WORKSPACE=`git rev-parse --show-toplevel`
22 fi
23 PARTS_DIR=$WORKSPACE/deployment/heat/onap-oom/parts
24
25 cat <<EOF
26 #
27 # Generated by scripts/gen-onap-oom-yaml.sh; MANUAL CHANGES WILL BE LOST
28 #
29 EOF
30
31 cat $PARTS_DIR/onap-oom-1.yaml
32
33 cat <<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 }
40       key_name: onap_key
41       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:
49             __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] }
52             __integration_override_yaml__: { get_param: integration_override_yaml }
53             __oam_network_id__: { get_resource: oam_network }
54             __oam_subnet_id__: { get_resource: oam_subnet }
55             __k8s_1_vm_ip__: { get_attr: [k8s_1_floating_ip, floating_ip_address] }
56             __k8s_vm_ips__: [
57 EOF
58
59 for VM_NUM in $(seq $NUM_K8S_VMS); do
60     K8S_VM_NAME=k8s_$VM_NUM
61     cat <<EOF
62               get_attr: [${K8S_VM_NAME}_floating_ip, floating_ip_address],
63 EOF
64 done
65
66 cat <<EOF
67             ]
68 EOF
69
70 for VM_NUM in $(seq $NUM_K8S_VMS); do
71     K8S_VM_NAME=k8s_$VM_NUM envsubst < $PARTS_DIR/onap-oom-2.yaml
72 done
73
74 cat $PARTS_DIR/onap-oom-3.yaml
75
76 for VM_NUM in $(seq $NUM_K8S_VMS); do
77     K8S_VM_NAME=k8s_$VM_NUM
78     cat <<EOF
79   ${K8S_VM_NAME}_vm_ip:
80     description: The IP address of the ${K8S_VM_NAME} instance
81     value: { get_attr: [${K8S_VM_NAME}_floating_ip, floating_ip_address] }
82
83 EOF
84 done