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
| ... | ... |
@@ -129,7 +129,7 @@ BM_FLAVOR_ARCH=${BM_FLAVOR_ARCH:-$BM_CPU_ARCH}
|
| 129 | 129 |
|
| 130 | 130 |
# Below this, we set some path and filenames. |
| 131 | 131 |
# Defaults are probably sufficient. |
| 132 |
-BM_IMAGE_BUILD_DIR=${BM_IMAGE_BUILD_DIR:-$DEST/diskimage-builder}
|
|
| 132 |
+DIB_DIR=${DIB_DIR:-$DEST/diskimage-builder}
|
|
| 133 | 133 |
|
| 134 | 134 |
# Use DIB to create deploy ramdisk and kernel. |
| 135 | 135 |
BM_BUILD_DEPLOY_RAMDISK=`trueorfalse True $BM_BUILD_DEPLOY_RAMDISK` |
| ... | ... |
@@ -165,7 +165,7 @@ function is_baremetal {
|
| 165 | 165 |
# Install diskimage-builder and shell-in-a-box |
| 166 | 166 |
# so that we can build the deployment kernel & ramdisk |
| 167 | 167 |
function prepare_baremetal_toolchain {
|
| 168 |
- git_clone $BM_IMAGE_BUILD_REPO $BM_IMAGE_BUILD_DIR $BM_IMAGE_BUILD_BRANCH |
|
| 168 |
+ git_clone $DIB_REPO $DIB_DIR $DIB_BUILD_BRANCH |
|
| 169 | 169 |
|
| 170 | 170 |
local shellinabox_basename=$(basename $BM_SHELL_IN_A_BOX) |
| 171 | 171 |
if [[ ! -e $DEST/$shellinabox_basename ]]; then |
| ... | ... |
@@ -223,7 +223,7 @@ function upload_baremetal_deploy {
|
| 223 | 223 |
BM_DEPLOY_KERNEL=bm-deploy.kernel |
| 224 | 224 |
BM_DEPLOY_RAMDISK=bm-deploy.initramfs |
| 225 | 225 |
if [ ! -e "$TOP_DIR/files/$BM_DEPLOY_KERNEL" -o ! -e "$TOP_DIR/files/$BM_DEPLOY_RAMDISK" ]; then |
| 226 |
- $BM_IMAGE_BUILD_DIR/bin/ramdisk-image-create $BM_DEPLOY_FLAVOR \ |
|
| 226 |
+ $DIB_DIR/bin/ramdisk-image-create $BM_DEPLOY_FLAVOR \ |
|
| 227 | 227 |
-o $TOP_DIR/files/bm-deploy |
| 228 | 228 |
fi |
| 229 | 229 |
fi |
| ... | ... |
@@ -271,7 +271,7 @@ function extract_and_upload_k_and_r_from_image {
|
| 271 | 271 |
image_name=$(basename "$file" ".qcow2") |
| 272 | 272 |
|
| 273 | 273 |
# this call returns the file names as "$kernel,$ramdisk" |
| 274 |
- out=$($BM_IMAGE_BUILD_DIR/bin/disk-image-get-kernel \ |
|
| 274 |
+ out=$($DIB_DIR/bin/disk-image-get-kernel \ |
|
| 275 | 275 |
-x -d $TOP_DIR/files -o bm-deploy -i $file) |
| 276 | 276 |
if [ $? -ne 0 ]; then |
| 277 | 277 |
die $LINENO "Failed to get kernel and ramdisk from $file" |
| ... | ... |
@@ -60,6 +60,19 @@ IRONIC_VM_NETWORK_RANGE=${IRONIC_VM_NETWORK_RANGE:-192.0.2.0/24}
|
| 60 | 60 |
IRONIC_VM_MACS_CSV_FILE=${IRONIC_VM_MACS_CSV_FILE:-$IRONIC_DATA_DIR/ironic_macs.csv}
|
| 61 | 61 |
IRONIC_AUTHORIZED_KEYS_FILE=${IRONIC_AUTHORIZED_KEYS_FILE:-$HOME/.ssh/authorized_keys}
|
| 62 | 62 |
|
| 63 |
+DIB_DIR=${DIB_DIR:-$DEST/diskimage-builder}
|
|
| 64 |
+ |
|
| 65 |
+# Use DIB to create deploy ramdisk and kernel. |
|
| 66 |
+IRONIC_BUILD_DEPLOY_RAMDISK=`trueorfalse True $IRONIC_BUILD_DEPLOY_RAMDISK` |
|
| 67 |
+# If not use DIB, these files are used as deploy ramdisk/kernel. |
|
| 68 |
+# (The value must be a absolute path) |
|
| 69 |
+IRONIC_DEPLOY_RAMDISK=${IRONIC_DEPLOY_RAMDISK:-}
|
|
| 70 |
+IRONIC_DEPLOY_KERNEL=${IRONIC_DEPLOY_KERNEL:-}
|
|
| 71 |
+IRONIC_DEPLOY_ELEMENT=${IRONIC_DEPLOY_ELEMENT:-deploy-ironic}
|
|
| 72 |
+ |
|
| 73 |
+#TODO(agordeev): replace 'ubuntu' with host distro name getting |
|
| 74 |
+IRONIC_DEPLOY_FLAVOR=${IRONIC_DEPLOY_FLAVOR:-ubuntu $IRONIC_DEPLOY_ELEMENT}
|
|
| 75 |
+ |
|
| 63 | 76 |
# Support entry points installation of console scripts |
| 64 | 77 |
IRONIC_BIN_DIR=$(get_python_exec_prefix) |
| 65 | 78 |
|
| ... | ... |
@@ -331,7 +344,7 @@ function enroll_vms {
|
| 331 | 331 |
|
| 332 | 332 |
# create the nova flavor |
| 333 | 333 |
nova flavor-create baremetal auto $IRONIC_VM_SPECS_RAM $IRONIC_VM_SPECS_DISK $IRONIC_VM_SPECS_CPU |
| 334 |
- 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" |
|
| 334 |
+ 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" |
|
| 335 | 335 |
|
| 336 | 336 |
# intentional sleep to make sure the tag has been set to port |
| 337 | 337 |
sleep 10 |
| ... | ... |
@@ -430,10 +443,55 @@ function configure_ironic_auxiliary {
|
| 430 | 430 |
configure_ironic_sshd |
| 431 | 431 |
} |
| 432 | 432 |
|
| 433 |
+# build deploy kernel+ramdisk, then upload them to glance |
|
| 434 |
+# this function sets IRONIC_DEPLOY_KERNEL_ID and IRONIC_DEPLOY_RAMDISK_ID |
|
| 435 |
+function upload_baremetal_ironic_deploy {
|
|
| 436 |
+ token=$1 |
|
| 437 |
+ |
|
| 438 |
+ if [ -z "$IRONIC_DEPLOY_KERNEL" -o -z "$IRONIC_DEPLOY_RAMDISK" ]; then |
|
| 439 |
+ IRONIC_DEPLOY_KERNEL_PATH=$TOP_DIR/files/ir-deploy.kernel |
|
| 440 |
+ IRONIC_DEPLOY_RAMDISK_PATH=$TOP_DIR/files/ir-deploy.initramfs |
|
| 441 |
+ else |
|
| 442 |
+ IRONIC_DEPLOY_KERNEL_PATH=$IRONIC_DEPLOY_KERNEL |
|
| 443 |
+ IRONIC_DEPLOY_RAMDISK_PATH=$IRONIC_DEPLOY_RAMDISK |
|
| 444 |
+ fi |
|
| 445 |
+ |
|
| 446 |
+ if [ ! -e "$IRONIC_DEPLOY_RAMDISK_PATH" -o ! -e "$IRONIC_DEPLOY_KERNEL_PATH" ]; then |
|
| 447 |
+ # files don't exist, need to build them |
|
| 448 |
+ if [ "$IRONIC_BUILD_DEPLOY_RAMDISK" = "True" ]; then |
|
| 449 |
+ # we can build them only if we're not offline |
|
| 450 |
+ if [ "$OFFLINE" != "True" ]; then |
|
| 451 |
+ $DIB_DIR/bin/ramdisk-image-create $IRONIC_DEPLOY_FLAVOR \ |
|
| 452 |
+ -o $TOP_DIR/files/ir-deploy |
|
| 453 |
+ else |
|
| 454 |
+ die $LINENO "Deploy kernel+ramdisk files don't exist and cannot be build in OFFLINE mode" |
|
| 455 |
+ fi |
|
| 456 |
+ else |
|
| 457 |
+ die $LINENO "Deploy kernel+ramdisk files don't exist and their building was disabled explicitly by IRONIC_BUILD_DEPLOY_RAMDISK" |
|
| 458 |
+ fi |
|
| 459 |
+ fi |
|
| 460 |
+ |
|
| 461 |
+ # load them into glance |
|
| 462 |
+ IRONIC_DEPLOY_KERNEL_ID=$(glance \ |
|
| 463 |
+ --os-auth-token $token \ |
|
| 464 |
+ --os-image-url http://$GLANCE_HOSTPORT \ |
|
| 465 |
+ image-create \ |
|
| 466 |
+ --name $(basename $IRONIC_DEPLOY_KERNEL_PATH) \ |
|
| 467 |
+ --is-public True --disk-format=aki \ |
|
| 468 |
+ < $IRONIC_DEPLOY_KERNEL_PATH | grep ' id ' | get_field 2) |
|
| 469 |
+ IRONIC_DEPLOY_RAMDISK_ID=$(glance \ |
|
| 470 |
+ --os-auth-token $token \ |
|
| 471 |
+ --os-image-url http://$GLANCE_HOSTPORT \ |
|
| 472 |
+ image-create \ |
|
| 473 |
+ --name $(basename $IRONIC_DEPLOY_RAMDISK_PATH) \ |
|
| 474 |
+ --is-public True --disk-format=ari \ |
|
| 475 |
+ < $IRONIC_DEPLOY_RAMDISK_PATH | grep ' id ' | get_field 2) |
|
| 476 |
+} |
|
| 477 |
+ |
|
| 433 | 478 |
function prepare_baremetal_basic_ops {
|
| 434 | 479 |
|
| 435 | 480 |
# install diskimage-builder |
| 436 |
- git_clone $BM_IMAGE_BUILD_REPO $BM_IMAGE_BUILD_DIR $BM_IMAGE_BUILD_BRANCH |
|
| 481 |
+ git_clone $DIB_REPO $DIB_DIR $DIB_BRANCH |
|
| 437 | 482 |
|
| 438 | 483 |
# make sure all needed service were enabled |
| 439 | 484 |
for srv in nova glance key neutron; do |
| ... | ... |
@@ -461,7 +519,7 @@ function prepare_baremetal_basic_ops {
|
| 461 | 461 |
echo_summary "Creating and uploading baremetal images for ironic" |
| 462 | 462 |
|
| 463 | 463 |
# build and upload separate deploy kernel & ramdisk |
| 464 |
- upload_baremetal_deploy $TOKEN |
|
| 464 |
+ upload_baremetal_ironic_deploy $TOKEN |
|
| 465 | 465 |
|
| 466 | 466 |
create_bridge_and_vms |
| 467 | 467 |
enroll_vms |
| ... | ... |
@@ -226,8 +226,8 @@ TEMPEST_BRANCH=${TEMPEST_BRANCH:-master}
|
| 226 | 226 |
|
| 227 | 227 |
|
| 228 | 228 |
# diskimage-builder |
| 229 |
-BM_IMAGE_BUILD_REPO=${BM_IMAGE_BUILD_REPO:-${GIT_BASE}/openstack/diskimage-builder.git}
|
|
| 230 |
-BM_IMAGE_BUILD_BRANCH=${BM_IMAGE_BUILD_BRANCH:-master}
|
|
| 229 |
+DIB_REPO=${DIB_REPO:-${GIT_BASE}/openstack/diskimage-builder.git}
|
|
| 230 |
+DIB_BRANCH=${DIB_BRANCH:-master}
|
|
| 231 | 231 |
|
| 232 | 232 |
# a websockets/html5 or flash powered VNC console for vm instances |
| 233 | 233 |
NOVNC_REPO=${NOVNC_REPO:-https://github.com/kanaka/noVNC.git}
|