Browse code

Merge "Remove any lib/baremetal usage for ironic deploy"

Jenkins authored on 2014/03/25 05:21:21
Showing 3 changed files
... ...
@@ -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"
... ...
@@ -64,6 +64,19 @@ IRONIC_VM_NETWORK_RANGE=${IRONIC_VM_NETWORK_RANGE:-192.0.2.0/24}
64 64
 IRONIC_VM_MACS_CSV_FILE=${IRONIC_VM_MACS_CSV_FILE:-$IRONIC_DATA_DIR/ironic_macs.csv}
65 65
 IRONIC_AUTHORIZED_KEYS_FILE=${IRONIC_AUTHORIZED_KEYS_FILE:-$HOME/.ssh/authorized_keys}
66 66
 
67
+DIB_DIR=${DIB_DIR:-$DEST/diskimage-builder}
68
+
69
+# Use DIB to create deploy ramdisk and kernel.
70
+IRONIC_BUILD_DEPLOY_RAMDISK=`trueorfalse True $IRONIC_BUILD_DEPLOY_RAMDISK`
71
+# If not use DIB, these files are used as deploy ramdisk/kernel.
72
+# (The value must be a absolute path)
73
+IRONIC_DEPLOY_RAMDISK=${IRONIC_DEPLOY_RAMDISK:-}
74
+IRONIC_DEPLOY_KERNEL=${IRONIC_DEPLOY_KERNEL:-}
75
+IRONIC_DEPLOY_ELEMENT=${IRONIC_DEPLOY_ELEMENT:-deploy-ironic}
76
+
77
+#TODO(agordeev): replace 'ubuntu' with host distro name getting
78
+IRONIC_DEPLOY_FLAVOR=${IRONIC_DEPLOY_FLAVOR:-ubuntu $IRONIC_DEPLOY_ELEMENT}
79
+
67 80
 # Support entry points installation of console scripts
68 81
 IRONIC_BIN_DIR=$(get_python_exec_prefix)
69 82
 
... ...
@@ -327,7 +340,7 @@ function enroll_vms {
327 327
 
328 328
     # create the nova flavor
329 329
     nova flavor-create baremetal auto $IRONIC_VM_SPECS_RAM $IRONIC_VM_SPECS_DISK $IRONIC_VM_SPECS_CPU
330
-    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"
330
+    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"
331 331
 
332 332
     # intentional sleep to make sure the tag has been set to port
333 333
     sleep 10
... ...
@@ -426,10 +439,55 @@ function configure_ironic_auxiliary {
426 426
     configure_ironic_sshd
427 427
 }
428 428
 
429
+# build deploy kernel+ramdisk, then upload them to glance
430
+# this function sets IRONIC_DEPLOY_KERNEL_ID and IRONIC_DEPLOY_RAMDISK_ID
431
+function upload_baremetal_ironic_deploy {
432
+    token=$1
433
+
434
+    if [ -z "$IRONIC_DEPLOY_KERNEL" -o -z "$IRONIC_DEPLOY_RAMDISK" ]; then
435
+        IRONIC_DEPLOY_KERNEL_PATH=$TOP_DIR/files/ir-deploy.kernel
436
+        IRONIC_DEPLOY_RAMDISK_PATH=$TOP_DIR/files/ir-deploy.initramfs
437
+    else
438
+        IRONIC_DEPLOY_KERNEL_PATH=$IRONIC_DEPLOY_KERNEL
439
+        IRONIC_DEPLOY_RAMDISK_PATH=$IRONIC_DEPLOY_RAMDISK
440
+    fi
441
+
442
+    if [ ! -e "$IRONIC_DEPLOY_RAMDISK_PATH" -o ! -e "$IRONIC_DEPLOY_KERNEL_PATH" ]; then
443
+        # files don't exist, need to build them
444
+        if [ "$IRONIC_BUILD_DEPLOY_RAMDISK" = "True" ]; then
445
+            # we can build them only if we're not offline
446
+            if [ "$OFFLINE" != "True" ]; then
447
+                $DIB_DIR/bin/ramdisk-image-create $IRONIC_DEPLOY_FLAVOR \
448
+                    -o $TOP_DIR/files/ir-deploy
449
+            else
450
+                die $LINENO "Deploy kernel+ramdisk files don't exist and cannot be build in OFFLINE mode"
451
+            fi
452
+        else
453
+            die $LINENO "Deploy kernel+ramdisk files don't exist and their building was disabled explicitly by IRONIC_BUILD_DEPLOY_RAMDISK"
454
+        fi
455
+    fi
456
+
457
+    # load them into glance
458
+    IRONIC_DEPLOY_KERNEL_ID=$(glance \
459
+        --os-auth-token $token \
460
+        --os-image-url http://$GLANCE_HOSTPORT \
461
+        image-create \
462
+        --name $(basename $IRONIC_DEPLOY_KERNEL_PATH) \
463
+        --is-public True --disk-format=aki \
464
+        < $IRONIC_DEPLOY_KERNEL_PATH  | grep ' id ' | get_field 2)
465
+    IRONIC_DEPLOY_RAMDISK_ID=$(glance \
466
+        --os-auth-token $token \
467
+        --os-image-url http://$GLANCE_HOSTPORT \
468
+        image-create \
469
+        --name $(basename $IRONIC_DEPLOY_RAMDISK_PATH) \
470
+        --is-public True --disk-format=ari \
471
+        < $IRONIC_DEPLOY_RAMDISK_PATH  | grep ' id ' | get_field 2)
472
+}
473
+
429 474
 function prepare_baremetal_basic_ops {
430 475
 
431 476
     # install diskimage-builder
432
-    git_clone $BM_IMAGE_BUILD_REPO $BM_IMAGE_BUILD_DIR $BM_IMAGE_BUILD_BRANCH
477
+    git_clone $DIB_REPO $DIB_DIR $DIB_BRANCH
433 478
 
434 479
     # make sure all needed service were enabled
435 480
     for srv in nova glance key neutron; do
... ...
@@ -457,7 +515,7 @@ function prepare_baremetal_basic_ops {
457 457
     echo_summary "Creating and uploading baremetal images for ironic"
458 458
 
459 459
     # build and upload separate deploy kernel & ramdisk
460
-    upload_baremetal_deploy $TOKEN
460
+    upload_baremetal_ironic_deploy $TOKEN
461 461
 
462 462
     create_bridge_and_vms
463 463
     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}