instack-undercloud/scripts/instack-deploy-overcloud
2014-08-18 14:04:56 -04:00

220 lines
7.8 KiB
Bash
Executable File

#!/bin/bash
set -eux
OS_AUTH_URL=${OS_AUTH_URL:-""}
if [ -z "$OS_AUTH_URL" ]; then
echo "You must source a stackrc file for the Undercloud."
exit 1
fi
# setup-baremetal requires this to be set
export TRIPLEO_ROOT=.
CPU=${CPU:-1}
MEM=${MEM:-2048}
DISK=${DISK:-30}
ARCH=${ARCH:-amd64}
MACS=${MACS:-"52:54:00:b5:bd:f0 52:54:00:f2:be:f0"}
VIRTUAL_POWER_USER=${VIRTUAL_POWER_USER:-$USER}
VIRTUAL_POWER_HOST=${VIRTUAL_POWER_HOST:-"192.168.122.1"}
SSH_KEY=${SSH_KEY:-""}
PM_IPS=( ${PM_IPS:-} )
PM_USERS=( ${PM_USERS:-} )
PM_PASSWORDS=( ${PM_PASSWORDS:-} )
export USE_IRONIC=1
export ROOT_DISK=${ROOT_DISK:-10}
JSONFILE=nodes.json
rm -f $JSONFILE
echo '{}' > $JSONFILE
JSON=$(jq .nodes=[] $JSONFILE)
count=0
for mac in $MACS; do
if [ -n "${PM_IPS:-}" -a -n "${PM_USERS:-}" -a -n "${PM_PASSWORDS:-}" ]; then
JSON=$(jq ".nodes=(.nodes + [{mac:[\"$mac\"], cpu:\"$CPU\", memory:\"$MEM\", disk:\"$DISK\", arch:\"$ARCH\", pm_user:\"$PM_USERS[$count]\", pm_addr:\"$PM_IPS[$count]\", pm_password:\"$PM_PASSWORDS[$count]\", pm_type:\"ipmi\"}])" <<< $JSON)
else
if [ ! -f "$SSH_KEY" ]; then
echo \$SSH_KEY must be the full file path to the virtual power key
exit 1
fi
JSON=$(jq ".nodes=(.nodes + [{mac:[\"$mac\"], cpu:\"$CPU\", memory:\"$MEM\", disk:\"$DISK\", arch:\"$ARCH\", pm_user:\"$VIRTUAL_POWER_USER\", pm_addr:\"$VIRTUAL_POWER_HOST\", pm_password:\"$(cat $SSH_KEY)\", pm_type:\"pxe_ssh\"}])" <<< $JSON)
fi
count=$((count + 1))
done
echo $JSON | python -mjson.tool
echo $JSON > $JSONFILE
for i in ramdisk kernel; do
if glance image-show bm-deploy-$i 2>&1 1>/dev/null; then
glance image-delete bm-deploy-$i
fi
done
tripleo setup-baremetal --service-host undercloud --nodes <(jq '.nodes' $JSONFILE)
# Must wait for baremetal nodes to register as nova hypervisors
sleep 60
tripleo setup-overcloud-passwords -o tripleo-overcloud-passwords
source tripleo-overcloud-passwords
# Define the interface that will be bridged onto the Neutron defined
# network.
NeutronPublicInterface=${NeutronPublicInterface:-eth0}
# Define the overcloud libvirt type for virtualization. kvm for
# baremetal, qemu for an overcloud running in vm's.
OVERCLOUD_LIBVIRT_TYPE=${OVERCLOUD_LIBVIRT_TYPE:-qemu}
COMPUTESCALE=${COMPUTESCALE:-1}
BLOCKSTORAGESCALE=${BLOCKSTORAGESCALE:-1}
SWIFTSTORAGESCALE=${SWIFTSTORAGESCALE:-1}
if [ -d /usr/share/openstack-tripleo-heat-templates ]; then
tripleo-heat-merge \
--included-template-dir /usr/share/openstack-tripleo-heat-templates \
--scale NovaCompute=$COMPUTESCALE \
--scale BlockStorage=$BLOCKSTORAGESCALE \
--scale SwiftStorage=$SWIFTSTORAGESCALE \
/usr/share/openstack-tripleo-heat-templates/overcloud-source.yaml \
/usr/share/openstack-tripleo-heat-templates/swift-source.yaml \
/usr/share/openstack-tripleo-heat-templates/swift-storage-source.yaml \
/usr/share/openstack-tripleo-heat-templates/ssl-source.yaml \
/usr/share/openstack-tripleo-heat-templates/block-storage.yaml \
> overcloud.yaml
OVERCLOUD_YAML_PATH=overcloud.yaml
export OVERCLOUD_PARAMETERS=${OVERCLOUD_PARAMETERS:-"\
-P AdminPassword=${OVERCLOUD_ADMIN_PASSWORD} \
-P AdminToken=${OVERCLOUD_ADMIN_TOKEN} \
-P CinderPassword=${OVERCLOUD_CINDER_PASSWORD} \
-P GlanceLogFile=\"''\" \
-P GlancePassword=${OVERCLOUD_GLANCE_PASSWORD} \
-P HeatPassword=${OVERCLOUD_HEAT_PASSWORD} \
-P NeutronDnsmasqOptions=\"dhcp-option-force=26,1400\" \
-P NeutronPassword=${OVERCLOUD_NEUTRON_PASSWORD} \
-P NeutronPublicInterface=$NeutronPublicInterface \
-P NovaComputeLibvirtType=$OVERCLOUD_LIBVIRT_TYPE \
-P NovaPassword=${OVERCLOUD_NOVA_PASSWORD} \
-P SwiftHashSuffix=${OVERCLOUD_SWIFT_HASH} \
-P SwiftPassword=${OVERCLOUD_SWIFT_PASSWORD} \
"}
HEAT_ENVIRONMENT=""
else
make -C $INSTACK_ROOT/tripleo-heat-templates overcloud.yaml COMPUTESCALE=$COMPUTESCALE BLOCKSTORAGESCALE=$BLOCKSTORAGESCALE SWIFTSTORAGESCALE=$SWIFTSTORAGESCALE
OVERCLOUD_YAML_PATH=$INSTACK_ROOT/tripleo-heat-templates/overcloud.yaml
NeutronControlPlaneID=$(neutron net-show ctlplane | grep ' id ' | awk '{print $4}')
export OVERCLOUD_PARAMETERS=${OVERCLOUD_PARAMETERS:-"\
-P AdminPassword=${OVERCLOUD_ADMIN_PASSWORD} \
-P AdminToken=${OVERCLOUD_ADMIN_TOKEN} \
-P CeilometerPassword=${OVERCLOUD_CEILOMETER_PASSWORD} \
-P CeilometerMeteringSecret=${OVERCLOUD_CEILOMETER_SECRET} \
-P CinderPassword=${OVERCLOUD_CINDER_PASSWORD} \
-P CinderISCSIHelper=lioadm \
-P CloudName=overcloud \
-P GlancePassword=${OVERCLOUD_GLANCE_PASSWORD} \
-P HeatPassword=${OVERCLOUD_HEAT_PASSWORD} \
-P NeutronControlPlaneID=$NeutronControlPlaneID \
-P NeutronDnsmasqOptions=dhcp-option-force=26,1400 \
-P NeutronPassword=${OVERCLOUD_NEUTRON_PASSWORD} \
-P NeutronPublicInterface=$NeutronPublicInterface \
-P NovaComputeLibvirtType=$OVERCLOUD_LIBVIRT_TYPE \
-P NovaPassword=${OVERCLOUD_NOVA_PASSWORD} \
-P SwiftHashSuffix=${OVERCLOUD_SWIFT_HASH} \
-P SwiftPassword=${OVERCLOUD_SWIFT_PASSWORD} \
-P NeutronNetworkType=${NEUTRON_NETWORK_TYPE} \
-P NeutronTunnelTypes=${NEUTRON_TUNNEL_TYPES} \
"}
HEAT_ENV=${HEAT_ENV:-"${INSTACK_ROOT}/overcloud-env.json"}
ENV_JSON='{"parameters":{}}'
jq . > "${HEAT_ENV}" <<< $ENV_JSON
chmod 0600 "${HEAT_ENV}"
generate-keystone-pki --heatenv $HEAT_ENV
HEAT_ENVIRONMENT="-e ${HEAT_ENV}"
fi
heat stack-create -f $OVERCLOUD_YAML_PATH \
$OVERCLOUD_PARAMETERS \
$HEAT_ENVIRONMENT \
overcloud
tripleo wait_for_stack_ready 220 10 overcloud
echo "Overcloud CREATE_COMPLETE"
if [ -d /etc/tripleo ]; then
TRIPLEO_ROOT=/etc/tripleo
else
TRIPLEO_ROOT=$INSTACK_ROOT/tripleo-incubator
fi
export OVERCLOUD_IP=$(nova list | grep controller0.*ctlplane | sed -e "s/.*=\\([0-9.]*\\).*/\1/")
touch ~/.ssh/known_hosts
chmod 600 ~/.ssh/known_hosts
ssh-keygen -R $OVERCLOUD_IP
export no_proxy=${no_proxy:-""}
export no_proxy=$no_proxy,$OVERCLOUD_IP
OVERCLOUD_ENDPOINT="http://$OVERCLOUD_IP:5000/v2.0/"
NEW_JSON=$(jq '.overcloud.password="'${OVERCLOUD_ADMIN_PASSWORD}'" | .overcloud.endpoint="'${OVERCLOUD_ENDPOINT}'" | .overcloud.endpointhost="'${OVERCLOUD_IP}'"' $JSONFILE)
echo $NEW_JSON > $JSONFILE
export TE_DATAFILE=$JSONFILE
source $TRIPLEO_ROOT/overcloudrc
if [ -z "$INSTACK_ROOT" ]; then
tripleo init-keystone -p $OVERCLOUD_ADMIN_PASSWORD $OVERCLOUD_ADMIN_TOKEN \
$OVERCLOUD_IP admin@example.com heat-admin@$OVERCLOUD_IP \
${SSLBASE:+--ssl $PUBLIC_API_URL}
REGISTER_SERVICE_OPTS=
else
init-keystone -o $OVERCLOUD_IP -t $OVERCLOUD_ADMIN_TOKEN \
-e admin.example.com -p $OVERCLOUD_ADMIN_PASSWORD -u heat-admin \
${SSLBASE:+-s $PUBLIC_API_URL}
# REGISTER_SERVICE_OPTS="--ceilometer-password $OVERCLOUD_CEILOMETER_PASSWORD "
REGISTER_SERVICE_OPTS=""
keystone role-create --name=swiftoperator
keystone role-create --name=ResellerAdmin
fi
tripleo setup-endpoints $OVERCLOUD_IP \
--cinder-password $OVERCLOUD_CINDER_PASSWORD \
--glance-password $OVERCLOUD_GLANCE_PASSWORD \
--heat-password $OVERCLOUD_HEAT_PASSWORD \
--neutron-password $OVERCLOUD_NEUTRON_PASSWORD \
--nova-password $OVERCLOUD_NOVA_PASSWORD \
--swift-password $OVERCLOUD_SWIFT_PASSWORD \
$REGISTER_SERVICE_OPTS \
${SSLBASE:+--ssl $PUBLIC_API_URL}
keystone role-create --name heat_stack_user
# setup-neutron "" "" 10.0.0.0/8 "" "" "" 192.0.2.45 192.0.2.64 192.0.2.0/24
NETWORK_CIDR=${NETWORK_CIDR:-"10.0.0.0/8"}
FLOATING_IP_START=${FLOATING_IP_START:-"172.17.0.45"}
FLOATING_IP_END=${FLOATING_IP_END:-"172.17.0.64"}
FLOATING_IP_CIDR=${FLOATING_IP_CIDR:-"172.17.0.0/16"}
tripleo setup-neutron "" "" $NETWORK_CIDR "" "" "" $FLOATING_IP_START $FLOATING_IP_END $FLOATING_IP_CIDR
nova flavor-delete m1.tiny
nova flavor-create m1.tiny 1 512 2 1
echo "Overcloud Deployed"