cpe-deployments/scripts/post-deployment/03-set-availability-zones.sh
2021-10-29 09:57:19 +01:00

52 lines
1.4 KiB
Bash
Executable File

#!/bin/bash
# Name Description Compute Nodes
# asrock01 Nodes in AZ1 02 04
# asrock02 Nodes in AZ2 02 03
# asrock03 Nodes in AZ3 02 03
declare -A COMPUTE_NODES
COMPUTE_NODES=(
# Host Aggregate name: Compute Nodes
["asrock01"]="02 03"
["asrock02"]="02 03"
["asrock03"]="02 03"
)
declare -A AVAILABILITY_ZONES
AVAILABILITY_ZONES=(
# Host Aggregate name: Availability Zone
["asrock01"]="asrock01"
["asrock02"]="asrock02"
["asrock03"]="asrock03"
)
declare -A NODE_NAME_PREFIXES
NODE_NAME_PREFIXES=(
# Host Aggregate name: Compute Nodes
["asrock01"]="as1-maas-node-"
["asrock02"]="as2-maas-node-"
["asrock03"]="as3-maas-node-"
)
for aggregate in "${!COMPUTE_NODES[@]}"; do
# Create aggregate
echo "Creating host aggregate ${aggregate}..."
openstack aggregate create \
--zone ${AVAILABILITY_ZONES[$aggregate]} \
${aggregate}
# Add COMPUTE_NODES to the host aggregate
for node in ${COMPUTE_NODES[$aggregate]}; do
echo "Adding node ${NODE_NAME_PREFIXES[$aggregate]}${node} to host aggregate ${aggregate}..."
openstack aggregate add host ${aggregate} ${NODE_NAME_PREFIXES[$aggregate]}${node}
done
openstack flavor show ${AVAILABILITY_ZONES[$aggregate]}.m1.cirros || openstack flavor create \
--vcpus 1 --ram 64 --disk 1 \
--property aggregate_instance_extra_specs:host_aggregate=${AVAILABILITY_ZONES[$aggregate]} \
${AVAILABILITY_ZONES[$aggregate]}.m1.cirros
done