Move the flavor creation to the integration script so it's demo'able.

This commit is contained in:
James Slagle 2015-01-21 19:51:36 -05:00
parent 48d27646eb
commit da69046185
4 changed files with 63 additions and 34 deletions

View File

@ -14,8 +14,7 @@ file_list="$HOME/.ssh/id_rsa_virt_power
$HOME/.ssh/id_rsa_virt_power.pub $HOME/.ssh/id_rsa_virt_power.pub
/tmp/deploy-virt-overcloudrc /tmp/deploy-virt-overcloudrc
$ANSWERSFILE $ANSWERSFILE
$TE_DATAFILE $TE_DATAFILE"
nodes.json"
for f in $file_list; do for f in $file_list; do
cp "$f" "$TMP_HOOKS_PATH" cp "$f" "$TMP_HOOKS_PATH"

View File

@ -24,6 +24,8 @@ function show_options () {
echo " --discover-nodes -- Perform discovery of registered nodes." echo " --discover-nodes -- Perform discovery of registered nodes."
echo " Powers on registered nodes to complete" echo " Powers on registered nodes to complete"
echo " the discovery process." echo " the discovery process."
echo " --setup-flavors -- Setup Nova flavors to match discovered"
echo " profiles"
echo " --deploy-nodes -- Deploy nodes" echo " --deploy-nodes -- Deploy nodes"
echo " -x -- enable tracing" echo " -x -- enable tracing"
echo " --help, -h -- Print this help message." echo " --help, -h -- Print this help message."
@ -31,7 +33,7 @@ function show_options () {
exit $1 exit $1
} }
TEMP=$(getopt -o ,h -l,register-nodes,nodes-json:,discover-nodes,deploy-nodes,help -o,x,h -n $SCRIPT_NAME -- "$@") TEMP=$(getopt -o ,h -l,register-nodes,nodes-json:,discover-nodes,deploy-nodes,help,setup-flavors -o,x,h -n $SCRIPT_NAME -- "$@")
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
# Note the quotes around `$TEMP': they are essential! # Note the quotes around `$TEMP': they are essential!
@ -41,6 +43,8 @@ REGISTER_NODES=
NODES_JSON= NODES_JSON=
DISCOVER_NODES= DISCOVER_NODES=
DEPLOY_NODES= DEPLOY_NODES=
SETUP_FLAVORS=
STDERR=/dev/null
while true ; do while true ; do
case "$1" in case "$1" in
@ -48,7 +52,8 @@ while true ; do
--nodes-json) NODES_JSON="$2"; shift 2;; --nodes-json) NODES_JSON="$2"; shift 2;;
--discover-nodes) DISCOVER_NODES="1"; shift 1;; --discover-nodes) DISCOVER_NODES="1"; shift 1;;
--deploy-nodes) DEPLOY_NODES="1"; shift 1;; --deploy-nodes) DEPLOY_NODES="1"; shift 1;;
-x) set -x; shift 1;; --setup-flavors) SETUP_FLAVORS="1"; shift 1;;
-x) set -x; STDERR=/dev/stderr; shift 1;;
-h | --help) show_options 0;; -h | --help) show_options 0;;
--) shift ; break ;; --) shift ; break ;;
*) echo "Error: unsupported option $1." ; exit 1 ;; *) echo "Error: unsupported option $1." ; exit 1 ;;
@ -57,8 +62,17 @@ done
function register_nodes { function register_nodes {
NODES_JSON=${NODES_JSON:-"nodes.json"} NODES_JSON=${NODES_JSON:-"nodes.json"}
NULL_STATS=${NULL_STATS:-0}
tmp_json=$NODES_JSON
if [ "$NULL_STATS" = "1" ]; then
tmp_json=$(mktemp)
jq '.nodes[].memory=null | .nodes[].disk=null | .nodes[].arch=null | .nodes[].cpu=null' $NODES_JSON > $tmp_json
fi
echo " Registering nodes from $NODES_JSON" echo " Registering nodes from $NODES_JSON"
register-nodes --service-host undercloud --nodes <(jq '.nodes' $NODES_JSON) 1>/dev/null register-nodes --service-host undercloud --nodes <(jq '.nodes' $tmp_json) 1>/dev/null
if [ "$NULL_STATS" = "1" ]; then
rm -f $tmp_json
fi
echo " Nodes registered." echo " Nodes registered."
echo echo
ironic node-list ironic node-list
@ -112,6 +126,47 @@ function deploy_nodes {
echo echo
} }
function setup_flavors {
if ! nova flavor-show baremetal_control 2>$STDERR 1>/dev/null; then
echo " Creating baremetal_control flavor ... "
nova flavor-create baremetal_control auto 2048 40 1
else
echo " baremetal_control flavor already exists."
fi
if ! nova flavor-show baremetal_compute 2>$STDERR 1>/dev/null; then
echo " Creating baremetal_compute flavor ... "
nova flavor-create baremetal_compute auto 4096 40 1
else
echo " baremetal_compute flavor already exists."
fi
deploy_kernel_id=$(glance image-show bm-deploy-kernel | awk ' / id / {print $4}')
deploy_ramdisk_id=$(glance image-show bm-deploy-ramdisk | awk ' / id / {print $4}')
echo
nova flavor-list
echo
echo " Setting baremetal_control flavor keys ... "
nova flavor-key baremetal_control set \
"cpu_arch"="x86_64" \
"baremetal:deploy_kernel_id"="$deploy_kernel_id" \
"baremetal:deploy_ramdisk_id"="$deploy_ramdisk_id" \
"baremetal:localboot"="true" \
"profile=control"
nova flavor-show baremetal_control
echo " Setting baremetal_compute flavor keys ... "
nova flavor-key baremetal_compute set \
"cpu_arch"="x86_64" \
"baremetal:deploy_kernel_id"="$deploy_kernel_id" \
"baremetal:deploy_ramdisk_id"="$deploy_ramdisk_id" \
"baremetal:localboot"="true" \
"profile=compute"
nova flavor-show baremetal_compute
}
echo "Preparing for deployment..." echo "Preparing for deployment..."
if [ "$REGISTER_NODES" = 1 ]; then if [ "$REGISTER_NODES" = 1 ]; then
@ -122,6 +177,10 @@ if [ "$DISCOVER_NODES" = 1 ]; then
discover_nodes discover_nodes
fi fi
if [ "$SETUP_FLAVORS" = 1 ]; then
setup_flavors
fi
echo "Prepared." echo "Prepared."
if [ "$DEPLOY_NODES" = 1 ]; then if [ "$DEPLOY_NODES" = 1 ]; then

View File

@ -50,14 +50,6 @@ if ! nova flavor-show baremetal 2>&1 1>/dev/null; then
nova flavor-create baremetal auto 4096 40 1 nova flavor-create baremetal auto 4096 40 1
fi fi
if ! nova flavor-show baremetal_control 2>&1 1>/dev/null; then
nova flavor-create baremetal_control auto 2048 40 1
fi
if ! nova flavor-show baremetal_compute 2>&1 1>/dev/null; then
nova flavor-create baremetal_compute auto 4096 40 1
fi
deploy_kernel_id=$(glance image-show bm-deploy-kernel | awk ' / id / {print $4}') deploy_kernel_id=$(glance image-show bm-deploy-kernel | awk ' / id / {print $4}')
deploy_ramdisk_id=$(glance image-show bm-deploy-ramdisk | awk ' / id / {print $4}') deploy_ramdisk_id=$(glance image-show bm-deploy-ramdisk | awk ' / id / {print $4}')
@ -67,19 +59,5 @@ nova flavor-key baremetal set \
"baremetal:deploy_ramdisk_id"="$deploy_ramdisk_id" \ "baremetal:deploy_ramdisk_id"="$deploy_ramdisk_id" \
"baremetal:localboot"="true" "baremetal:localboot"="true"
nova flavor-key baremetal_control set \
"cpu_arch"="x86_64" \
"baremetal:deploy_kernel_id"="$deploy_kernel_id" \
"baremetal:deploy_ramdisk_id"="$deploy_ramdisk_id" \
"baremetal:localboot"="true" \
"profile=control"
nova flavor-key baremetal_compute set \
"cpu_arch"="x86_64" \
"baremetal:deploy_kernel_id"="$deploy_kernel_id" \
"baremetal:deploy_ramdisk_id"="$deploy_ramdisk_id" \
"baremetal:localboot"="true" \
"profile=compute"
sudo cp -f "$IMAGE_PATH/$DISCOVERY_NAME.kernel" "$TFTP_ROOT/discovery.kernel" sudo cp -f "$IMAGE_PATH/$DISCOVERY_NAME.kernel" "$TFTP_ROOT/discovery.kernel"
sudo cp -f "$IMAGE_PATH/$DISCOVERY_NAME.initramfs" "$TFTP_ROOT/discovery.ramdisk" sudo cp -f "$IMAGE_PATH/$DISCOVERY_NAME.initramfs" "$TFTP_ROOT/discovery.ramdisk"

View File

@ -34,13 +34,6 @@ source $DEVTEST_VARIABLES
export TE_DATAFILE=instackenv.json export TE_DATAFILE=instackenv.json
tripleo devtest_testenv.sh $TE_DATAFILE tripleo devtest_testenv.sh $TE_DATAFILE
# Reconfigure 2 of the vm's to only have 2 GB of ram.
virsh setmem --config baremetal_2 2097152
virsh setmem --config baremetal_3 2097152
virsh setmaxmem --config baremetal_2 2097152
virsh setmaxmem --config baremetal_3 2097152
jq '.nodes[].memory=null | .nodes[].disk=null | .nodes[].arch=null | .nodes[].cpu=null' $TE_DATAFILE > nodes.json
sudo virsh undefine --remove-all-storage seed sudo virsh undefine --remove-all-storage seed
MACS=$(for i in $(seq 0 3); do echo -n $(tripleo get-vm-mac baremetal_$i)" "; done) MACS=$(for i in $(seq 0 3); do echo -n $(tripleo get-vm-mac baremetal_$i)" "; done)