cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jaya...@apache.org
Subject git commit: updated refs/heads/master to 78abeba
Date Mon, 12 Aug 2013 12:02:45 GMT
Updated Branches:
  refs/heads/master cd2ea3b84 -> 78abebae2


CLOUDSTACK-4231 make apache server listen on all the ipaliases to provide access to meta-data.

Signed-off-by: Jayapal <jayapal@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/78abebae
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/78abebae
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/78abebae

Branch: refs/heads/master
Commit: 78abebae283807e943184840aec404e362a45cfc
Parents: cd2ea3b
Author: Bharat Kumar <bharat.kumar@citrix.com>
Authored: Sat Aug 10 18:06:53 2013 +0530
Committer: Jayapal <jayapal@apache.org>
Committed: Mon Aug 12 17:32:19 2013 +0530

----------------------------------------------------------------------
 .../debian/config/etc/init.d/cloud-early-config |  8 +++
 .../debian/config/root/createIpAlias.sh         | 54 ++++++++++++++++++++
 .../debian/config/root/deleteIpAlias.sh         | 17 +++++-
 3 files changed, 77 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/78abebae/patches/systemvm/debian/config/etc/init.d/cloud-early-config
----------------------------------------------------------------------
diff --git a/patches/systemvm/debian/config/etc/init.d/cloud-early-config b/patches/systemvm/debian/config/etc/init.d/cloud-early-config
index a552d44..736234c 100755
--- a/patches/systemvm/debian/config/etc/init.d/cloud-early-config
+++ b/patches/systemvm/debian/config/etc/init.d/cloud-early-config
@@ -754,7 +754,15 @@ setup_vpc_apache2() {
 }
 
 
