Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- memory=2048
- vcpus=1
- disksize=40
- instancename=""
- submit=""
- nodes=""
- function usage {
- echo 'usage: gnew.sh [-m <memory>] [-c <cpus>] [-d <disk_size>] -i <instance_name>
- -m <memory> memory in MB to allocate (default 2048)
- -c <cpus> number of cpus to allocate (default 1)
- -d <disk_size> size of disk in GB to be created (default 40)
- -n <pri>:<sec> specify primary and secondary nodes to use
- -s submit as a background job (default disabled)
- -i <instance_name> name of new instance (required)
- '
- return 0;
- }
- while [ "$1" ]; do
- case $1 in
- -m)
- shift
- memory=$1
- ;;
- -c)
- shift
- vcpus=$1
- ;;
- -d)
- shift
- disksize=$1
- ;;
- -s)
- submit="--submit"
- ;;
- -i)
- shift
- instancename=$1
- ;;
- -n)
- shift
- nodes=$1
- ;;
- *)
- usage
- exit 0
- ;;
- esac
- shift
- done
- if [ "$instancename" == "" ]; then
- echo "New instance name is required"
- usage
- exit 1
- fi
- if [ "$nodes" == "" ]; then
- allocator="-I hail"
- else
- allocator="-n $nodes"
- fi
- /usr/sbin/gnt-instance add $allocator -o debootstrap+default -t drbd -s ${disksize}G \
- -B maxmem=${memory}MB,minmem=${memory}MB,vcpus=$vcpus \
- -H kvm:kernel_path="",initrd_path="",kernel_args="",boot_order=network \
- --no-name-check --no-ip-check --no-install --no-start --no-wait-for-sync $submit $instancename
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement