Gary Wu | 14a6b30 | 2018-05-01 15:59:28 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
Gary Wu | 7d03458 | 2018-05-12 09:08:20 -0700 | [diff] [blame] | 3 | if [ "$#" -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 |
| 7 | fi |
| 8 | NUM_K8S_VMS=$1 |
| 9 | |
Gary Wu | 14a6b30 | 2018-05-01 15:59:28 -0700 | [diff] [blame] | 10 | |
| 11 | if [ -z "$WORKSPACE" ]; then |
| 12 | export WORKSPACE=`git rev-parse --show-toplevel` |
| 13 | fi |
| 14 | PARTS_DIR=$WORKSPACE/deployment/heat/onap-oom/parts |
| 15 | |
Gary Wu | 11c9874 | 2018-05-02 16:19:04 -0700 | [diff] [blame] | 16 | cat <<EOF |
| 17 | # |
| 18 | # Generated by scripts/gen-onap-oom-yaml.sh; MANUAL CHANGES WILL BE LOST |
| 19 | # |
| 20 | EOF |
| 21 | |
Gary Wu | 14a6b30 | 2018-05-01 15:59:28 -0700 | [diff] [blame] | 22 | cat $PARTS_DIR/onap-oom-1.yaml |
| 23 | |
| 24 | cat <<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 Wu | 14a6b30 | 2018-05-01 15:59:28 -0700 | [diff] [blame] | 40 | __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 Wu | 11c9874 | 2018-05-02 16:19:04 -0700 | [diff] [blame] | 43 | __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 Wu | 14a6b30 | 2018-05-01 15:59:28 -0700 | [diff] [blame] | 46 | __k8s_vm_ips__: [ |
| 47 | EOF |
| 48 | |
| 49 | for 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], |
| 53 | EOF |
| 54 | done |
| 55 | |
| 56 | cat <<EOF |
| 57 | ] |
| 58 | EOF |
| 59 | |
| 60 | for VM_NUM in $(seq $NUM_K8S_VMS); do |
| 61 | K8S_VM_NAME=k8s_$VM_NUM envsubst < $PARTS_DIR/onap-oom-2.yaml |
| 62 | done |
| 63 | |
| 64 | cat $PARTS_DIR/onap-oom-3.yaml |
Gary Wu | 36e42dd | 2018-05-03 07:29:53 -0700 | [diff] [blame] | 65 | |
| 66 | for 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 | |
| 73 | EOF |
| 74 | done |