+clean_ipalias_config() {
+rm -f /etc/apache2/conf.d/ports.*.meta-data.conf
+rm -f /etc/apache2/sites-available/ipAlias*
+rm -f /etc/apache2/sites-enabled/ipAlias*
+rm -rf /etc/failure_config
+}
+
 setup_apache2() {
+  clean_ipalias_config
   log_it "Setting up apache web server"
   local ip=$1
   [ -f /etc/apache2/sites-available/default ] && sed -i -e "s/<VirtualHost.*>/<VirtualHost
$ip:80>/" /etc/apache2/sites-available/default

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/78abebae/patches/systemvm/debian/config/root/createIpAlias.sh
----------------------------------------------------------------------
diff --git a/patches/systemvm/debian/config/root/createIpAlias.sh b/patches/systemvm/debian/config/root/createIpAlias.sh
index 5498195..cd273f6 100755
--- a/patches/systemvm/debian/config/root/createIpAlias.sh
+++ b/patches/systemvm/debian/config/root/createIpAlias.sh
@@ -28,9 +28,38 @@ then
     exit 1
 fi
 
+PORTS_CONF=/etc/apache2/ports.conf
+PORTS_CONF_BAK=/etc/ports.conf.bak
+FAIL_DIR=/etc/failure_config
+CMDLINE=$(cat /var/cache/cloud/cmdline | tr '\n' ' ')
+
+if [ ! -d "$FAIL_DIR" ]
+  then
+      mkdir "$FAIL_DIR"
+fi
+#bakup ports.conf
+cp "$PORTS_CONF" "$PORTS_CONF_BAK"
+
+domain=$(echo "$CMDLINE" | grep -o " domain=.* " | sed -e 's/domain=//' | awk '{print $1}')
+
+setup_apache2() {
+  local ip=$1
+  logger -t cloud "Setting up apache web server for $ip"
+  cp /etc/apache2/sites-available/default  /etc/apache2/sites-available/ipAlias.${ip}.meta-data
+  cp /etc/apache2/sites-available/default-ssl  /etc/apache2/sites-available/ipAlias.${ip}-ssl.meta-data
+  cp /etc/apache2/ports.conf /etc/apache2/conf.d/ports.${ip}.meta-data.conf
+  sed -i -e "s/<VirtualHost.*>/<VirtualHost $ip:80>\nServerName $domain/" /etc/apache2/sites-available/ipAlias.${ip}.meta-data
+  sed -i -e "s/<VirtualHost.*>/<VirtualHost $ip:443>\nServerName $domain/" /etc/apache2/sites-available/ipAlias.${ip}-ssl.meta-data
+  sed -i -e "/NameVirtualHost .*:80/d" /etc/apache2/conf.d/ports.${ip}.meta-data.conf
+  sed -i -e "s/Listen .*:80/Listen $ip:80/g" /etc/apache2/conf.d/ports.${ip}.meta-data.conf
+  sed -i -e "s/Listen .*:443/Listen $ip:443/g" /etc/apache2/conf.d/ports.${ip}.meta-data.conf
+  ln -s /etc/apache2/sites-available/ipAlias.${ip}.meta-data /etc/apache2/sites-enabled/ipAlias.${ip}.meta-data
+  ln -s /etc/apache2/sites-available/ipAlias.${ip}-ssl.meta-data /etc/apache2/sites-enabled/ipAlias.${ip}-ssl.meta-data
+}
 
 var="$1"
 cert="/root/.ssh/id_rsa.cloud"
+config_ips=""
 
 while [ -n "$var" ]
 do
@@ -39,8 +68,33 @@ do
  routerip=$(echo $var1 | cut -f2 -d ":")
  netmask=$(echo $var1 | cut -f3 -d ":")
  ifconfig eth0:$alias_count $routerip netmask $netmask up
+ setup_apache2 "$routerip"
+ config_ips="${config_ips}"$routerip":"
  var=$( echo $var | sed "s/${var1}-//" )
 done
+
+#restarting the apache server for the config to take effect.
+service apache2 restart
+result=$?
+if [ "$result" -ne "0" ]
+then
+   logger -t cloud "createIpAlias.sh: could not configure apache2 server"
+   logger -t cloud "createIpAlias.sh: reverting to the old config"
+   logger -t cloud "createIpAlias.sh: moving out the failure config to $FAIL_DIR"
+   while [ -n "$config_ips" ]
+   do
+      ip=$( echo $config_ips | cut -f1 -d ":" )
+      mv  "/etc/apache2/sites-available/ipAlias.${ip}.meta-data" "$FAIL_DIR/ipAlias.${ip}.meta-data"
+      mv  "/etc/apache2/sites-available/ipAlias.${ip}-ssl.meta-data" "$FAIL_DIR/ipAlias.${ip}-ssl.meta-data"
+      mv  "/etc/apache2/conf.d/ports.${ip}.meta-data.conf"       "$FAIL_DIR/ports.${ip}.meta-data.conf"
+      rm -f "/etc/apache2/sites-enabled/ipAlias.${ip}.meta-data"
+      rm -f "/etc/apache2/sites-enabled/ipAlias.${ip}-ssl.meta-data"
+      config_ips=$( echo $config_ips | sed "s/${ip}://" )
+   done
+   service apache2 restart
+   unlock_exit $result $lock $locked
+fi
+
 #restaring the password service to enable it on the ip aliases
 /etc/init.d/cloud-passwd-srvr restart
 unlock_exit $? $lock $locked
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/78abebae/patches/systemvm/debian/config/root/deleteIpAlias.sh
----------------------------------------------------------------------
diff --git a/patches/systemvm/debian/config/root/deleteIpAlias.sh b/patches/systemvm/debian/config/root/deleteIpAlias.sh
index fa228fb..47edb92 100755
--- a/patches/systemvm/debian/config/root/deleteIpAlias.sh
+++ b/patches/systemvm/debian/config/root/deleteIpAlias.sh
@@ -21,7 +21,6 @@ usage() {
 }
 
 source /root/func.sh
-
 lock="biglock"
 locked=$(getLockFile $lock)
 if [ "$locked" != "1" ]
@@ -29,6 +28,16 @@ then
     exit 1
 fi
 
+remove_apache_config() {
+local ip=$1
+ logger -t cloud "removing apache web server config for $ip"
+ rm -f "/etc/apache2/sites-available/ipAlias.${ip}.meta-data"
+ rm -f "/etc/apache2/sites-available/ipAlias.${ip}-ssl.meta-data"
+ rm -f "/etc/apache2/conf.d/ports.${ip}.meta-data.conf"
+ rm -f "/etc/apache2/sites-enabled/ipAlias.${ip}-ssl.meta-data"
+ rm -f "/etc/apache2/sites-enabled/ipAlias.${ip}.meta-data"
+}
+
 var="$1"
 cert="/root/.ssh/id_rsa.cloud"
 
@@ -36,12 +45,16 @@ while [[ !( "$var" == "-" ) ]]
 do
  var1=$(echo $var | cut -f1 -d "-")
  alias_count=$( echo $var1 | cut -f1 -d ":" )
+ routerip=$( echo $var1 | cut -f2 -d ":" )
  ifconfig eth0:$alias_count  down
+ remove_apache_config "$routerip"
  var=$( echo $var | sed "s/${var1}-//" )
 done
+#restarting the apache server for the config to take effect.
+service apache2 restart
 
 releaseLockFile $lock $locked
 
 #recreating the active ip aliases
 /root/createIpAlias.sh $2
-unlock_exit $? $lock $locked
+unlock_exit $? $lock $locked
\ No newline at end of file


Mime
View raw message