
I think we agreed we could drop nova baremetal support from tripleo-incubator once Nova removed it. This patch drops the USE_IRONIC option entirely and simply sets Ironic up to be the default baremetal provisioning service. Change-Id: Ibef2713e54955abf3fd7661e607653c18be1f395
116 lines
3.7 KiB
Bash
Executable File
116 lines
3.7 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# Copyright 2013-2014 Hewlett-Packard Development Company, L.P.
|
|
# All Rights Reserved.
|
|
#
|
|
# 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.
|
|
|
|
set -eu
|
|
set -o pipefail
|
|
|
|
SCRIPT_NAME=$(basename $0)
|
|
SCRIPT_HOME=$(dirname $0)
|
|
|
|
function show_options {
|
|
echo "Usage: $SCRIPT_NAME [options]"
|
|
echo
|
|
echo "Reads a JSON file describing machines for a baremetal cluster and"
|
|
echo "registers them all with Nova baremetal. Excess machines are removed"
|
|
echo "and flavors are created to match the machines that have been"
|
|
echo "registered using the local deploy-ramdisk and kernel, which are also"
|
|
echo "loaded into glance."
|
|
echo
|
|
echo "Options:"
|
|
echo " -h -- this help"
|
|
echo " --service-host -- nova bm service host to register nodes with"
|
|
echo " --nodes -- JSON list of nodes to register"
|
|
echo
|
|
exit $1
|
|
}
|
|
|
|
SERVICE_HOST=""
|
|
JSON_PATH=
|
|
|
|
TEMP=$(getopt -o h -l help,service-host:,nodes: -n $SCRIPT_NAME -- "$@")
|
|
if [ $? != 0 ]; then
|
|
echo "Terminating..." >&2
|
|
exit 1
|
|
fi
|
|
|
|
# Note the quotes around `$TEMP': they are essential!
|
|
eval set -- "$TEMP"
|
|
|
|
while true ; do
|
|
case "$1" in
|
|
-h | --help) show_options 0;;
|
|
--service-host) SERVICE_HOST="$2"; shift 2 ;;
|
|
--nodes) JSON_PATH="$2"; shift 2 ;;
|
|
--) shift ; break ;;
|
|
*) echo "Error: unsupported option $1." ; exit 1 ;;
|
|
esac
|
|
done
|
|
|
|
if [ -z "$SERVICE_HOST" ]; then
|
|
echo "Ironic not supported, please specify --service-host."
|
|
exit 1
|
|
fi
|
|
if [ -z "$JSON_PATH" ]; then
|
|
echo "A node list is required."
|
|
exit 1
|
|
fi
|
|
|
|
deploy_kernel=$TRIPLEO_ROOT/deploy-ramdisk-ironic.kernel
|
|
deploy_ramdisk=$TRIPLEO_ROOT/deploy-ramdisk-ironic.initramfs
|
|
if ! nova image-show bm-deploy-kernel > /dev/null ; then
|
|
deploy_kernel_id=$(glance image-create --name bm-deploy-kernel --visibility public \
|
|
--disk-format aki --container-format aki < "$deploy_kernel" | awk ' / id / {print $4}')
|
|
deploy_ramdisk_id=$(glance image-create --name bm-deploy-ramdisk --visibility public \
|
|
--disk-format ari --container-format ari < "$deploy_ramdisk" | awk ' / id / {print $4}')
|
|
fi
|
|
|
|
NODES=$(cat $JSON_PATH)
|
|
register-nodes -s $SERVICE_HOST -n <(echo $NODES) -k bm-deploy-kernel -d bm-deploy-ramdisk
|
|
|
|
function cleanup_flavor {
|
|
local FLAVOR_NAME=${1:?"cleanup_flavor requires a flavor name"}
|
|
if nova flavor-show "$FLAVOR_NAME" &> /dev/null; then
|
|
nova flavor-delete "$FLAVOR_NAME"
|
|
fi
|
|
}
|
|
|
|
# While we can't mix hypervisors, having non-baremetal flavors will just
|
|
# confuse things.
|
|
cleanup_flavor 'm1.tiny'
|
|
cleanup_flavor 'm1.small'
|
|
cleanup_flavor 'm1.medium'
|
|
cleanup_flavor 'm1.large'
|
|
cleanup_flavor 'm1.xlarge'
|
|
|
|
cleanup_flavor 'baremetal'
|
|
# XXX(lifeless) this should be a loop making sure every node is represented
|
|
# with a flavor.
|
|
MEM=$(jq -r ".[0][\"memory\"]" <<< $NODES)
|
|
DISK=$(jq -r ".[0][\"disk\"]" <<< $NODES)
|
|
CPU=$(jq -r ".[0][\"cpu\"]" <<< $NODES)
|
|
ARCH=$(jq -r ".[0][\"arch\"]" <<< $NODES)
|
|
|
|
EPHEMERAL_DISK=$(( $DISK - $ROOT_DISK ))
|
|
if (( $EPHEMERAL_DISK < 0 )); then
|
|
echo "Error: NODE_DISK - ROOT_DISK must be >= 0 to specify size of ephemeral disk"
|
|
exit 1
|
|
fi
|
|
|
|
nova flavor-create baremetal \
|
|
--ephemeral $EPHEMERAL_DISK auto $MEM $ROOT_DISK $CPU
|
|
nova flavor-key baremetal set "cpu_arch"="$ARCH"
|