Add script to automate the creation of a test cluster environment

This commit is contained in:
John Hua 2015-07-21 16:40:48 +08:00
parent aa3700ca4d
commit 9b7a470f2f
4 changed files with 62 additions and 1 deletions

2
.gitignore vendored
View File

@ -5,5 +5,5 @@
localrc
newrelease.yaml
models/
prepare_cluster.sh

35
add_node.sh Executable file
View File

@ -0,0 +1,35 @@
#!/bin/bash
set -x
guest_name="$1"
fuel_network="$2"
trunk_network="$3"
memory="$4"
disksize="$5"
tname="Other install media"
vm_uuid=$(xe vm-install template="$tname" new-name-label="$guest_name")
localsr=$(xe pool-list params=default-SR minimal=true)
extra_vdi=$(xe vdi-create \
name-label=xvdb \
virtual-size="${disksize}GiB" \
sr-uuid=$localsr type=user)
xe vbd-create vm-uuid=$vm_uuid vdi-uuid=$extra_vdi device=0
xe vm-memory-limits-set \
static-min=${memory}MiB \
static-max=${memory}MiB \
dynamic-min=${memory}MiB \
dynamic-max=${memory}MiB \
uuid=$vm_uuid
xe vif-create network-uuid=$(xe network-list name-label="$fuel_network" --minimal) \
vm-uuid=$vm_uuid device=0
xe vif-create network-uuid=$(xe network-list name-label="$trunk_network" --minimal) \
vm-uuid=$vm_uuid device=1
xe vm-param-set uuid=$vm_uuid HVM-boot-params:order=nd
xe vm-start vm=$vm_uuid

10
prepare_cluster.sh.sample Executable file
View File

@ -0,0 +1,10 @@
#!/bin/bash
./prepare_xs.sh "XenServer-1" "Controller" "fuel_network" "trunk_network" 2048 40
./prepare_xs.sh "XenServer-1" "Compute-1" "fuel_network" "trunk_network" 2048 40
./prepare_xs.sh "XenServer-2" "Compute-2" "fuel_network" "trunk_network" 2048 40
./prepare_xs.sh "XenServer-3" "Compute-3" "fuel_network" "trunk_network" 2048 40
./prepare_xs.sh "XenServer-4" "Compute-Storage" "vlan_19" "trunk_network" 2048 40

16
prepare_xs.sh Executable file
View File

@ -0,0 +1,16 @@
#!/bin/bash
set +x
host="$1"
name="$2"
eth0="$3"
eth1="$4"
memory="$5"
disksize="$6"
cmd="~/add_node.sh \"$name\" \"$eth0\" \"$eth1\" $memory $disksize"
scp add_node.sh root@$host:~
ssh root@$host "$cmd"
ssh root@$host "rm ~/add_node -f"