#!/bin/bash


# Name                       Description                  Compute Nodes
# default                    2:1 CPU                      04,05,06 

declare -A COMPUTE_NODES
COMPUTE_NODES=(
  ["default"]="04 05 06"
)

NODE_NAME_PREFIX="node0"

for aggregate in "${!COMPUTE_NODES[@]}"; do
  # Create aggregate
  echo "Creating host aggregate ${aggregate}..."
  openstack aggregate create \
    --property host_aggregate=${aggregate} \
    ${aggregate}

  # Add COMPUTE_NODES to the host aggregate
  for node in ${COMPUTE_NODES[$aggregate]}; do
    echo "Adding node ${NODE_NAME_PREFIX}${node} to host aggregate ${aggregate}..."
    openstack aggregate add host ${aggregate} ${NODE_NAME_PREFIX}${node}
  done
done