generate_ssh_key() {
[ -f "$SSH_KEY" ] || ssh-keygen -f ${SSH_KEY} -N ''
- install -o jenkins -m 0600 ${SSH_KEY} /tmp/
+ install -o $USER -m 0600 ${SSH_KEY} /tmp/
}
get_base_image() {
# clean up existing nodes
for node in $(virsh list --name | grep -P '\w{3}\d{2}'); do
virsh destroy $node
- virsh undefine $node
+ done
+ for node in $(virsh list --name --all | grep -P '\w{3}\d{2}'); do
+ virsh undefine --nvram $node
done
}
create_vms() {
local -n vnodes=$1
local -n vnodes_ram=$2
+ local -n vnodes_vcpus=$3
# create vms with specified options
for node in "${vnodes[@]}"; do
- virt-install --name ${node} --ram ${vnodes_ram[$node]} --vcpus=2 --cpu host --accelerate \
+ virt-install --name ${node} --ram ${vnodes_ram[$node]} --vcpus ${vnodes_vcpus[$node]} --cpu host --accelerate \
--network network:pxe,model=virtio \
--network network:mgmt,model=virtio \
--network network:internal,model=virtio \
--disk path=$(pwd)/images/mcp_${node}.qcow2,format=qcow2,bus=virtio,cache=none,io=native \
--os-type linux --os-variant none \
--boot hd --vnc --console pty --autostart --noreboot \
- --disk path=$(pwd)/images/mcp_${node}.iso,device=cdrom
+ --disk path=$(pwd)/images/mcp_${node}.iso,device=cdrom \
+ --noautoconsole
done
}
# wait until ssh on Salt master is available
while (($attempt <= $total_attempts)); do
- ssh -i ${SSH_KEY} ubuntu@${SALT_MASTER} uptime
+ ssh ${SSH_OPTS} ubuntu@${SALT_MASTER} uptime
case $? in
0) echo "${attempt}> Success"; break ;;
*) echo "${attempt}/${total_attempts}> ssh server ain't ready yet, waiting for ${sleep_time} seconds ..." ;;