blob: e32d2e7b3aebbe020a08ce3a939ec1f2352ffb95 [file] [log] [blame]
#!/bin/bash
#
################################################################################
# Copyright (c) 2019 AT&T Intellectual Property. #
# Copyright (c) 2019 Nokia. #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); #
# you may not use this file except in compliance with the License. #
# You may obtain a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
################################################################################
usage() {
echo "Usage: $0 [ -n <number of VMs {1-99}> ][ -6 ]" 1>&2;
echo "n: Set the number of VMs that will be installed. This number must be between 1 and 99; " 1>&2;
echo "6: When set, VMs will be configured with an IPv6 interface" 1>&2;
exit 1;
}
unset V6
while getopts ":n:6" o; do
case "${o}" in
n)
if [[ ${OPTARG} =~ ^[0-9]+$ ]];then
if [ ${OPTARG} -ge 1 -a ${OPTARG} -le 15 ]; then
vm_num=${OPTARG}
else
usage
fi
else
usage
fi
;;
6)
V6='-v6'
;;
*)
usage
;;
esac
done
shift $((OPTIND-1))
NUM_K8S_VMS=$(($vm_num - 1))
unset SEQ
if [ "$NUM_K8S_VMS" -gt "0" ]; then
SEQ=$(seq -f %02g $NUM_K8S_VMS)
fi
if [ -z "$WORKSPACE" ]; then
export WORKSPACE=`git rev-parse --show-toplevel`
fi
PARTS_DIR=$WORKSPACE/ric-infra/00-Kubernetes/heat/parts
cat <<EOF
#
# Generated by scripts/gen-onap-oom-yaml.sh; MANUAL CHANGES WILL BE LOST
#
EOF
cat $PARTS_DIR/part-1${V6}.yaml
# the first node is master
#for VM_NUM in mst $(seq -f %02g $NUM_K8S_VMS); do
for VM_NUM in mst $SEQ; do
VM_TYPE=k8s HOST_LABEL=compute VM_NUM=$VM_NUM envsubst < $PARTS_DIR/part-2${V6}.yaml
done
cat $PARTS_DIR/part-3${V6}.yaml
#for VM_NUM in mst $(seq -f %02g $NUM_K8S_VMS); do
for VM_NUM in mst $SEQ; do
K8S_VM_NAME=k8s_$VM_NUM
cat <<EOF
${K8S_VM_NAME}_vm_ip:
description: The IP address of the ${K8S_VM_NAME} instance
value: { get_attr: [${K8S_VM_NAME}_floating_ip, floating_ip_address] }
EOF
done