Remove any lib/baremetal usage for ironic deploy
Get rid of lib/baremetal usage so that it can be simply deleted when that time comes: Copy upload_baremetal_deploy function to lib/ironic; Rename it to upload_baremetal_ironic_deploy; Remove any $BM_* variables references from lib/ironic; Rename $BM_IMAGE_BUILD_* environment variables to $DIB_*; Improve logic around deploy k&r building; Add check for $OFFLINE mode; Change-Id: I4302b32328df9156bf8738773a127db914e8edde
This commit is contained in:
parent
ad3ac5876b
commit
f177f72623
@ -129,7 +129,7 @@ BM_FLAVOR_ARCH=${BM_FLAVOR_ARCH:-$BM_CPU_ARCH}
|
|||||||
|
|
||||||
# Below this, we set some path and filenames.
|
# Below this, we set some path and filenames.
|
||||||
# Defaults are probably sufficient.
|
# Defaults are probably sufficient.
|
||||||
BM_IMAGE_BUILD_DIR=${BM_IMAGE_BUILD_DIR:-$DEST/diskimage-builder}
|
DIB_DIR=${DIB_DIR:-$DEST/diskimage-builder}
|
||||||
|
|
||||||
# Use DIB to create deploy ramdisk and kernel.
|
# Use DIB to create deploy ramdisk and kernel.
|
||||||
BM_BUILD_DEPLOY_RAMDISK=`trueorfalse True $BM_BUILD_DEPLOY_RAMDISK`
|
BM_BUILD_DEPLOY_RAMDISK=`trueorfalse True $BM_BUILD_DEPLOY_RAMDISK`
|
||||||
@ -165,7 +165,7 @@ function is_baremetal {
|
|||||||
# Install diskimage-builder and shell-in-a-box
|
# Install diskimage-builder and shell-in-a-box
|
||||||
# so that we can build the deployment kernel & ramdisk
|
# so that we can build the deployment kernel & ramdisk
|
||||||
function prepare_baremetal_toolchain {
|
function prepare_baremetal_toolchain {
|
||||||
git_clone $BM_IMAGE_BUILD_REPO $BM_IMAGE_BUILD_DIR $BM_IMAGE_BUILD_BRANCH
|
git_clone $DIB_REPO $DIB_DIR $DIB_BUILD_BRANCH
|
||||||
|
|
||||||
local shellinabox_basename=$(basename $BM_SHELL_IN_A_BOX)
|
local shellinabox_basename=$(basename $BM_SHELL_IN_A_BOX)
|
||||||
if [[ ! -e $DEST/$shellinabox_basename ]]; then
|
if [[ ! -e $DEST/$shellinabox_basename ]]; then
|
||||||
@ -223,7 +223,7 @@ function upload_baremetal_deploy {
|
|||||||
BM_DEPLOY_KERNEL=bm-deploy.kernel
|
BM_DEPLOY_KERNEL=bm-deploy.kernel
|
||||||
BM_DEPLOY_RAMDISK=bm-deploy.initramfs
|
BM_DEPLOY_RAMDISK=bm-deploy.initramfs
|
||||||
if [ ! -e "$TOP_DIR/files/$BM_DEPLOY_KERNEL" -o ! -e "$TOP_DIR/files/$BM_DEPLOY_RAMDISK" ]; then
|
if [ ! -e "$TOP_DIR/files/$BM_DEPLOY_KERNEL" -o ! -e "$TOP_DIR/files/$BM_DEPLOY_RAMDISK" ]; then
|
||||||
$BM_IMAGE_BUILD_DIR/bin/ramdisk-image-create $BM_DEPLOY_FLAVOR \
|
$DIB_DIR/bin/ramdisk-image-create $BM_DEPLOY_FLAVOR \
|
||||||
-o $TOP_DIR/files/bm-deploy
|
-o $TOP_DIR/files/bm-deploy
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@ -271,7 +271,7 @@ function extract_and_upload_k_and_r_from_image {
|
|||||||
image_name=$(basename "$file" ".qcow2")
|
image_name=$(basename "$file" ".qcow2")
|
||||||
|
|
||||||
# this call returns the file names as "$kernel,$ramdisk"
|
# this call returns the file names as "$kernel,$ramdisk"
|
||||||
out=$($BM_IMAGE_BUILD_DIR/bin/disk-image-get-kernel \
|
out=$($DIB_DIR/bin/disk-image-get-kernel \
|
||||||
-x -d $TOP_DIR/files -o bm-deploy -i $file)
|
-x -d $TOP_DIR/files -o bm-deploy -i $file)
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
die $LINENO "Failed to get kernel and ramdisk from $file"
|
die $LINENO "Failed to get kernel and ramdisk from $file"
|
||||||
|
64
lib/ironic
64
lib/ironic
@ -60,6 +60,19 @@ IRONIC_VM_NETWORK_RANGE=${IRONIC_VM_NETWORK_RANGE:-192.0.2.0/24}
|
|||||||
IRONIC_VM_MACS_CSV_FILE=${IRONIC_VM_MACS_CSV_FILE:-$IRONIC_DATA_DIR/ironic_macs.csv}
|
IRONIC_VM_MACS_CSV_FILE=${IRONIC_VM_MACS_CSV_FILE:-$IRONIC_DATA_DIR/ironic_macs.csv}
|
||||||
IRONIC_AUTHORIZED_KEYS_FILE=${IRONIC_AUTHORIZED_KEYS_FILE:-$HOME/.ssh/authorized_keys}
|
IRONIC_AUTHORIZED_KEYS_FILE=${IRONIC_AUTHORIZED_KEYS_FILE:-$HOME/.ssh/authorized_keys}
|
||||||
|
|
||||||
|
DIB_DIR=${DIB_DIR:-$DEST/diskimage-builder}
|
||||||
|
|
||||||
|
# Use DIB to create deploy ramdisk and kernel.
|
||||||
|
IRONIC_BUILD_DEPLOY_RAMDISK=`trueorfalse True $IRONIC_BUILD_DEPLOY_RAMDISK`
|
||||||
|
# If not use DIB, these files are used as deploy ramdisk/kernel.
|
||||||
|
# (The value must be a absolute path)
|
||||||
|
IRONIC_DEPLOY_RAMDISK=${IRONIC_DEPLOY_RAMDISK:-}
|
||||||
|
IRONIC_DEPLOY_KERNEL=${IRONIC_DEPLOY_KERNEL:-}
|
||||||
|
IRONIC_DEPLOY_ELEMENT=${IRONIC_DEPLOY_ELEMENT:-deploy-ironic}
|
||||||
|
|
||||||
|
#TODO(agordeev): replace 'ubuntu' with host distro name getting
|
||||||
|
IRONIC_DEPLOY_FLAVOR=${IRONIC_DEPLOY_FLAVOR:-ubuntu $IRONIC_DEPLOY_ELEMENT}
|
||||||
|
|
||||||
# Support entry points installation of console scripts
|
# Support entry points installation of console scripts
|
||||||
IRONIC_BIN_DIR=$(get_python_exec_prefix)
|
IRONIC_BIN_DIR=$(get_python_exec_prefix)
|
||||||
|
|
||||||
@ -331,7 +344,7 @@ function enroll_vms {
|
|||||||
|
|
||||||
# create the nova flavor
|
# create the nova flavor
|
||||||
nova flavor-create baremetal auto $IRONIC_VM_SPECS_RAM $IRONIC_VM_SPECS_DISK $IRONIC_VM_SPECS_CPU
|
nova flavor-create baremetal auto $IRONIC_VM_SPECS_RAM $IRONIC_VM_SPECS_DISK $IRONIC_VM_SPECS_CPU
|
||||||
nova flavor-key baremetal set "cpu_arch"="x86_64" "baremetal:deploy_kernel_id"="$BM_DEPLOY_KERNEL_ID" "baremetal:deploy_ramdisk_id"="$BM_DEPLOY_RAMDISK_ID"
|
nova flavor-key baremetal set "cpu_arch"="x86_64" "baremetal:deploy_kernel_id"="$IRONIC_DEPLOY_KERNEL_ID" "baremetal:deploy_ramdisk_id"="$IRONIC_DEPLOY_RAMDISK_ID"
|
||||||
|
|
||||||
# intentional sleep to make sure the tag has been set to port
|
# intentional sleep to make sure the tag has been set to port
|
||||||
sleep 10
|
sleep 10
|
||||||
@ -430,10 +443,55 @@ function configure_ironic_auxiliary {
|
|||||||
configure_ironic_sshd
|
configure_ironic_sshd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# build deploy kernel+ramdisk, then upload them to glance
|
||||||
|
# this function sets IRONIC_DEPLOY_KERNEL_ID and IRONIC_DEPLOY_RAMDISK_ID
|
||||||
|
function upload_baremetal_ironic_deploy {
|
||||||
|
token=$1
|
||||||
|
|
||||||
|
if [ -z "$IRONIC_DEPLOY_KERNEL" -o -z "$IRONIC_DEPLOY_RAMDISK" ]; then
|
||||||
|
IRONIC_DEPLOY_KERNEL_PATH=$TOP_DIR/files/ir-deploy.kernel
|
||||||
|
IRONIC_DEPLOY_RAMDISK_PATH=$TOP_DIR/files/ir-deploy.initramfs
|
||||||
|
else
|
||||||
|
IRONIC_DEPLOY_KERNEL_PATH=$IRONIC_DEPLOY_KERNEL
|
||||||
|
IRONIC_DEPLOY_RAMDISK_PATH=$IRONIC_DEPLOY_RAMDISK
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -e "$IRONIC_DEPLOY_RAMDISK_PATH" -o ! -e "$IRONIC_DEPLOY_KERNEL_PATH" ]; then
|
||||||
|
# files don't exist, need to build them
|
||||||
|
if [ "$IRONIC_BUILD_DEPLOY_RAMDISK" = "True" ]; then
|
||||||
|
# we can build them only if we're not offline
|
||||||
|
if [ "$OFFLINE" != "True" ]; then
|
||||||
|
$DIB_DIR/bin/ramdisk-image-create $IRONIC_DEPLOY_FLAVOR \
|
||||||
|
-o $TOP_DIR/files/ir-deploy
|
||||||
|
else
|
||||||
|
die $LINENO "Deploy kernel+ramdisk files don't exist and cannot be build in OFFLINE mode"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
die $LINENO "Deploy kernel+ramdisk files don't exist and their building was disabled explicitly by IRONIC_BUILD_DEPLOY_RAMDISK"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# load them into glance
|
||||||
|
IRONIC_DEPLOY_KERNEL_ID=$(glance \
|
||||||
|
--os-auth-token $token \
|
||||||
|
--os-image-url http://$GLANCE_HOSTPORT \
|
||||||
|
image-create \
|
||||||
|
--name $(basename $IRONIC_DEPLOY_KERNEL_PATH) \
|
||||||
|
--is-public True --disk-format=aki \
|
||||||
|
< $IRONIC_DEPLOY_KERNEL_PATH | grep ' id ' | get_field 2)
|
||||||
|
IRONIC_DEPLOY_RAMDISK_ID=$(glance \
|
||||||
|
--os-auth-token $token \
|
||||||
|
--os-image-url http://$GLANCE_HOSTPORT \
|
||||||
|
image-create \
|
||||||
|
--name $(basename $IRONIC_DEPLOY_RAMDISK_PATH) \
|
||||||
|
--is-public True --disk-format=ari \
|
||||||
|
< $IRONIC_DEPLOY_RAMDISK_PATH | grep ' id ' | get_field 2)
|
||||||
|
}
|
||||||
|
|
||||||
function prepare_baremetal_basic_ops {
|
function prepare_baremetal_basic_ops {
|
||||||
|
|
||||||
# install diskimage-builder
|
# install diskimage-builder
|
||||||
git_clone $BM_IMAGE_BUILD_REPO $BM_IMAGE_BUILD_DIR $BM_IMAGE_BUILD_BRANCH
|
git_clone $DIB_REPO $DIB_DIR $DIB_BRANCH
|
||||||
|
|
||||||
# make sure all needed service were enabled
|
# make sure all needed service were enabled
|
||||||
for srv in nova glance key neutron; do
|
for srv in nova glance key neutron; do
|
||||||
@ -461,7 +519,7 @@ function prepare_baremetal_basic_ops {
|
|||||||
echo_summary "Creating and uploading baremetal images for ironic"
|
echo_summary "Creating and uploading baremetal images for ironic"
|
||||||
|
|
||||||
# build and upload separate deploy kernel & ramdisk
|
# build and upload separate deploy kernel & ramdisk
|
||||||
upload_baremetal_deploy $TOKEN
|
upload_baremetal_ironic_deploy $TOKEN
|
||||||
|
|
||||||
create_bridge_and_vms
|
create_bridge_and_vms
|
||||||
enroll_vms
|
enroll_vms
|
||||||
|
4
stackrc
4
stackrc
@ -226,8 +226,8 @@ TEMPEST_BRANCH=${TEMPEST_BRANCH:-master}
|
|||||||
|
|
||||||
|
|
||||||
# diskimage-builder
|
# diskimage-builder
|
||||||
BM_IMAGE_BUILD_REPO=${BM_IMAGE_BUILD_REPO:-${GIT_BASE}/openstack/diskimage-builder.git}
|
DIB_REPO=${DIB_REPO:-${GIT_BASE}/openstack/diskimage-builder.git}
|
||||||
BM_IMAGE_BUILD_BRANCH=${BM_IMAGE_BUILD_BRANCH:-master}
|
DIB_BRANCH=${DIB_BRANCH:-master}
|
||||||
|
|
||||||
# a websockets/html5 or flash powered VNC console for vm instances
|
# a websockets/html5 or flash powered VNC console for vm instances
|
||||||
NOVNC_REPO=${NOVNC_REPO:-https://github.com/kanaka/noVNC.git}
|
NOVNC_REPO=${NOVNC_REPO:-https://github.com/kanaka/noVNC.git}
|
||||||
|
Loading…
Reference in New Issue
Block a user