[Doc] Compute Identity Nodes Common Code +

Compute identity nodes are required for Standard Controller configuration
setups. Move their creation and removal functions to common file:

  - create_compute
  - destroy_compute

Allow also to specify the number of Compute nodes to be created.

Change-Id: I5d687b4daf16745758c65ed0d44eec5307e0f7f4
Signed-off-by: Abraham Arce <abraham.arce.moreno@intel.com>
This commit is contained in:
Abraham Arce 2018-10-30 09:32:43 -06:00
parent 787d7f1f2e
commit 1b534e77b0
3 changed files with 42 additions and 29 deletions

View File

@ -5,25 +5,14 @@ SCRIPT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}" )" )"
source ${SCRIPT_DIR}/functions.sh source ${SCRIPT_DIR}/functions.sh
CONFIGURATION="standardcontroller" CONFIGURATION="standardcontroller"
BRIDGE_INTERFACE=${BRIDGE_INTERFACE:-stxbr}
CONTROLLER=${CONTROLLER:-controller} CONTROLLER=${CONTROLLER:-controller}
COMPUTE=${COMPUTE:-compute} COMPUTE=${COMPUTE:-compute}
COMPUTE_NODES_NUMBER=${COMPUTE_NODES_NUMBER:-1}
DOMAIN_DIRECTORY=vms DOMAIN_DIRECTORY=vms
destroy_controller ${CONFIGURATION} ${CONTROLLER} destroy_controller ${CONFIGURATION} ${CONTROLLER}
for i in {0..1}; do for ((i=0; i<=$COMPUTE_NODES_NUMBER; i++)); do
COMPUTE_NODE=${COMPUTE}-${i} COMPUTE_NODE=${COMPUTE}-${i}
DOMAIN_FILE=$DOMAIN_DIRECTORY/$COMPUTE_NODE.xml destroy_compute $COMPUTE_NODE
if virsh list --all --name | grep ${COMPUTE_NODE}; then
STATUS=$(virsh list --all | grep ${COMPUTE_NODE} | awk '{ print $3}')
if ([ "$STATUS" == "running" ])
then
sudo virsh destroy ${COMPUTE_NODE}
fi
sudo virsh undefine ${COMPUTE_NODE}
delete_disk /var/lib/libvirt/images/${COMPUTE_NODE}-0.img
delete_disk /var/lib/libvirt/images/${COMPUTE_NODE}-1.img
[ -e ${DOMAIN_FILE} ] && delete_xml ${DOMAIN_FILE}
fi
done done

View File

@ -132,3 +132,39 @@ destroy_controller() {
fi fi
done done
} }
# Create a Compute node
create_compute() {
local COMPUTE_NODE=$1
local DOMAIN_FILE=${DOMAIN_DIRECTORY}/${COMPUTE_NODE}.xml
sudo qemu-img create -f qcow2 /var/lib/libvirt/images/${COMPUTE_NODE}-0.img 200G
sudo qemu-img create -f qcow2 /var/lib/libvirt/images/${COMPUTE_NODE}-1.img 200G
cp compute.xml ${DOMAIN_FILE}
sed -i -e "
s,NAME,${COMPUTE_NODE},;
s,DISK0,/var/lib/libvirt/images/${COMPUTE_NODE}-0.img,;
s,DISK1,/var/lib/libvirt/images/${COMPUTE_NODE}-1.img,
s,%BR1%,${BRIDGE_INTERFACE}1,
s,%BR2%,${BRIDGE_INTERFACE}2,
s,%BR3%,${BRIDGE_INTERFACE}3,
s,%BR4%,${BRIDGE_INTERFACE}4,
" ${DOMAIN_FILE}
sudo virsh define ${DOMAIN_FILE}
}
# Delete a Compute node
destroy_compute() {
local COMPUTE_NODE=$1
local DOMAIN_FILE=$DOMAIN_DIRECTORY/$COMPUTE_NODE.xml
if virsh list --all --name | grep ${COMPUTE_NODE}; then
STATUS=$(virsh list --all | grep ${COMPUTE_NODE} | awk '{ print $3}')
if ([ "$STATUS" == "running" ])
then
sudo virsh destroy ${COMPUTE_NODE}
fi
sudo virsh undefine ${COMPUTE_NODE}
delete_disk /var/lib/libvirt/images/${COMPUTE_NODE}-0.img
delete_disk /var/lib/libvirt/images/${COMPUTE_NODE}-1.img
[ -e ${DOMAIN_FILE} ] && delete_xml ${DOMAIN_FILE}
fi
}

View File

@ -27,6 +27,7 @@ CONFIGURATION="standardcontroller"
BRIDGE_INTERFACE=${BRIDGE_INTERFACE:-stxbr} BRIDGE_INTERFACE=${BRIDGE_INTERFACE:-stxbr}
CONTROLLER=${CONTROLLER:-controller} CONTROLLER=${CONTROLLER:-controller}
COMPUTE=${COMPUTE:-compute} COMPUTE=${COMPUTE:-compute}
COMPUTE_NODES_NUMBER=${COMPUTE_NODES_NUMBER:-1}
DOMAIN_DIRECTORY=vms DOMAIN_DIRECTORY=vms
bash ${SCRIPT_DIR}/destroy_standard_controller.sh bash ${SCRIPT_DIR}/destroy_standard_controller.sh
@ -35,22 +36,9 @@ bash ${SCRIPT_DIR}/destroy_standard_controller.sh
create_controller $CONFIGURATION $CONTROLLER $BRIDGE_INTERFACE $ISOIMAGE create_controller $CONFIGURATION $CONTROLLER $BRIDGE_INTERFACE $ISOIMAGE
for i in {0..1}; do for ((i=0; i<=$COMPUTE_NODES_NUMBER; i++)); do
COMPUTE_NODE=${COMPUTE}-${i} COMPUTE_NODE=${COMPUTE}-${i}
sudo qemu-img create -f qcow2 /var/lib/libvirt/images/${COMPUTE_NODE}-0.img 200G create_compute ${COMPUTE_NODE}
sudo qemu-img create -f qcow2 /var/lib/libvirt/images/${COMPUTE_NODE}-1.img 200G
DOMAIN_FILE=${DOMAIN_DIRECTORY}/${COMPUTE_NODE}.xml
cp ${SCRIPT_DIR}/compute.xml ${DOMAIN_FILE}
sed -i -e "
s,NAME,${COMPUTE_NODE},;
s,DISK0,/var/lib/libvirt/images/${COMPUTE_NODE}-0.img,;
s,DISK1,/var/lib/libvirt/images/${COMPUTE_NODE}-1.img,
s,%BR1%,${BRIDGE_INTERFACE}1,
s,%BR2%,${BRIDGE_INTERFACE}2,
s,%BR3%,${BRIDGE_INTERFACE}3,
s,%BR4%,${BRIDGE_INTERFACE}4,
" ${DOMAIN_FILE}
sudo virsh define ${DOMAIN_FILE}
done done
sudo virt-manager sudo virt-manager