Skip to content

Commit

Permalink
Added tests for the number of supplied arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
beloglazov committed Jul 16, 2012
1 parent bd1d33a commit de51313
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 18 deletions.
14 changes: 11 additions & 3 deletions 10-openstack-controller/05-ssh-ubuntu-vm.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
#!/bin/sh

# SSH into an Ubuntu VM. This script accepts the IP address of the VM
# instance as a parameter.
ssh -i ../config/test.pem -l ubuntu $1
# SSH into a VM instance.

if [ $# -ne 2 ]
then
echo "You must specify two arguments:"
echo "(1) the username corresponing to the ../config/test.pem key"
echo "(2) the IP address of the VM instance"
exit 1
fi

ssh -i ../config/test.pem -l $1 $2
14 changes: 11 additions & 3 deletions 10-openstack-controller/07-nova-volume-attach.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
#!/bin/sh

# Attach the created volume to an Ubuntu VM instance as /dev/vdc. This
# script accepts a volume ID as a parameter.
nova volume-attach ubuntu $1 /dev/vdc
# Attach the created volume to a VM instance as /dev/vdc.

if [ $# -ne 2 ]
then
echo "You must specify two arguments:"
echo "(1) the name of the VM instance"
echo "(2) the ID of the volume to attach"
exit 1
fi

nova volume-attach $1 $2 /dev/vdc
File renamed without changes.
6 changes: 6 additions & 0 deletions lib/mysqlq.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
# This scripts executes an SQL query specified as a parameter using
# the MySQL connection created by the mysql.sh script

if [ $# -ne 1 ]
then
echo "You must specify one argument - an SQL query string"
exit 1
fi

echo "QUERY: "$1

DIR="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
Expand Down
35 changes: 35 additions & 0 deletions lib/prepend-license-header-sh.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/sh

# This script prepends the license header provided in the
# license-header file to the file specified as an argument if the
# header has not yet been prepended.

DIR="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
SOURCE=${DIR}/license-header-sh

TARGET_LINE1=`cat $1 | sed '1!d;q'`
TARGET_LINE2=`cat $1 | sed '2!d;q'`
TARGET_LINE3=`cat $1 | sed '3!d;q'`

SOURCE_LINE1=`cat $SOURCE | sed '1!d;q'`
SOURCE_LINE2=`cat $SOURCE | sed '2!d;q'`
SOURCE_LINE3=`cat $SOURCE | sed '3!d;q'`

echo $TARGET_LINE1
echo $TARGET_LINE2
echo $TARGET_LINE3

echo $SOURCE_LINE1
echo $SOURCE_LINE2
echo $SOURCE_LINE3

if [ $TARGET_LINE1 != $SOURCE_LINE1 -o $TARGET_LINE2 != $SOURCE_LINE2 -o $TARGET_LINE2 != $SOURCE_LINE2 ]
then
echo "not equal -> replacing"
sed -i 's/#!\/bin\/sh//g' $1

cp $1 /tmp/out
cat $SOURCE > $1
cat /tmp/out >> $1
rm -f /tmp/out
fi
12 changes: 0 additions & 12 deletions lib/prepend-license-header.sh

This file was deleted.

7 changes: 7 additions & 0 deletions lib/vmip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,12 @@
# This script returns the IP address of a VM instance by its name
# defined in libvirt. The scripts accepts a parameter specifying the
# VM instance name.

if [ $# -ne 1 ]
then
echo "You must specify one argument - the libvirt name of a VM instance"
exit 1
fi

nmap -sT -PN -T5 -p22 192.168.0.0/24 > /dev/null 2>&1
ip neighbour | grep `virsh dumpxml $1 | grep "mac address" | cut -d \' -f2` |cut -d ' ' -f1

0 comments on commit de51313

Please sign in to comment.