From b7214e620223916b86a5527ac92a2bb030f92efc Mon Sep 17 00:00:00 2001 From: kishan Date: Wed, 14 Sep 2011 01:07:25 +0530 Subject: [PATCH] bug 10626: Modified install sys tmpl script to get templateId from DB using db.properties status 10626: resolved fixed --- scripts/storage/secondary/cloud-install-sys-tmplt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/scripts/storage/secondary/cloud-install-sys-tmplt b/scripts/storage/secondary/cloud-install-sys-tmplt index ded4358630d..48a203bfcfb 100755 --- a/scripts/storage/secondary/cloud-install-sys-tmplt +++ b/scripts/storage/secondary/cloud-install-sys-tmplt @@ -10,7 +10,7 @@ failed() { echo "Installation failed" exit $1 } - +#set -x mflag= fflag= ext="vhd" @@ -60,18 +60,22 @@ then failed 3 fi +dbHost=$(sed '/^\#/d' /etc/cloud/management/db.properties | grep 'db.cloud.host' | 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:]]*$//') +dbPassword=$(sed '/^\#/d' /etc/cloud/management/db.properties | grep 'db.cloud.password' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//') + if [ "$hyper" == "kvm" ] then ext="qcow2" - templateId=3 + 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"`) elif [ "$hyper" == "xenserver" ] then ext="vhd" - templateId=${templateId:-1} + 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"`) elif [ "$hyper" == "vmware" ] then ext="ova" - templateId=8 + 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"`) else usage failed 2