mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-11-03 04:12:31 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			172 lines
		
	
	
		
			4.5 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			172 lines
		
	
	
		
			4.5 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
#!/bin/bash
 | 
						|
# Copyright (C) 2011 Citrix Systems, Inc.  All rights reserved
 | 
						|
#     
 | 
						|
# This software is licensed under the GNU General Public License v3 or later.
 | 
						|
# 
 | 
						|
# It is free software: you can redistribute it and/or modify
 | 
						|
# it under the terms of the GNU General Public License as published by
 | 
						|
# the Free Software Foundation, either version 3 of the License, or any later version.
 | 
						|
# This program is distributed in the hope that it will be useful,
 | 
						|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
						|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
						|
# GNU General Public License for more details.
 | 
						|
# 
 | 
						|
# You should have received a copy of the GNU General Public License
 | 
						|
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
						|
# 
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 
 | 
						|
 | 
						|
 | 
						|
. /etc/rc.d/init.d/functions
 | 
						|
 | 
						|
set -x
 | 
						|
 | 
						|
usage() {
 | 
						|
  printf "Usage: %s: [-d] [-r] \n" $(basename $0) >&2
 | 
						|
}
 | 
						|
 | 
						|
deploy_server() {
 | 
						|
  ssh root@$1 "yum remove -y \"cloud*\" ; yum clean all ; cd /usr/share/cloud/ && rm -rf * && rm -rf /var/cache/cloud ; yum install -y cloud-client cloud-premium cloud-usage"
 | 
						|
  ssh root@$1 "cloud-setup-databases alena@$2 xenserver"
 | 
						|
  ssh root@$1 "cd /usr/share/cloud/management/conf; sed '/db.cloud.url.params/ d' db.properties > db.properties1; dos2unix db.properties1; mv -f db.properties1 db.properties"
 | 
						|
  ssh root@$1 "cd /usr/share/cloud/management/conf; echo \db.cloud.url.params=includeInnodbStatusInDeadlockExceptions=true\&logSlowQueries=true\&prepStmtCacheSize=517\&cachePrepStmts=true >> db.properties"
 | 
						|
  if [ $? -gt 0 ]; then echo "failed to install on $1"; return 2; fi
 | 
						|
 echo "Management server is deployed successfully"
 | 
						|
}
 | 
						|
 | 
						|
deploy_db() {
 | 
						|
  echo "Deploying database on $1"
 | 
						|
 # ssh root@$1 "cp $CONFIGDIR/conf/templates.sql /usr/share/cloud/setup/templates.xenserver.sql "
 | 
						|
ssh root@$1 "cloud-setup-databases alena@$1 --deploy-as=root xenserver"
 | 
						|
  if [ $? -gt 0 ]; then echo "failed to deploy db on $1"; return 2; fi
 | 
						|
  echo "Database is deployed successfully"
 | 
						|
}
 | 
						|
 | 
						|
run_server() {
 | 
						|
  ssh root@$1 "service cloud-management start; service cloud-usage start 2>&1 &"
 | 
						|
}
 | 
						|
 | 
						|
stop_server() {
 | 
						|
  ssh root@$1 "service cloud-management stop; service cloud-usage stop 2>&1 &"
 | 
						|
}
 | 
						|
 | 
						|
dir=$(dirname "$0")
 | 
						|
if [ -f $dir/../deploy.properties ]; then
 | 
						|
  . "$dir/../deploy.properties"
 | 
						|
fi
 | 
						|
 | 
						|
if [ "$USER" == "" ]; then
 | 
						|
  printf "ERROR: Need tospecify the user\n"
 | 
						|
  exit 4
 | 
						|
fi
 | 
						|
 | 
						|
if [ "$SERVER" == "" ]; then
 | 
						|
  printf "ERROR: Need to specify the management server\n"
 | 
						|
  exit 1
 | 
						|
fi
 | 
						|
 | 
						|
installflag=
 | 
						|
deployflag=
 | 
						|
runflag=
 | 
						|
killflag=
 | 
						|
setupflag=
 | 
						|
mgmtIp=
 | 
						|
mode=expert
 | 
						|
distdir=dist
 | 
						|
 | 
						|
