#!/usr/bin/env bash

provisionNode() {
  local group=$1
  local num=$2
  local ip_addr=$3
  echo "Provisioning $1-$2 with interface $3"
  /usr/share/opennms/bin/provision.pl requisition $group
  /usr/share/opennms/bin/provision.pl node add $group $num $group-$num
  /usr/share/opennms/bin/provision.pl interface add $group $num $ip_addr
  /usr/share/opennms/bin/provision.pl service add $group $num $ip_addr ICMP
  /usr/share/opennms/bin/provision.pl category add $group $num Servers
  /usr/share/opennms/bin/provision.pl category add $group $num Development
  /usr/share/opennms/bin/provision.pl requisition import $group
}

declare -a tcc_ip_addresses=("166.130.187.208" "166.130.187.212" "166.130.187.209")
COUNTER=1
for i in "${tcc_ip_addresses[@]}"
do
  provisionNode tcc $COUNTER $i
  let COUNTER=COUNTER+1 
done

declare -a vhx_ip_addresses=("166.130.158.113" "166.130.121.192" "166.130.158.104")
COUNTER=1
for i in "${vhx_ip_addresses[@]}"
do
  provisionNode vhx $COUNTER $i
  let COUNTER=COUNTER+1 
done



