64 lines
1.8 KiB
Bash
Executable File
64 lines
1.8 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
set -eux
|
|
|
|
IMAGE_PATH=${IMAGE_PATH:-"."}
|
|
|
|
export DEPLOY_NAME=${DEPLOY_NAME:-deploy-ramdisk-ironic}
|
|
export DISCOVERY_NAME=${DISCOVERY_NAME:-discovery-ramdisk}
|
|
TFTP_ROOT=${TFTP_ROOT:-/tftpboot}
|
|
|
|
command $(sudo cat /root/stackrc | xargs)
|
|
|
|
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
|
|
|
|
function check_image {
|
|
local image_name=$IMAGE_PATH/$1
|
|
|
|
if [ ! -f $image_name ]; then
|
|
echo "$image_name does not exist."
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
function load_image {
|
|
local image_name=$IMAGE_PATH/$1
|
|
|
|
tripleo load-image -d $image_name
|
|
}
|
|
|
|
check_image $DEPLOY_NAME.initramfs
|
|
check_image $DEPLOY_NAME.kernel
|
|
check_image $DISCOVERY_NAME.initramfs
|
|
check_image $DISCOVERY_NAME.kernel
|
|
check_image openstack-full.qcow2
|
|
|
|
load_image openstack-full.qcow2
|
|
|
|
glance image-delete bm-deploy-kernel 2>/dev/null || :
|
|
glance image-create --name bm-deploy-kernel --is-public true \
|
|
--disk-format aki < $IMAGE_PATH/$DEPLOY_NAME.kernel
|
|
glance image-delete bm-deploy-ramdisk 2>/dev/null || :
|
|
glance image-create --name bm-deploy-ramdisk --is-public true \
|
|
--disk-format ari < $IMAGE_PATH/$DEPLOY_NAME.initramfs
|
|
|
|
if ! nova flavor-show baremetal 2>&1 1>/dev/null; then
|
|
nova flavor-create baremetal auto 4096 40 1
|
|
fi
|
|
|
|
deploy_kernel_id=$(glance image-show bm-deploy-kernel | awk ' / id / {print $4}')
|
|
deploy_ramdisk_id=$(glance image-show bm-deploy-ramdisk | awk ' / id / {print $4}')
|
|
|
|
nova flavor-key baremetal set \
|
|
"cpu_arch"="x86_64" \
|
|
"baremetal:deploy_kernel_id"="$deploy_kernel_id" \
|
|
"baremetal:deploy_ramdisk_id"="$deploy_ramdisk_id" \
|
|
"baremetal:localboot"="true"
|
|
|
|
sudo cp -f "$IMAGE_PATH/$DISCOVERY_NAME.kernel" "$TFTP_ROOT/discovery.kernel"
|
|
sudo cp -f "$IMAGE_PATH/$DISCOVERY_NAME.initramfs" "$TFTP_ROOT/discovery.ramdisk"
|