Add fake env support to baremetal

Use bm_poseur to create VM and network bridge
so that, in the absence of physical hardware,
baremetal driver still has something to manipulate.

Change-Id: Id80ede13a35e4380f358b47f08d41ff98ea9d70f
This commit is contained in:
Devananda van der Veen 2012-11-23 10:54:54 -08:00
parent c9702f9a6d
commit 7611c894b5
4 changed files with 57 additions and 5 deletions

View File

@ -71,10 +71,24 @@ BM_POWER_MANAGER=${BM_POWER_MANAGER:-nova.virt.baremetal.fake.FakePowerManager}
# These should be customized to your environment and hardware
# -----------------------------------------------------------
# BM_DNSMASQ_* options must be changed to suit your network environment
BM_DNSMASQ_IFACE=${BM_DNSMASQ_IFACE:-$PUBLIC_INTERFACE}
BM_DNSMASQ_IFACE=${BM_DNSMASQ_IFACE:-eth0}
BM_DNSMASQ_RANGE=${BM_DNSMASQ_RANGE:-192.0.2.32,192.0.2.48}
# whether to create a fake environment, eg. for devstack-gate
BM_USE_FAKE_ENV=`trueorfalse False $BM_USE_FAKE_ENV`
# Extra options to pass to bm_poseur
# change the bridge name or IP: --bridge br99 --bridge-ip 192.0.2.1
# change the virtualization type: --engine qemu
BM_POSEUR_EXTRA_OPTS=${BM_POSEUR_EXTRA_OPTS:-}
# BM_DNSMASQ_IFACE should match FLAT_NETWORK_BRIDGE
if [ "$BM_USE_FAKE_ENV" ]; then
BM_DNSMASQ_IFACE=${BM_DNSMASQ_IFACE:-br99}
BM_DNSMASQ_RANGE=${BM_DNSMASQ_RANGE:-192.0.2.32,192.0.2.48}
else
BM_DNSMASQ_IFACE=${BM_DNSMASQ_IFACE:-eth0}
# if testing on a physical network,
# BM_DNSMASQ_RANGE must be changed to suit your network
BM_DNSMASQ_RANGE=${BM_DNSMASQ_RANGE:-}
fi
# BM_FIRST_MAC *must* be set to the MAC address of the node you will boot.
# This is passed to dnsmasq along with the kernel/ramdisk to
@ -108,8 +122,8 @@ BM_FLAVOR_ARCH=${BM_FLAVOR_ARCH:-$BM_CPU_ARCH}
# Below this, we set some path and filenames.
# Defaults are probably sufficient.
BM_IMAGE_BUILD_DIR=${BM_IMAGE_BUILD_DIR:-$DEST/diskimage-builder}
BM_POSEUR_DIR=${BM_POSEUR_DIR:-$DEST/bm_poseur}
BM_HOST_CURRENT_KERNEL=$(uname -r)
BM_DEPLOY_RAMDISK=${BM_DEPLOY_RAMDISK:-bm-deploy-$BM_HOST_CURRENT_KERNEL-initrd}
@ -140,6 +154,7 @@ function is_baremetal() {
# so that we can build the deployment kernel & ramdisk
function prepare_baremetal_toolchain() {
git_clone $BM_IMAGE_BUILD_REPO $BM_IMAGE_BUILD_DIR $BM_IMAGE_BUILD_BRANCH
git_clone $BM_POSEUR_REPO $BM_POSEUR_DIR $BM_POSEUR_BRANCH
local shellinabox_basename=$(basename $BM_SHELL_IN_A_BOX)
if [[ ! -e $DEST/$shellinabox_basename ]]; then
@ -158,6 +173,27 @@ function prepare_baremetal_toolchain() {
fi
}
# set up virtualized environment for devstack-gate testing
function create_fake_baremetal_env() {
local bm_poseur="$BM_POSEUR_DIR/bm_poseur"
# TODO(deva): add support for >1 VM
sudo $bm_poseur $BM_POSEUR_EXTRA_OPTS create-bridge
sudo $bm_poseur $BM_POSEUR_EXTRA_OPTS create-vm
BM_FIRST_MAC=$(sudo $bm_poseur get-macs)
# NOTE: there is currently a limitation in baremetal driver
# that requires second MAC even if it is not used.
# Passing a fake value allows this to work.
# TODO(deva): remove this after driver issue is fixed.
BM_SECOND_MAC='12:34:56:78:90:12'
}
function cleanup_fake_baremetal_env() {
local bm_poseur="$BM_POSEUR_DIR/bm_poseur"
sudo $bm_poseur $BM_POSEUR_EXTRA_OPTS destroy-vm
sudo $bm_poseur $BM_POSEUR_EXTRA_OPTS destroy-bridge
}
# prepare various directories needed by baremetal hypervisor
function configure_baremetal_nova_dirs() {
# ensure /tftpboot is prepared

View File

@ -1145,6 +1145,9 @@ if is_service_enabled nova && is_baremetal; then
echo_summary "Preparing for nova baremetal"
prepare_baremetal_toolchain
configure_baremetal_nova_dirs
if [[ "$BM_USE_FAKE_ENV" = "True" ]]; then
create_fake_baremetal_env
fi
fi
# Launch Services

View File

@ -115,6 +115,13 @@ RYU_BRANCH=master
BM_IMAGE_BUILD_REPO=https://github.com/stackforge/diskimage-builder.git
BM_IMAGE_BUILD_BRANCH=master
# bm_poseur
# Used to simulate a hardware environment for baremetal
# Only used if BM_USE_FAKE_ENV is set
BM_POSEUR_REPO=https://github.com/tripleo/bm_poseur.git
BM_POSEUR_BRANCH=master
# Nova hypervisor configuration. We default to libvirt with **kvm** but will
# drop back to **qemu** if we are unable to load the kvm module. ``stack.sh`` can
# also install an **LXC** or **OpenVZ** based system.

View File

@ -25,6 +25,7 @@ source $TOP_DIR/stackrc
DATA_DIR=${DATA_DIR:-${DEST}/data}
# Get project function libraries
source $TOP_DIR/lib/baremetal
source $TOP_DIR/lib/cinder
source $TOP_DIR/lib/horizon
source $TOP_DIR/lib/swift
@ -67,6 +68,11 @@ if is_service_enabled tls-proxy; then
killall stud
fi
# baremetal might have created a fake environment
if is_service_enabled baremetal && [[ "$BM_USE_FAKE_ENV" = "True" ]]; then
cleanup_fake_baremetal_env
fi
SCSI_PERSIST_DIR=$CINDER_STATE_PATH/volumes/*
# Get the iSCSI volumes