Skip to content

Commit b7214e6

Browse files
author
kishan
committed
bug 10626: Modified install sys tmpl script to get templateId from DB using db.properties
status 10626: resolved fixed
1 parent b05c69f commit b7214e6

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

‎scripts/storage/secondary/cloud-install-sys-tmplt‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ failed() {
1010
echo "Installation failed"
1111
exit $1
1212
}
13-
13+
#set -x
1414
mflag=
1515
fflag=
1616
ext="vhd"
@@ -60,18 +60,22 @@ then
6060
failed 3
6161
fi
6262

63+
dbHost=$(sed '/^\#/d' /etc/cloud/management/db.properties | grep 'db.cloud.host' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
64+
dbUser=$(sed '/^\#/d' /etc/cloud/management/db.properties | grep 'db.cloud.username' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
65+
dbPassword=$(sed '/^\#/d' /etc/cloud/management/db.properties | grep 'db.cloud.password' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
66+
6367
if [ "$hyper" == "kvm" ]
6468
then
6569
ext="qcow2"
66-
templateId=3
70+
templateId=(`mysql -h $dbHost --user=$dbUser --password=$dbPassword --skip-column-names -U cloud -e "select max(id) from cloud.vm_template where type = \"SYSTEM\" and hypervisor_type = \"KVM\" and removed is null"`)
6771
elif [ "$hyper" == "xenserver" ]
6872
then
6973
ext="vhd"
70-
templateId=${templateId:-1}
74+
templateId=(`mysql -h $dbHost --user=$dbUser --password=$dbPassword --skip-column-names -U cloud -e "select max(id) from cloud.vm_template where type = \"SYSTEM\" and hypervisor_type = \"XenServer\" and removed is null"`)
7175
elif [ "$hyper" == "vmware" ]
7276
then
7377
ext="ova"
74-
templateId=8
78+
templateId=(`mysql -h $dbHost --user=$dbUser --password=$dbPassword --skip-column-names -U cloud -e "select max(id) from cloud.vm_template where type = \"SYSTEM\" and hypervisor_type = \"VMware\" and removed is null"`)
7579
else
7680
usage
7781
failed 2

0 commit comments

Comments
 (0)