DevStack: Add support for deploying nodes with pxe_ipmitool

This patch is adding support for deploying nodes with the pxe_ipmitool
driver and VMs.

The patch adds a dependency on the "virtualbmc" utility which is
responsible for creating a virtual/fake BMC that handles the IPMI
commands (using pyghmi.bmc) and convert it to calls to the
python-libvirt library.

The function "is_ironic_hardware" was converted into a variable called
"IRONIC_IS_HARDWARE" which can be set to True/False to indicate whether
DevStack is being setup for baremetal or VMs.

Partial-Bug: #1544642
Change-Id: I5edc51c7fc8b6f0bb7fe4ca129596709a32eb93e
This commit is contained in:
Lucas Alvares Gomes 2016-02-15 12:33:19 +00:00
parent a70b5365d3
commit 7ffa1d58ce
5 changed files with 78 additions and 23 deletions

View File

@ -19,3 +19,4 @@ syslinux
tftpd-hpa tftpd-hpa
xinetd xinetd
squashfs-tools squashfs-tools
libvirt-dev

View File

@ -14,3 +14,4 @@ syslinux
tftp-server tftp-server
xinetd xinetd
squashfs-tools squashfs-tools
libvirt-devel

View File

@ -129,6 +129,15 @@ IRONIC_HTTP_DIR=${IRONIC_HTTP_DIR:-$IRONIC_DATA_DIR/httpboot}
IRONIC_HTTP_SERVER=${IRONIC_HTTP_SERVER:-$HOST_IP} IRONIC_HTTP_SERVER=${IRONIC_HTTP_SERVER:-$HOST_IP}
IRONIC_HTTP_PORT=${IRONIC_HTTP_PORT:-8088} IRONIC_HTTP_PORT=${IRONIC_HTTP_PORT:-8088}
# Whether DevStack will be setup for bare metal or VMs
IRONIC_IS_HARDWARE=$(trueorfalse False IRONIC_IS_HARDWARE)
# The first port in the range to bind the Virtual BMCs. The number of
# ports that will be used depends on $IRONIC_VM_COUNT variable, e.g if
# $IRONIC_VM_COUNT=3 the ports 6230, 6231 and 6232 will be used for the
# Virtual BMCs, one for each VM.
IRONIC_VBMC_PORT_RANGE_START=${IRONIC_VBMC_PORT_RANGE_START:-6230}
# NOTE(lucasagomes): This flag is used to differentiate the nodes that # NOTE(lucasagomes): This flag is used to differentiate the nodes that
# uses IPA as their deploy ramdisk from nodes that uses the agent_* drivers # uses IPA as their deploy ramdisk from nodes that uses the agent_* drivers
# (which also uses IPA but depends on Swift Temp URLs to work). At present, # (which also uses IPA but depends on Swift Temp URLs to work). At present,
@ -173,13 +182,13 @@ function is_ironic_enabled {
return 1 return 1
} }
function is_ironic_hardware { function is_deployed_by_agent {
is_ironic_enabled && [[ -n "${IRONIC_DEPLOY_DRIVER##*_ssh}" ]] && return 0 [[ -z "${IRONIC_DEPLOY_DRIVER%%agent*}" ]] && return 0
return 1 return 1
} }
function is_deployed_by_agent { function is_deployed_by_ipmitool {
[[ -z "${IRONIC_DEPLOY_DRIVER%%agent*}" ]] && return 0 [[ -z "${IRONIC_DEPLOY_DRIVER##*_ipmitool}" ]] && return 0
return 1 return 1
} }
@ -211,6 +220,10 @@ function install_ironic {
if [[ "$IRONIC_IPXE_ENABLED" == "True" ]] ; then if [[ "$IRONIC_IPXE_ENABLED" == "True" ]] ; then
install_apache_wsgi install_apache_wsgi
fi fi
if is_deployed_by_ipmitool && [[ "$IRONIC_IS_HARDWARE" == "False" ]]; then
pip_install "virtualbmc"
fi
} }
# install_ironicclient() - Collect sources and prepare # install_ironicclient() - Collect sources and prepare
@ -366,12 +379,17 @@ function configure_ironic_conductor {
pxe_params+=" systemd.journald.forward_to_console=yes" pxe_params+=" systemd.journald.forward_to_console=yes"
fi fi
fi fi
# When booting with less than 1GB, we need to switch from default tmpfs # When booting with less than 1GB, we need to switch from default tmpfs
# to ramfs for ramdisks to decompress successfully. # to ramfs for ramdisks to decompress successfully.
if (is_ironic_hardware && [[ "$IRONIC_HW_NODE_RAM" -lt 1024 ]]) || if ([[ "$IRONIC_IS_HARDWARE" == "True" ]] &&
(! is_ironic_hardware && [[ "$IRONIC_VM_SPECS_RAM" -lt 1024 ]]); then [[ "$IRONIC_HW_NODE_RAM" -lt 1024 ]]) ||
([[ "$IRONIC_IS_HARDWARE" == "False" ]] &&
[[ "$IRONIC_VM_SPECS_RAM" -lt 1024 ]]); then
pxe_params+=" rootfstype=ramfs" pxe_params+=" rootfstype=ramfs"
fi fi
if [[ -n "$pxe_params" ]]; then if [[ -n "$pxe_params" ]]; then
iniset $IRONIC_CONF_FILE pxe pxe_append_params "$pxe_params" iniset $IRONIC_CONF_FILE pxe pxe_append_params "$pxe_params"
fi fi
@ -591,12 +609,15 @@ function create_bridge_and_vms {
else else
local log_arg="" local log_arg=""
fi fi
local vbmc_port=$IRONIC_VBMC_PORT_RANGE_START
local vm_name local vm_name
for vm_name in $(_ironic_bm_vm_names); do for vm_name in $(_ironic_bm_vm_names); do
sudo su $STACK_USER -c "$IRONIC_SCRIPTS_DIR/create-node.sh $vm_name \ sudo su $STACK_USER -c "$IRONIC_SCRIPTS_DIR/create-node.sh $vm_name \
$IRONIC_VM_SPECS_CPU $IRONIC_VM_SPECS_RAM $IRONIC_VM_SPECS_DISK \ $IRONIC_VM_SPECS_CPU $IRONIC_VM_SPECS_RAM $IRONIC_VM_SPECS_DISK \
amd64 $IRONIC_VM_NETWORK_BRIDGE $IRONIC_VM_EMULATOR \ amd64 $IRONIC_VM_NETWORK_BRIDGE $IRONIC_VM_EMULATOR \
$log_arg" >> $IRONIC_VM_MACS_CSV_FILE $vbmc_port $log_arg" >> $IRONIC_VM_MACS_CSV_FILE
vbmc_port=$((vbmc_port+1))
done done
create_ovs_taps create_ovs_taps
} }
@ -632,21 +653,32 @@ function enroll_nodes {
local chassis_id local chassis_id
chassis_id=$(ironic chassis-create -d "ironic test chassis" | grep " uuid " | get_field 2) chassis_id=$(ironic chassis-create -d "ironic test chassis" | grep " uuid " | get_field 2)
if ! is_ironic_hardware; then if [[ "$IRONIC_IS_HARDWARE" == "False" ]]; then
local ironic_node_cpu=$IRONIC_VM_SPECS_CPU local ironic_node_cpu=$IRONIC_VM_SPECS_CPU
local ironic_node_ram=$IRONIC_VM_SPECS_RAM local ironic_node_ram=$IRONIC_VM_SPECS_RAM
local ironic_node_disk=$IRONIC_VM_SPECS_DISK local ironic_node_disk=$IRONIC_VM_SPECS_DISK
local ironic_ephemeral_disk=$IRONIC_VM_EPHEMERAL_DISK local ironic_ephemeral_disk=$IRONIC_VM_EPHEMERAL_DISK
local ironic_node_arch=x86_64 local ironic_node_arch=x86_64
local ironic_hwinfo_file=$IRONIC_VM_MACS_CSV_FILE local ironic_hwinfo_file=$IRONIC_VM_MACS_CSV_FILE
local node_options="\
-i deploy_kernel=$IRONIC_DEPLOY_KERNEL_ID \ if is_deployed_by_ipmitool; then
-i deploy_ramdisk=$IRONIC_DEPLOY_RAMDISK_ID \ local node_options="\
-i ssh_virt_type=$IRONIC_SSH_VIRT_TYPE \ -i deploy_kernel=$IRONIC_DEPLOY_KERNEL_ID \
-i ssh_address=$IRONIC_VM_SSH_ADDRESS \ -i deploy_ramdisk=$IRONIC_DEPLOY_RAMDISK_ID \
-i ssh_port=$IRONIC_VM_SSH_PORT \ -i ipmi_address=127.0.0.1 \
-i ssh_username=$IRONIC_SSH_USERNAME \ -i ipmi_username=admin \
-i ssh_key_filename=$IRONIC_KEY_FILE" -i ipmi_password=password"
else
local node_options="\
-i deploy_kernel=$IRONIC_DEPLOY_KERNEL_ID \
-i deploy_ramdisk=$IRONIC_DEPLOY_RAMDISK_ID \
-i ssh_virt_type=$IRONIC_SSH_VIRT_TYPE \
-i ssh_address=$IRONIC_VM_SSH_ADDRESS \
-i ssh_port=$IRONIC_VM_SSH_PORT \
-i ssh_username=$IRONIC_SSH_USERNAME \
-i ssh_key_filename=$IRONIC_KEY_FILE"
fi
else else
local ironic_node_cpu=$IRONIC_HW_NODE_CPU local ironic_node_cpu=$IRONIC_HW_NODE_CPU
local ironic_node_ram=$IRONIC_HW_NODE_RAM local ironic_node_ram=$IRONIC_HW_NODE_RAM
@ -661,9 +693,17 @@ function enroll_nodes {
local total_nodes=0 local total_nodes=0
local total_cpus=0 local total_cpus=0
while read hardware_info; do while read hardware_info; do
if ! is_ironic_hardware; then if [[ "$IRONIC_IS_HARDWARE" == "False" ]]; then
local mac_address=$hardware_info local mac_address
elif [[ -z "${IRONIC_DEPLOY_DRIVER##*_ipmitool}" ]]; then mac_address=$(echo $hardware_info | awk '{print $1}')
if is_deployed_by_ipmitool; then
local vbmc_port
vbmc_port=$(echo $hardware_info | awk '{print $2}')
node_options+=" -i ipmi_port=$vbmc_port"
fi
elif is_deployed_by_ipmitool; then
local ipmi_address local ipmi_address
ipmi_address=$(echo $hardware_info |awk '{print $1}') ipmi_address=$(echo $hardware_info |awk '{print $1}')
local mac_address local mac_address
@ -896,11 +936,11 @@ function prepare_baremetal_basic_ops {
return 0 return 0
fi fi
if ! is_ironic_hardware; then if [[ "$IRONIC_IS_HARDWARE" == "False" ]]; then
configure_ironic_auxiliary configure_ironic_auxiliary
fi fi
upload_baremetal_ironic_deploy upload_baremetal_ironic_deploy
if ! is_ironic_hardware; then if [[ "$IRONIC_IS_HARDWARE" == "False" ]]; then
create_bridge_and_vms create_bridge_and_vms
fi fi
enroll_nodes enroll_nodes

View File

@ -19,6 +19,11 @@ VOL_NAME="$NAME.qcow2"
virsh list | grep -q $NAME && virsh destroy $NAME virsh list | grep -q $NAME && virsh destroy $NAME
virsh list --inactive | grep -q $NAME && virsh undefine $NAME virsh list --inactive | grep -q $NAME && virsh undefine $NAME
# Delete the Virtual BMC
if [[ $(type -P vbmc) != "" ]]; then
vbmc list | grep -a $NAME && vbmc delete $NAME
fi
if virsh pool-list | grep -q $LIBVIRT_STORAGE_POOL ; then if virsh pool-list | grep -q $LIBVIRT_STORAGE_POOL ; then
virsh vol-list $LIBVIRT_STORAGE_POOL | grep -q $VOL_NAME && virsh vol-list $LIBVIRT_STORAGE_POOL | grep -q $VOL_NAME &&
virsh vol-delete $VOL_NAME --pool $LIBVIRT_STORAGE_POOL virsh vol-delete $VOL_NAME --pool $LIBVIRT_STORAGE_POOL

View File

@ -24,7 +24,8 @@ esac
BRIDGE=$6 BRIDGE=$6
EMULATOR=$7 EMULATOR=$7
LOGDIR=$8 VBMC_PORT=$8
LOGDIR=$9
LIBVIRT_NIC_DRIVER=${LIBVIRT_NIC_DRIVER:-"e1000"} LIBVIRT_NIC_DRIVER=${LIBVIRT_NIC_DRIVER:-"e1000"}
LIBVIRT_STORAGE_POOL=${LIBVIRT_STORAGE_POOL:-"default"} LIBVIRT_STORAGE_POOL=${LIBVIRT_STORAGE_POOL:-"default"}
@ -72,7 +73,14 @@ if ! virsh list --all | grep -q $NAME; then
--bootdev network --name $NAME --image "$volume_path" \ --bootdev network --name $NAME --image "$volume_path" \
--arch $ARCH --cpus $CPU --memory $MEM --libvirt-nic-driver $LIBVIRT_NIC_DRIVER \ --arch $ARCH --cpus $CPU --memory $MEM --libvirt-nic-driver $LIBVIRT_NIC_DRIVER \
--emulator $EMULATOR --network $BRIDGE $VM_LOGGING >&2 --emulator $EMULATOR --network $BRIDGE $VM_LOGGING >&2
# Createa Virtual BMC for the node if IPMI is used
if [[ $(type -P vbmc) != "" ]]; then
vbmc add $NAME --port $VBMC_PORT
vbmc start $NAME
fi
fi fi
# echo mac # echo mac
virsh dumpxml $NAME | grep "mac address" | head -1 | cut -d\' -f2 VM_MAC=$(virsh dumpxml $NAME | grep "mac address" | head -1 | cut -d\' -f2)
echo $VM_MAC $VBMC_PORT