make cloud-install-sys-tmplt work without db.properties file

this allows developer setup secondary storage from their development environment
This commit is contained in:
frank 2012-06-20 11:08:33 -07:00
parent a2d49bef69
commit 27265597bf

View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# $Id: installrtng.sh 11251 2010-07-23 23:40:44Z abhishek $ $HeadURL: svn://svn.lab.vmops.com/repos/vmdev/java/scripts/storage/secondary/installrtng.sh $ # $Id: installrtng.sh 11251 2010-07-23 23:40:44Z abhishek $ $HeadURL: svn://svn.lab.vmops.com/repos/vmdev/java/scripts/storage/secondary/installrtng.sh $
usage() { usage() {
printf "Usage: %s: -m <secondary storage mount point> -f <system vm template file> [-h <hypervisor name: kvm|vmware|xenserver> ] [ -s <mgmt server secret key, if you specified any when running cloud-setup-database, default is password>][-u <Url to system vm template>] [-F <clean up system templates of specified hypervisor>] [-e <Template suffix, e.g vhd, ova, qcow2>]\n" $(basename $0) >&2 printf "Usage: %s: -m <secondary storage mount point> -f <system vm template file> [-h <hypervisor name: kvm|vmware|xenserver> ] [ -s <mgmt server secret key, if you specified any when running cloud-setup-database, default is password>][-u <Url to system vm template>] [-F <clean up system templates of specified hypervisor>] [-e <Template suffix, e.g vhd, ova, qcow2>] [-o <Database server hostname or ip, e.g localhost>] [-r <Database user name, e.g root>] [-d <Database password. Fllowed by nothing if the password is empty>]\n" $(basename $0) >&2
printf "or\n" >&2 printf "or\n" >&2
printf "%s: -m <secondary storage mount point> -u <http url for system vm template> [-h <hypervisor name: kvm|vmware|xenserver> ] [ -s <mgmt server secret key>]\n" $(basename $0) >&2 printf "%s: -m <secondary storage mount point> -u <http url for system vm template> [-h <hypervisor name: kvm|vmware|xenserver> ] [ -s <mgmt server secret key>]\n" $(basename $0) >&2
} }
@ -18,7 +18,10 @@ templateId=1
hyper= hyper=
msKey=password msKey=password
DISKSPACE=5120000 #free disk space required in kilobytes DISKSPACE=5120000 #free disk space required in kilobytes
while getopts 'm:h:f:u:Ft:e:s:' OPTION dbHost=
dbUser=
dbPassword=
while getopts 'm:h:f:u:Ft:e:s:o:r:d' OPTION
do do
case $OPTION in case $OPTION in
m) mflag=1 m) mflag=1
@ -40,6 +43,15 @@ do
s) sflag=1 s) sflag=1
msKey="$OPTARG" msKey="$OPTARG"
;; ;;
o) oflag=1
dbHost="$OPTARG"
;;
r) rflag=1
dbUser="$OPTARG"
;;
d) dflag=1
dbPassword="$OPTARG"
;;
?) usage ?) usage
failed 2 failed 2
;; ;;
@ -70,8 +82,15 @@ then
failed 3 failed 3
fi fi
if [ "$oflag" != 1 ]; then
dbHost=$(sed '/^\#/d' /etc/cloud/management/db.properties | grep 'db.cloud.host' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//') dbHost=$(sed '/^\#/d' /etc/cloud/management/db.properties | grep 'db.cloud.host' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
fi
if [ "$rflag" != 1]; then
dbUser=$(sed '/^\#/d' /etc/cloud/management/db.properties | grep 'db.cloud.username' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//') dbUser=$(sed '/^\#/d' /etc/cloud/management/db.properties | grep 'db.cloud.username' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
fi
if [ -f /etc/cloud/management/db.properties ]; then
encType=$(sed '/^\#/d' /etc/cloud/management/db.properties | grep 'db.cloud.encryption.type' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//') encType=$(sed '/^\#/d' /etc/cloud/management/db.properties | grep 'db.cloud.encryption.type' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
if [ "$encType" == "file" ] if [ "$encType" == "file" ]
then then
@ -84,6 +103,7 @@ then
failed 9 failed 9
fi fi
fi fi
fi
if [[ "$encType" == "file" || "$encType" == "web" ]] if [[ "$encType" == "file" || "$encType" == "web" ]]
then then
@ -98,8 +118,10 @@ then
fi fi
fi fi
else else
if [ "$dflag" != 1]; then
dbPassword=$(sed '/^\#/d' /etc/cloud/management/db.properties | grep 'db.cloud.password' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//'i ) dbPassword=$(sed '/^\#/d' /etc/cloud/management/db.properties | grep 'db.cloud.password' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//'i )
fi fi
fi
if [ "$hyper" == "kvm" ] if [ "$hyper" == "kvm" ]
then then