while getopts 'idkrsb:D' OPTION
 | 
						|
do
 | 
						|
  case $OPTION in
 | 
						|
  i)    installflag=1
 | 
						|
        ;;
 | 
						|
  d)    deployflag=1
 | 
						|
        ;;
 | 
						|
  k)    killflag=1
 | 
						|
        ;;
 | 
						|
  r)    runflag=1
 | 
						|
        ;;
 | 
						|
  b)    distdir="$OPTARG"
 | 
						|
        ;;
 | 
						|
  s)    setupflag=1
 | 
						|
        mode=setup
 | 
						|
        ;;
 | 
						|
  D)    developer=1; distdir=dist/developer;;
 | 
						|
 | 
						|
  ?)    usage
 | 
						|
  esac
 | 
						|
done
 | 
						|
 | 
						|
 | 
						|
if [ "$setupflag$deployflag$installflag$killflag$runflag" == "" ]
 | 
						|
then
 | 
						|
  usage
 | 
						|
  exit
 | 
						|
fi
 | 
						|
 | 
						|
 | 
						|
if [ "$installflag" == "1" ]
 | 
						|
then
 | 
						|
    echo "Deploying server...."
 | 
						|
 | 
						|
    for i in $SERVER
 | 
						|
    do
 | 
						|
      echo -n "$i: "
 | 
						|
      deploy_server $i $DB
 | 
						|
      if [ $? -gt 0 ]; then  failure ; else success;fi
 | 
						|
      echo
 | 
						|
    done
 | 
						|
fi
 | 
						|
 | 
						|
if [ "$deployflag" == "1" ]
 | 
						|
then
 | 
						|
    echo "Deploying database..."
 | 
						|
    for i in $DB
 | 
						|
    do
 | 
						|
      echo -n "$i: "
 | 
						|
      deploy_db $i
 | 
						|
      if [ $? -gt 0 ]; then  failure ; else success;fi
 | 
						|
      echo
 | 
						|
    done
 | 
						|
fi
 | 
						|
 | 
						|
 | 
						|
if [ "$runflag" == "1" ]
 | 
						|
then
 | 
						|
   echo "Starting Management server"
 | 
						|
   for i in $SERVER
 | 
						|
   do
 | 
						|
      run_server $i
 | 
						|
      sleep 30
 | 
						|
   done
 | 
						|
 | 
						|
 | 
						|
echo "Setting up configuration values..."
 | 
						|
    for i in $LB
 | 
						|
   do
 | 
						|
      DST='../src/'
 | 
						|
      java -cp ${DST}commons-httpclient-3.1.jar:${DST}mysql-connector-java-5.1.7-bin.jar:${DST}commons-logging-1.1.1.jar:${DST}commons-codec-1.4.jar:${DST}cloud-test.jar:${DST}log4j-1.2.15.jar:${DST}trilead-ssh2-build213.jar:${DST}cloud-utils.jar:.././conf com.cloud.test.regression.Deploy -h $i -f ../conf/deploy.xml
 | 
						|
      echo "Restarting Management server to apply configuration values"
 | 
						|
   done
 | 
						|
 | 
						|
echo "Restarting management servers"
 | 
						|
  for i in $SERVER
 | 
						|
   do
 | 
						|
      echo "Restarting Management server to apply configuration values"
 | 
						|
      stop_server $i
 | 
						|
      run_server $i
 | 
						|
      sleep 60
 | 
						|
   done
 | 
						|
 | 
						|
 | 
						|
echo "Adding secondary/primary storage/hosts..."
 | 
						|
    for i in $LB
 | 
						|
   do
 | 
						|
      DST='../src/'
 | 
						|
      java -cp ${DST}commons-httpclient-3.1.jar:${DST}mysql-connector-java-5.1.7-bin.jar:${DST}commons-logging-1.1.1.jar:${DST}commons-codec-1.4.jar:${DST}cloud-test.jar:${DST}log4j-1.2.15.jar:${DST}trilead-ssh2-build213.jar:${DST}cloud-utils.jar:.././conf com.cloud.test.regression.Deploy -h $i -f ../conf/config.xml
 | 
						|
   done
 | 
						|
 | 
						|
fi
 |