New files for baremetal driver:
- lib/baremetal
- files/apts/baremetal
Adds two dependencies:
- google shell-in-a-box
- diskimage-builder
Enable by setting both:
VIRT_DRIVER=baremetal
ENABLED_SERVICES="$ENABLED_SERVICES,baremetal"
Change-Id: Ibf6fe1671a759a449c9eb0df47751d1b31ade591
0 | 9 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,403 @@ |
0 |
+# vim: tabstop=4 shiftwidth=4 softtabstop=4 |
|
1 |
+ |
|
2 |
+# Copyright (c) 2012 Hewlett-Packard Development Company, L.P. |
|
3 |
+# All Rights Reserved. |
|
4 |
+# |
|
5 |
+# Licensed under the Apache License, Version 2.0 (the "License"); you may |
|
6 |
+# not use this file except in compliance with the License. You may obtain |
|
7 |
+# a copy of the License at |
|
8 |
+# |
|
9 |
+# http://www.apache.org/licenses/LICENSE-2.0 |
|
10 |
+# |
|
11 |
+# Unless required by applicable law or agreed to in writing, software |
|
12 |
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
|
13 |
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
|
14 |
+# License for the specific language governing permissions and limitations |
|
15 |
+# under the License. |
|
16 |
+ |
|
17 |
+ |
|
18 |
+# This file provides devstack with the environment and utilities to |
|
19 |
+# control nova-compute's baremetal driver. |
|
20 |
+# It sets reasonable defaults to run within a single host, |
|
21 |
+# using virtual machines in place of physical hardware. |
|
22 |
+# However, by changing just a few options, devstack+baremetal can in fact |
|
23 |
+# control physical hardware resources on the same network, if you know |
|
24 |
+# the MAC address(es) and IPMI credentials. |
|
25 |
+# |
|
26 |
+# At a minimum, to enable the baremetal driver, you must set these in loclarc: |
|
27 |
+# VIRT_DRIVER=baremetal |
|
28 |
+# ENABLED_SERVICES="$ENABLED_SERVICES,baremetal" |
|
29 |
+# |
|
30 |
+# |
|
31 |
+# We utilize diskimage-builder to create a ramdisk, and then |
|
32 |
+# baremetal driver uses that to push a disk image onto the node(s). |
|
33 |
+# |
|
34 |
+# Below we define various defaults which control the behavior of the |
|
35 |
+# baremetal compute service, and inform it of the hardware it will contorl. |
|
36 |
+# |
|
37 |
+# Below that, various functions are defined, which are called by devstack |
|
38 |
+# in the following order: |
|
39 |
+# |
|
40 |
+# before nova-cpu starts: |
|
41 |
+# - prepare_baremetal_toolchain |
|
42 |
+# - configure_baremetal_nova_dirs |
|
43 |
+# |
|
44 |
+# after nova and glance have started: |
|
45 |
+# - build_and_upload_baremetal_deploy_k_and_r $token |
|
46 |
+# - create_baremetal_flavor $BM_DEPLOY_KERNEL_ID $BM_DEPLOY_RAMDISK_ID |
|
47 |
+# - upload_baremetal_image $url $token |
|
48 |
+# - add_baremetal_node <first_mac> <second_mac> |
|
49 |
+ |
|
50 |
+ |
|
51 |
+# Save trace setting |
|
52 |
+XTRACE=$(set +o | grep xtrace) |
|
53 |
+set +o xtrace |
|
54 |
+ |
|
55 |
+# Sub-driver settings |
|
56 |
+# ------------------- |
|
57 |
+ |
|
58 |
+# sub-driver to use for kernel deployment |
|
59 |
+# - nova.virt.baremetal.pxe.PXE |
|
60 |
+# - nova.virt.baremetal.tilera.TILERA |
|
61 |
+BM_DRIVER=${BM_DRIVER:-nova.virt.baremetal.pxe.PXE} |
|
62 |
+ |
|
63 |
+# sub-driver to use for remote power management |
|
64 |
+# - nova.virt.baremetal.fake.FakePowerManager, for manual power control |
|
65 |
+# - nova.virt.baremetal.ipmi.Ipmi, for remote IPMI |
|
66 |
+# - nova.virt.baremetal.tilera_pdu.Pdu, for TilePro hardware |
|
67 |
+BM_POWER_MANAGER=${BM_POWER_MANAGER:-nova.virt.baremetal.fake.FakePowerManager} |
|
68 |
+ |
|
69 |
+ |
|
70 |
+# These should be customized to your environment and hardware |
|
71 |
+# ----------------------------------------------------------- |
|
72 |
+ |
|
73 |
+# BM_DNSMASQ_* options must be changed to suit your network environment |
|
74 |
+BM_DNSMASQ_IFACE=${BM_DNSMASQ_IFACE:-$PUBLIC_INTERFACE} |
|
75 |
+BM_DNSMASQ_IFACE=${BM_DNSMASQ_IFACE:-eth0} |
|
76 |
+BM_DNSMASQ_RANGE=${BM_DNSMASQ_RANGE:-192.0.2.32,192.0.2.48} |
|
77 |
+ |
|
78 |
+# BM_FIRST_MAC *must* be set to the MAC address of the node you will boot. |
|
79 |
+# This is passed to dnsmasq along with the kernel/ramdisk to |
|
80 |
+# deploy via PXE. |
|
81 |
+BM_FIRST_MAC=${BM_FIRST_MAC:-} |
|
82 |
+ |
|
83 |
+# BM_SECOND_MAC is only important if the host has >1 NIC. |
|
84 |
+BM_SECOND_MAC=${BM_SECOND_MAC:-} |
|
85 |
+ |
|
86 |
+# Hostname for the baremetal nova-compute node, if not run on this host |
|
87 |
+BM_HOSTNAME=${BM_HOSTNAME:-$(hostname -f)} |
|
88 |
+ |
|
89 |
+# BM_PM_* options are only necessary if BM_POWER_MANAGER=...IPMI |
|
90 |
+BM_PM_ADDR=${BM_PM_ADDR:-0.0.0.0} |
|
91 |
+BM_PM_USER=${BM_PM_USER:-user} |
|
92 |
+BM_PM_PASS=${BM_PM_PASS:-pass} |
|
93 |
+ |
|
94 |
+# BM_FLAVOR_* options are arbitrary and not necessarily related to physical |
|
95 |
+# hardware capacity. These can be changed if you are testing |
|
96 |
+# BaremetalHostManager with multiple nodes and different flavors. |
|
97 |
+BM_CPU_ARCH=${BM_CPU_ARCH:-x86_64} |
|
98 |
+BM_FLAVOR_CPU=${BM_FLAVOR_CPU:-1} |
|
99 |
+BM_FLAVOR_RAM=${BM_FLAVOR_RAM:-1024} |
|
100 |
+BM_FLAVOR_ROOT_DISK=${BM_FLAVOR_ROOT_DISK:-10} |
|
101 |
+BM_FLAVOR_EPHEMERAL_DISK=${BM_FLAVOR_EPHEMERAL_DISK:-0} |
|
102 |
+BM_FLAVOR_SWAP=${BM_FLAVOR_SWAP:-1} |
|
103 |
+BM_FLAVOR_NAME=${BM_FLAVOR_NAME:-bm.small} |
|
104 |
+BM_FLAVOR_ID=${BM_FLAVOR_ID:-11} |
|
105 |
+BM_FLAVOR_ARCH=${BM_FLAVOR_ARCH:-$BM_CPU_ARCH} |
|
106 |
+ |
|
107 |
+ |
|
108 |
+# Below this, we set some path and filenames. |
|
109 |
+# Defaults are probably sufficient. |
|
110 |
+ |
|
111 |
+BM_IMAGE_BUILD_DIR=${BM_IMAGE_BUILD_DIR:-$DEST/diskimage-builder} |
|
112 |
+ |
|
113 |
+BM_HOST_CURRENT_KERNEL=$(uname -r) |
|
114 |
+BM_DEPLOY_RAMDISK=${BM_DEPLOY_RAMDISK:-bm-deploy-$BM_HOST_CURRENT_KERNEL-initrd} |
|
115 |
+BM_DEPLOY_KERNEL=${BM_DEPLOY_KERNEL:-bm-deploy-$BM_HOST_CURRENT_KERNEL-vmlinuz} |
|
116 |
+ |
|
117 |
+# If you need to add any extra flavors to the deploy ramdisk image |
|
118 |
+# eg, specific network drivers, specify them here |
|
119 |
+BM_DEPLOY_FLAVOR=${BM_DEPLOY_FLAVOR:-} |
|
120 |
+ |
|
121 |
+# set URL and version for google shell-in-a-box |
|
122 |
+BM_SHELL_IN_A_BOX=${BM_SHELL_IN_A_BOX:-http://shellinabox.googlecode.com/files/shellinabox-2.14.tar.gz} |
|
123 |
+ |
|
124 |
+ |
|
125 |
+# Functions |
|
126 |
+# --------- |
|
127 |
+ |
|
128 |
+# Check if baremetal is properly enabled |
|
129 |
+# Returns false if VIRT_DRIVER is not baremetal, or if ENABLED_SERVICES |
|
130 |
+# does not contain "baremetal" |
|
131 |
+function is_baremetal() { |
|
132 |
+ if [[ "$ENABLED_SERVICES" =~ 'baremetal' && "$VIRT_DRIVER" = 'baremetal' ]]; then |
|
133 |
+ return 0 |
|
134 |
+ fi |
|
135 |
+ return 1 |
|
136 |
+} |
|
137 |
+ |
|
138 |
+# Install diskimage-builder and shell-in-a-box |
|
139 |
+# so that we can build the deployment kernel & ramdisk |
|
140 |
+function prepare_baremetal_toolchain() { |
|
141 |
+ git_clone $BM_IMAGE_BUILD_REPO $BM_IMAGE_BUILD_DIR $BM_IMAGE_BUILD_BRANCH |
|
142 |
+ |
|
143 |
+ local shellinabox_basename=$(basename $BM_SHELL_IN_A_BOX) |
|
144 |
+ if [[ ! -e $DEST/$shellinabox_basename ]]; then |
|
145 |
+ cd $DEST |
|
146 |
+ wget $BM_SHELL_IN_A_BOX |
|
147 |
+ fi |
|
148 |
+ if [[ ! -d $DEST/${shellinabox_basename%%.tar.gz} ]]; then |
|
149 |
+ cd $DEST |
|
150 |
+ tar xzf $shellinabox_basename |
|
151 |
+ fi |
|
152 |
+ if [[ ! $(which shellinaboxd) ]]; then |
|
153 |
+ cd $DEST/${shellinabox_basename%%.tar.gz} |
|
154 |
+ ./configure |
|
155 |
+ make |
|
156 |
+ sudo make install |
|
157 |
+ fi |
|
158 |
+} |
|
159 |
+ |
|
160 |
+# prepare various directories needed by baremetal hypervisor |
|
161 |
+function configure_baremetal_nova_dirs() { |
|
162 |
+ # ensure /tftpboot is prepared |
|
163 |
+ sudo mkdir -p /tftpboot |
|
164 |
+ sudo mkdir -p /tftpboot/pxelinux.cfg |
|
165 |
+ sudo cp /usr/lib/syslinux/pxelinux.0 /tftpboot/ |
|
166 |
+ sudo chown -R `whoami`:libvirtd /tftpboot |
|
167 |
+ |
|
168 |
+ # ensure $NOVA_STATE_PATH/baremetal is prepared |
|
169 |
+ sudo mkdir -p $NOVA_STATE_PATH/baremetal |
|
170 |
+ sudo mkdir -p $NOVA_STATE_PATH/baremetal/console |
|
171 |
+ sudo mkdir -p $NOVA_STATE_PATH/baremetal/dnsmasq |
|
172 |
+ sudo touch $NOVA_STATE_PATH/baremetal/dnsmasq/dnsmasq-dhcp.host |
|
173 |
+ sudo chown -R `whoami` $NOVA_STATE_PATH/baremetal |
|
174 |
+ |
|
175 |
+ # ensure dnsmasq is installed but not running |
|
176 |
+ # because baremetal driver will reconfigure and restart this as needed |
|
177 |
+ if [ ! is_package_installed dnsmasq ]; then |
|
178 |
+ install_package dnsmasq |
|
179 |
+ fi |
|
180 |
+ stop_service dnsmasq |
|
181 |
+} |
|
182 |
+ |
|
183 |
+# build deploy kernel+ramdisk, then upload them to glance |
|
184 |
+# this function sets BM_DEPLOY_KERNEL_ID and BM_DEPLOY_RAMDISK_ID |
|
185 |
+function upload_baremetal_deploy() { |
|
186 |
+ token=$1 |
|
187 |
+ |
|
188 |
+ if [ ! -e $TOP_DIR/files/$BM_DEPLOY_KERNEL -a -e /boot/vmlinuz-$BM_HOST_CURRENT_KERNEL ]; then |
|
189 |
+ sudo cp /boot/vmlinuz-$BM_HOST_CURRENT_KERNEL $TOP_DIR/files/$BM_DEPLOY_KERNEL |
|
190 |
+ sudo chmod a+r $TOP_DIR/files/$BM_DEPLOY_KERNEL |
|
191 |
+ fi |
|
192 |
+ if [ ! -e $TOP_DIR/files/$BM_DEPLOY_RAMDISK ]; then |
|
193 |
+ $BM_IMAGE_BUILD_DIR/bin/ramdisk-image-create $BM_DEPLOY_FLAVOR deploy \ |
|
194 |
+ -o $TOP_DIR/files/$BM_DEPLOY_RAMDISK -k $BM_HOST_CURRENT_KERNEL |
|
195 |
+ fi |
|
196 |
+ |
|
197 |
+ # load them into glance |
|
198 |
+ BM_DEPLOY_KERNEL_ID=$(glance \ |
|
199 |
+ --os-auth-token $token \ |
|
200 |
+ --os-image-url http://$GLANCE_HOSTPORT \ |
|
201 |
+ image-create \ |
|
202 |
+ --name $BM_DEPLOY_KERNEL \ |
|
203 |
+ --public --disk-format=aki \ |
|
204 |
+ < $TOP_DIR/files/$BM_DEPLOY_KERNEL | grep ' id ' | get_field 2) |
|
205 |
+ BM_DEPLOY_RAMDISK_ID=$(glance \ |
|
206 |
+ --os-auth-token $token \ |
|
207 |
+ --os-image-url http://$GLANCE_HOSTPORT \ |
|
208 |
+ image-create \ |
|
209 |
+ --name $BM_DEPLOY_RAMDISK \ |
|
210 |
+ --public --disk-format=ari \ |
|
211 |
+ < $TOP_DIR/files/$BM_DEPLOY_RAMDISK | grep ' id ' | get_field 2) |
|
212 |
+} |
|
213 |
+ |
|
214 |
+# create a basic baremetal flavor, associated with deploy kernel & ramdisk |
|
215 |
+# |
|
216 |
+# Usage: create_baremetal_flavor <aki_uuid> <ari_uuid> |
|
217 |
+function create_baremetal_flavor() { |
|
218 |
+ aki=$1 |
|
219 |
+ ari=$2 |
|
220 |
+ nova flavor-create $BM_FLAVOR_NAME $BM_FLAVOR_ID \ |
|
221 |
+ $BM_FLAVOR_RAM $BM_FLAVOR_ROOT_DISK $BM_FLAVOR_CPU |
|
222 |
+ nova-manage instance_type set_key \ |
|
223 |
+ --name=$BM_FLAVOR_NAME --key cpu_arch --value $BM_FLAVOR_ARCH |
|
224 |
+ nova-manage instance_type set_key \ |
|
225 |
+ --name=$BM_FLAVOR_NAME --key deploy_kernel_id --value $aki |
|
226 |
+ nova-manage instance_type set_key \ |
|
227 |
+ --name=$BM_FLAVOR_NAME --key deploy_ramdisk_id --value $ari |
|
228 |
+} |
|
229 |
+ |
|
230 |
+# pull run-time kernel/ramdisk out of disk image and load into glance |
|
231 |
+# note that $file is currently expected to be in qcow2 format |
|
232 |
+# Sets KERNEL_ID and RAMDISK_ID |
|
233 |
+# |
|
234 |
+# Usage: extract_and_upload_k_and_r_from_image $token $file |
|
235 |
+function extract_and_upload_k_and_r_from_image() { |
|
236 |
+ token=$1 |
|
237 |
+ file=$2 |
|
238 |
+ image_name=$(basename "$file" ".qcow2") |
|
239 |
+ |
|
240 |
+ # this call returns the file names as "$kernel,$ramdisk" |
|
241 |
+ out=$($BM_IMAGE_BUILD_DIR/bin/disk-image-get-kernel \ |
|
242 |
+ -x -d $TOP_DIR/files -o bm-deploy -i $file) |
|
243 |
+ if [ $? -ne 0 ]; then |
|
244 |
+ die "Failed to get kernel and ramdisk from $file" |
|
245 |
+ fi |
|
246 |
+ XTRACE=$(set +o | grep xtrace) |
|
247 |
+ set +o xtrace |
|
248 |
+ out=$(echo "$out" | tail -1) |
|
249 |
+ $XTRACE |
|
250 |
+ OUT_KERNEL=${out%%,*} |
|
251 |
+ OUT_RAMDISK=${out##*,} |
|
252 |
+ |
|
253 |
+ # load them into glance |
|
254 |
+ KERNEL_ID=$(glance \ |
|
255 |
+ --os-auth-token $token \ |
|
256 |
+ --os-image-url http://$GLANCE_HOSTPORT \ |
|
257 |
+ image-create \ |
|
258 |
+ --name $image_name-kernel \ |
|
259 |
+ --public --disk-format=aki \ |
|
260 |
+ < $TOP_DIR/files/$OUT_KERNEL | grep ' id ' | get_field 2) |
|
261 |
+ RAMDISK_ID=$(glance \ |
|
262 |
+ --os-auth-token $token \ |
|
263 |
+ --os-image-url http://$GLANCE_HOSTPORT \ |
|
264 |
+ image-create \ |
|
265 |
+ --name $image_name-initrd \ |
|
266 |
+ --public --disk-format=ari \ |
|
267 |
+ < $TOP_DIR/files/$OUT_RAMDISK | grep ' id ' | get_field 2) |
|
268 |
+} |
|
269 |
+ |
|
270 |
+ |
|
271 |
+# Re-implementation of devstack's "upload_image" function |
|
272 |
+# |
|
273 |
+# Takes the same parameters, but has some peculiarities which made it |
|
274 |
+# easier to create a separate method, rather than complicate the logic |
|
275 |
+# of the existing function. |
|
276 |
+function upload_baremetal_image() { |
|
277 |
+ local image_url=$1 |
|
278 |
+ local token=$2 |
|
279 |
+ |
|
280 |
+ # Create a directory for the downloaded image tarballs. |
|
281 |
+ mkdir -p $FILES/images |
|
282 |
+ |
|
283 |
+ # Downloads the image (uec ami+aki style), then extracts it. |
|
284 |
+ IMAGE_FNAME=`basename "$image_url"` |
|
285 |
+ if [[ ! -f $FILES/$IMAGE_FNAME || \ |
|
286 |
+ "$(stat -c "%s" $FILES/$IMAGE_FNAME)" = "0" ]]; then |
|
287 |
+ wget -c $image_url -O $FILES/$IMAGE_FNAME |
|
288 |
+ if [[ $? -ne 0 ]]; then |
|
289 |
+ echo "Not found: $image_url" |
|
290 |
+ return |
|
291 |
+ fi |
|
292 |
+ fi |
|
293 |
+ |
|
294 |
+ local KERNEL="" |
|
295 |
+ local RAMDISK="" |
|
296 |
+ local DISK_FORMAT="" |
|
297 |
+ local CONTAINER_FORMAT="" |
|
298 |
+ case "$IMAGE_FNAME" in |
|
299 |
+ *.tar.gz|*.tgz) |
|
300 |
+ # Extract ami and aki files |
|
301 |
+ [ "${IMAGE_FNAME%.tar.gz}" != "$IMAGE_FNAME" ] && |
|
302 |
+ IMAGE_NAME="${IMAGE_FNAME%.tar.gz}" || |
|
303 |
+ IMAGE_NAME="${IMAGE_FNAME%.tgz}" |
|
304 |
+ xdir="$FILES/images/$IMAGE_NAME" |
|
305 |
+ rm -Rf "$xdir"; |
|
306 |
+ mkdir "$xdir" |
|
307 |
+ tar -zxf $FILES/$IMAGE_FNAME -C "$xdir" |
|
308 |
+ KERNEL=$(for f in "$xdir/"*-vmlinuz* "$xdir/"aki-*/image; do |
|
309 |
+ [ -f "$f" ] && echo "$f" && break; done; true) |
|
310 |
+ RAMDISK=$(for f in "$xdir/"*-initrd* "$xdir/"ari-*/image; do |
|
311 |
+ [ -f "$f" ] && echo "$f" && break; done; true) |
|
312 |
+ IMAGE=$(for f in "$xdir/"*.img "$xdir/"ami-*/image; do |
|
313 |
+ [ -f "$f" ] && echo "$f" && break; done; true) |
|
314 |
+ if [[ -z "$IMAGE_NAME" ]]; then |
|
315 |
+ IMAGE_NAME=$(basename "$IMAGE" ".img") |
|
316 |
+ fi |
|
317 |
+ DISK_FORMAT=ami |
|
318 |
+ CONTAINER_FORMAT=ami |
|
319 |
+ ;; |
|
320 |
+ *.qcow2) |
|
321 |
+ IMAGE="$FILES/${IMAGE_FNAME}" |
|
322 |
+ IMAGE_NAME=$(basename "$IMAGE" ".qcow2") |
|
323 |
+ DISK_FORMAT=qcow2 |
|
324 |
+ CONTAINER_FORMAT=bare |
|
325 |
+ ;; |
|
326 |
+ *) echo "Do not know what to do with $IMAGE_FNAME"; false;; |
|
327 |
+ esac |
|
328 |
+ |
|
329 |
+ if [ "$CONTAINER_FORMAT" = "bare" ]; then |
|
330 |
+ extract_and_upload_k_and_r_from_image $token $IMAGE |
|
331 |
+ elif [ "$CONTAINER_FORMAT" = "ami" ]; then |
|
332 |
+ KERNEL_ID=$(glance \ |
|
333 |
+ --os-auth-token $token \ |
|
334 |
+ --os-image-url http://$GLANCE_HOSTPORT \ |
|
335 |
+ image-create \ |
|
336 |
+ --name "$IMAGE_NAME-kernel" --public \ |
|
337 |
+ --container-format aki \ |
|
338 |
+ --disk-format aki < "$KERNEL" | grep ' id ' | get_field 2) |
|
339 |
+ RAMDISK_ID=$(glance \ |
|
340 |
+ --os-auth-token $token \ |
|
341 |
+ --os-image-url http://$GLANCE_HOSTPORT \ |
|
342 |
+ image-create \ |
|
343 |
+ --name "$IMAGE_NAME-ramdisk" --public \ |
|
344 |
+ --container-format ari \ |
|
345 |
+ --disk-format ari < "$RAMDISK" | grep ' id ' | get_field 2) |
|
346 |
+ else |
|
347 |
+ # TODO(deva): add support for other image types |
|
348 |
+ return |
|
349 |
+ fi |
|
350 |
+ |
|
351 |
+ glance \ |
|
352 |
+ --os-auth-token $token \ |
|
353 |
+ --os-image-url http://$GLANCE_HOSTPORT \ |
|
354 |
+ image-create \ |
|
355 |
+ --name "${IMAGE_NAME%.img}" --public \ |
|
356 |
+ --container-format $CONTAINER_FORMAT \ |
|
357 |
+ --disk-format $DISK_FORMAT \ |
|
358 |
+ ${KERNEL_ID:+--property kernel_id=$KERNEL_ID} \ |
|
359 |
+ ${RAMDISK_ID:+--property ramdisk_id=$RAMDISK_ID} < "${IMAGE}" |
|
360 |
+ |
|
361 |
+ # override DEFAULT_IMAGE_NAME so that tempest can find the image |
|
362 |
+ # that we just uploaded in glance |
|
363 |
+ DEFAULT_IMAGE_NAME="${IMAGE_NAME%.img}" |
|
364 |
+} |
|
365 |
+ |
|
366 |
+function clear_baremetal_of_all_nodes() { |
|
367 |
+ list=$(nova-baremetal-manage node list | tail -n +2 | awk '{print $1}' ) |
|
368 |
+ for node in $list |
|
369 |
+ do |
|
370 |
+ nova-baremetal-manage node delete $node |
|
371 |
+ done |
|
372 |
+ list=$(nova-baremetal-manage interface list | tail -n +2 | awk '{print $1}' ) |
|
373 |
+ for iface in $list |
|
374 |
+ do |
|
375 |
+ nova-baremetal-manage interface delete $iface |
|
376 |
+ done |
|
377 |
+} |
|
378 |
+ |
|
379 |
+# inform nova-baremetal about nodes, MACs, etc |
|
380 |
+# Defaults to using BM_FIRST_MAC and BM_SECOND_MAC if parameters not specified |
|
381 |
+# |
|
382 |
+# Usage: add_baremetal_node <first_mac> <second_mac> |
|
383 |
+function add_baremetal_node() { |
|
384 |
+ mac_1=${1:-$BM_FIRST_MAC} |
|
385 |
+ mac_2=${2:-$BM_SECOND_MAC} |
|
386 |
+ |
|
387 |
+ id=$(nova-baremetal-manage node create \ |
|
388 |
+ --host=$BM_HOSTNAME --prov_mac=$mac_1 \ |
|
389 |
+ --cpus=$BM_FLAVOR_CPU --memory_mb=$BM_FLAVOR_RAM \ |
|
390 |
+ --local_gb=$BM_FLAVOR_ROOT_DISK --terminal_port=0 \ |
|
391 |
+ --pm_address=$BM_PM_ADDR --pm_user=$BM_PM_USER --pm_password=$BM_PM_PASS \ |
|
392 |
+ ) |
|
393 |
+ [ $? -eq 0 ] || [ "$id" ] || die "Error adding baremetal node" |
|
394 |
+ id2=$(nova-baremetal-manage interface create \ |
|
395 |
+ --node_id=$id --mac_address=$mac_2 --datapath_id=0 --port_no=0 \ |
|
396 |
+ ) |
|
397 |
+ [ $? -eq 0 ] || [ "$id2" ] || die "Error adding interface to barmetal node $id" |
|
398 |
+} |
|
399 |
+ |
|
400 |
+ |
|
401 |
+# Restore xtrace |
|
402 |
+$XTRACE |
... | ... |
@@ -214,6 +214,11 @@ function configure_nova() { |
214 | 214 |
fi |
215 | 215 |
fi |
216 | 216 |
|
217 |
+ # Prepare directories and packages for baremetal driver |
|
218 |
+ if is_baremetal; then |
|
219 |
+ configure_baremetal_nova_dirs |
|
220 |
+ fi |
|
221 |
+ |
|
217 | 222 |
if is_service_enabled quantum && is_quantum_ovs_base_plugin "$Q_PLUGIN" && ! sudo grep -q '^cgroup_device_acl' $QEMU_CONF ; then |
218 | 223 |
# Add /dev/net/tun to cgroup_device_acls, needed for type=ethernet interfaces |
219 | 224 |
cat <<EOF | sudo tee -a $QEMU_CONF |
... | ... |
@@ -356,6 +361,10 @@ function create_nova_conf() { |
356 | 356 |
local dburl |
357 | 357 |
database_connection_url dburl nova |
358 | 358 |
add_nova_opt "sql_connection=$dburl" |
359 |
+ if is_baremetal; then |
|
360 |
+ database_connection_url dburl nova_bm |
|
361 |
+ add_nova_opt "baremetal_sql_connection=$dburl" |
|
362 |
+ fi |
|
359 | 363 |
add_nova_opt "libvirt_type=$LIBVIRT_TYPE" |
360 | 364 |
add_nova_opt "libvirt_cpu_mode=none" |
361 | 365 |
add_nova_opt "instance_name_template=${INSTANCE_NAME_PREFIX}%08x" |
... | ... |
@@ -441,12 +450,23 @@ function init_nova() { |
441 | 441 |
|
442 | 442 |
# (Re)create nova database |
443 | 443 |
$NOVA_BIN_DIR/nova-manage db sync |
444 |
+ |
|
445 |
+ # (Re)create nova baremetal database |
|
446 |
+ if is_baremetal; then |
|
447 |
+ recreate_database nova_bm latin1 |
|
448 |
+ $NOVA_BIN_DIR/nova-baremetal-manage db sync |
|
449 |
+ fi |
|
444 | 450 |
fi |
445 | 451 |
|
446 | 452 |
# Create cache dir |
447 | 453 |
sudo mkdir -p $NOVA_AUTH_CACHE_DIR |
448 | 454 |
sudo chown `whoami` $NOVA_AUTH_CACHE_DIR |
449 | 455 |
rm -f $NOVA_AUTH_CACHE_DIR/* |
456 |
+ |
|
457 |
+ # Create the keys folder |
|
458 |
+ sudo mkdir -p ${NOVA_STATE_PATH}/keys |
|
459 |
+ # make sure we own NOVA_STATE_PATH and all subdirs |
|
460 |
+ sudo chown -R `whoami` ${NOVA_STATE_PATH} |
|
450 | 461 |
} |
451 | 462 |
|
452 | 463 |
# install_novaclient() - Collect source and prepare |
... | ... |
@@ -322,6 +322,7 @@ source $TOP_DIR/lib/ceilometer |
322 | 322 |
source $TOP_DIR/lib/heat |
323 | 323 |
source $TOP_DIR/lib/quantum |
324 | 324 |
source $TOP_DIR/lib/tempest |
325 |
+source $TOP_DIR/lib/baremetal |
|
325 | 326 |
|
326 | 327 |
# Set the destination directories for OpenStack projects |
327 | 328 |
HORIZON_DIR=$DEST/horizon |
... | ... |
@@ -393,6 +394,13 @@ if [ "$VIRT_DRIVER" = 'xenserver' ]; then |
393 | 393 |
# Allow ``build_domU.sh`` to specify the flat network bridge via kernel args |
394 | 394 |
FLAT_NETWORK_BRIDGE_DEFAULT=$(grep -o 'flat_network_bridge=[[:alnum:]]*' /proc/cmdline | cut -d= -f 2 | sort -u) |
395 | 395 |
GUEST_INTERFACE_DEFAULT=eth1 |
396 |
+elif [ "$VIRT_DRIVER" = 'baremetal' ]; then |
|
397 |
+ PUBLIC_INTERFACE_DEFAULT=eth0 |
|
398 |
+ FLAT_NETWORK_BRIDGE_DEFAULT=br100 |
|
399 |
+ FLAT_INTERFACE=${FLAT_INTERFACE:-eth0} |
|
400 |
+ FORCE_DHCP_RELEASE=${FORCE_DHCP_RELEASE:-False} |
|
401 |
+ NET_MAN=${NET_MAN:-FlatManager} |
|
402 |
+ STUB_NETWORK=${STUB_NETWORK:-False} |
|
396 | 403 |
else |
397 | 404 |
PUBLIC_INTERFACE_DEFAULT=br100 |
398 | 405 |
FLAT_NETWORK_BRIDGE_DEFAULT=br100 |
... | ... |
@@ -404,6 +412,7 @@ NET_MAN=${NET_MAN:-FlatDHCPManager} |
404 | 404 |
EC2_DMZ_HOST=${EC2_DMZ_HOST:-$SERVICE_HOST} |
405 | 405 |
FLAT_NETWORK_BRIDGE=${FLAT_NETWORK_BRIDGE:-$FLAT_NETWORK_BRIDGE_DEFAULT} |
406 | 406 |
VLAN_INTERFACE=${VLAN_INTERFACE:-$GUEST_INTERFACE_DEFAULT} |
407 |
+FORCE_DHCP_RELEASE=${FORCE_DHCP_RELEASE:-True} |
|
407 | 408 |
|
408 | 409 |
# Test floating pool and range are used for testing. They are defined |
409 | 410 |
# here until the admin APIs can replace nova-manage |
... | ... |
@@ -1009,9 +1018,9 @@ if is_service_enabled n-net q-dhcp; then |
1009 | 1009 |
# Delete traces of nova networks from prior runs |
1010 | 1010 |
sudo killall dnsmasq || true |
1011 | 1011 |
clean_iptables |
1012 |
- rm -rf $NOVA_STATE_PATH/networks |
|
1013 |
- mkdir -p $NOVA_STATE_PATH/networks |
|
1014 |
- |
|
1012 |
+ rm -rf ${NOVA_STATE_PATH}/networks |
|
1013 |
+ sudo mkdir -p ${NOVA_STATE_PATH}/networks |
|
1014 |
+ sudo chown -R ${USER} ${NOVA_STATE_PATH}/networks |
|
1015 | 1015 |
# Force IP forwarding on, just on case |
1016 | 1016 |
sudo sysctl -w net.ipv4.ip_forward=1 |
1017 | 1017 |
fi |
... | ... |
@@ -1092,6 +1101,10 @@ if is_service_enabled nova; then |
1092 | 1092 |
# Need to avoid crash due to new firewall support |
1093 | 1093 |
XEN_FIREWALL_DRIVER=${XEN_FIREWALL_DRIVER:-"nova.virt.firewall.IptablesFirewallDriver"} |
1094 | 1094 |
add_nova_opt "firewall_driver=$XEN_FIREWALL_DRIVER" |
1095 |
+ |
|
1096 |
+ # OpenVZ |
|
1097 |
+ # ------ |
|
1098 |
+ |
|
1095 | 1099 |
elif [ "$VIRT_DRIVER" = 'openvz' ]; then |
1096 | 1100 |
echo_summary "Using OpenVZ virtualization driver" |
1097 | 1101 |
# TODO(deva): OpenVZ driver does not yet work if compute_driver is set here. |
... | ... |
@@ -1100,6 +1113,25 @@ if is_service_enabled nova; then |
1100 | 1100 |
add_nova_opt "connection_type=openvz" |
1101 | 1101 |
LIBVIRT_FIREWALL_DRIVER=${LIBVIRT_FIREWALL_DRIVER:-"nova.virt.libvirt.firewall.IptablesFirewallDriver"} |
1102 | 1102 |
add_nova_opt "firewall_driver=$LIBVIRT_FIREWALL_DRIVER" |
1103 |
+ |
|
1104 |
+ # Bare Metal |
|
1105 |
+ # ---------- |
|
1106 |
+ |
|
1107 |
+ elif [ "$VIRT_DRIVER" = 'baremetal' ]; then |
|
1108 |
+ echo_summary "Using BareMetal driver" |
|
1109 |
+ add_nova_opt "compute_driver=nova.virt.baremetal.driver.BareMetalDriver" |
|
1110 |
+ LIBVIRT_FIREWALL_DRIVER=${LIBVIRT_FIREWALL_DRIVER:-"nova.virt.firewall.NoopFirewallDriver"} |
|
1111 |
+ add_nova_opt "firewall_driver=$LIBVIRT_FIREWALL_DRIVER" |
|
1112 |
+ add_nova_opt "baremetal_driver=$BM_DRIVER" |
|
1113 |
+ add_nova_opt "baremetal_tftp_root=/tftpboot" |
|
1114 |
+ add_nova_opt "instance_type_extra_specs=cpu_arch:$BM_CPU_ARCH" |
|
1115 |
+ add_nova_opt "power_manager=$BM_POWER_MANAGER" |
|
1116 |
+ add_nova_opt "scheduler_host_manager=nova.scheduler.baremetal_host_manager.BaremetalHostManager" |
|
1117 |
+ add_nova_opt "scheduler_default_filters=AllHostsFilter" |
|
1118 |
+ |
|
1119 |
+ # Default |
|
1120 |
+ # ------- |
|
1121 |
+ |
|
1103 | 1122 |
else |
1104 | 1123 |
echo_summary "Using libvirt virtualization driver" |
1105 | 1124 |
add_nova_opt "compute_driver=libvirt.LibvirtDriver" |
... | ... |
@@ -1108,6 +1140,12 @@ if is_service_enabled nova; then |
1108 | 1108 |
fi |
1109 | 1109 |
fi |
1110 | 1110 |
|
1111 |
+# Extra things to prepare nova for baremetal, before nova starts |
|
1112 |
+if is_service_enabled nova && is_baremetal; then |
|
1113 |
+ echo_summary "Preparing for nova baremetal" |
|
1114 |
+ prepare_baremetal_toolchain |
|
1115 |
+ configure_baremetal_nova_dirs |
|
1116 |
+fi |
|
1111 | 1117 |
|
1112 | 1118 |
# Launch Services |
1113 | 1119 |
# =============== |
... | ... |
@@ -1227,19 +1265,56 @@ fi |
1227 | 1227 |
# * **precise**: http://uec-images.ubuntu.com/precise/current/precise-server-cloudimg-amd64.tar.gz |
1228 | 1228 |
|
1229 | 1229 |
if is_service_enabled g-reg; then |
1230 |
- echo_summary "Uploading images" |
|
1231 | 1230 |
TOKEN=$(keystone token-get | grep ' id ' | get_field 2) |
1232 | 1231 |
|
1233 |
- # Option to upload legacy ami-tty, which works with xenserver |
|
1234 |
- if [[ -n "$UPLOAD_LEGACY_TTY" ]]; then |
|
1235 |
- IMAGE_URLS="${IMAGE_URLS:+${IMAGE_URLS},}https://github.com/downloads/citrix-openstack/warehouse/tty.tgz" |
|
1236 |
- fi |
|
1232 |
+ if is_baremetal; then |
|
1233 |
+ echo_summary "Creating and uploading baremetal images" |
|
1237 | 1234 |
|
1238 |
- for image_url in ${IMAGE_URLS//,/ }; do |
|
1239 |
- upload_image $image_url $TOKEN |
|
1240 |
- done |
|
1235 |
+ # build and upload separate deploy kernel & ramdisk |
|
1236 |
+ upload_baremetal_deploy $TOKEN |
|
1237 |
+ |
|
1238 |
+ # upload images, separating out the kernel & ramdisk for PXE boot |
|
1239 |
+ for image_url in ${IMAGE_URLS//,/ }; do |
|
1240 |
+ upload_baremetal_image $image_url $TOKEN |
|
1241 |
+ done |
|
1242 |
+ else |
|
1243 |
+ echo_summary "Uploading images" |
|
1244 |
+ |
|
1245 |
+ # Option to upload legacy ami-tty, which works with xenserver |
|
1246 |
+ if [[ -n "$UPLOAD_LEGACY_TTY" ]]; then |
|
1247 |
+ IMAGE_URLS="${IMAGE_URLS:+${IMAGE_URLS},}https://github.com/downloads/citrix-openstack/warehouse/tty.tgz" |
|
1248 |
+ fi |
|
1249 |
+ |
|
1250 |
+ for image_url in ${IMAGE_URLS//,/ }; do |
|
1251 |
+ upload_image $image_url $TOKEN |
|
1252 |
+ done |
|
1253 |
+ fi |
|
1241 | 1254 |
fi |
1242 | 1255 |
|
1256 |
+# If we are running nova with baremetal driver, there are a few |
|
1257 |
+# last-mile configuration bits to attend to, which must happen |
|
1258 |
+# after n-api and n-sch have started. |
|
1259 |
+# Also, creating the baremetal flavor must happen after images |
|
1260 |
+# are loaded into glance, though just knowing the IDs is sufficient here |
|
1261 |
+if is_service_enabled nova && is_baremetal; then |
|
1262 |
+ # create special flavor for baremetal if we know what images to associate |
|
1263 |
+ [[ -n "$BM_DEPLOY_KERNEL_ID" ]] && [[ -n "$BM_DEPLOY_RAMDISK_ID" ]] && \ |
|
1264 |
+ create_baremetal_flavor $BM_DEPLOY_KERNEL_ID $BM_DEPLOY_RAMDISK_ID |
|
1265 |
+ |
|
1266 |
+ # otherwise user can manually add it later by calling nova-baremetal-manage |
|
1267 |
+ # otherwise user can manually add it later by calling nova-baremetal-manage |
|
1268 |
+ [[ -n "$BM_FIRST_MAC" ]] && add_baremetal_node |
|
1269 |
+ |
|
1270 |
+ # NOTE: we do this here to ensure that our copy of dnsmasq is running |
|
1271 |
+ sudo pkill dnsmasq || true |
|
1272 |
+ sudo dnsmasq --conf-file= --port=0 --enable-tftp --tftp-root=/tftpboot \ |
|
1273 |
+ --dhcp-boot=pxelinux.0 --bind-interfaces --pid-file=/var/run/dnsmasq.pid \ |
|
1274 |
+ --interface=$BM_DNSMASQ_IFACE --dhcp-range=$BM_DNSMASQ_RANGE |
|
1275 |
+ |
|
1276 |
+ # ensure callback daemon is running |
|
1277 |
+ sudo pkill nova-baremetal-deploy-helper || true |
|
1278 |
+ screen_it baremetal "nova-baremetal-deploy-helper" |
|
1279 |
+fi |
|
1243 | 1280 |
|
1244 | 1281 |
# Configure Tempest last to ensure that the runtime configuration of |
1245 | 1282 |
# the various OpenStack services can be queried. |
... | ... |
@@ -111,6 +111,10 @@ HEATCLIENT_BRANCH=master |
111 | 111 |
RYU_REPO=https://github.com/osrg/ryu.git |
112 | 112 |
RYU_BRANCH=master |
113 | 113 |
|
114 |
+# diskimage-builder |
|
115 |
+BM_IMAGE_BUILD_REPO=https://github.com/stackforge/diskimage-builder.git |
|
116 |
+BM_IMAGE_BUILD_BRANCH=master |
|
117 |
+ |
|
114 | 118 |
# Nova hypervisor configuration. We default to libvirt with **kvm** but will |
115 | 119 |
# drop back to **qemu** if we are unable to load the kvm module. ``stack.sh`` can |
116 | 120 |
# also install an **LXC** or **OpenVZ** based system. |