You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ya...@apache.org on 2014/01/17 21:36:54 UTC

[3/3] git commit: updated refs/heads/master to ca81e7b

CLOUDSTACK-5779: Move ipAlias to use routerProxy


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

Branch: refs/heads/master
Commit: ce67e24d0aeada261aa6b44b2c37abfc6f0973af
Parents: 36920a3
Author: Sheng Yang <sh...@citrix.com>
Authored: Fri Jan 17 11:51:41 2014 -0800
Committer: Sheng Yang <sh...@citrix.com>
Committed: Fri Jan 17 12:36:42 2014 -0800

----------------------------------------------------------------------
 .../virtualnetwork/VirtualRoutingResource.java  |  27 +----
 .../vmware/resource/VmwareResource.java         |   8 +-
 .../xen/resource/CitrixResourceBase.java        |  10 +-
 scripts/network/domr/createipAlias.sh           |  26 -----
 scripts/network/domr/deleteipAlias.sh           |  25 -----
 scripts/network/domr/s2s_vpn.sh                 |  29 ------
 scripts/vm/hypervisor/xenserver/vmops           |  32 ------
 .../config/opt/cloud/bin/createIpAlias.sh       | 100 +++++++++++++++++++
 .../config/opt/cloud/bin/deleteIpAlias.sh       |  60 +++++++++++
 .../patches/debian/config/root/createIpAlias.sh | 100 -------------------
 .../patches/debian/config/root/deleteIpAlias.sh |  60 -----------
 11 files changed, 170 insertions(+), 307 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ce67e24d/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
index f469d8a..20cc0cc 100755
--- a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
+++ b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
@@ -106,10 +106,7 @@ public class VirtualRoutingResource implements Manager {
     private String _loadbPath;
     private String _publicEthIf;
     private String _privateEthIf;
-    private String _bumpUpPriorityPath;
     private String _routerProxyPath;
-    private String _createIpAliasPath;
-    private String _deleteIpAliasPath;
 
     private int _timeout;
     private int _startTimeout;
@@ -587,23 +584,18 @@ public class VirtualRoutingResource implements Manager {
 
     protected Answer execute(final CreateIpAliasCommand cmd) {
         String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
-        final Script command = new Script(_createIpAliasPath, _timeout, s_logger);
         List<IpAliasTO> ipAliasTOs = cmd.getIpAliasList();
         String args = "";
-        command.add(routerIp);
         for (IpAliasTO ipaliasto : ipAliasTOs) {
             args = args + ipaliasto.getAlias_count() + ":" + ipaliasto.getRouterip() + ":" + ipaliasto.getNetmask() + "-";
         }
-        command.add(args);
-        final String result = command.execute();
+        final String result = routerProxy("createipAlias.sh", routerIp, args);
         return new Answer(cmd, result == null, result);
     }
 
     protected Answer execute(final DeleteIpAliasCommand cmd) {
-        final Script command = new Script(_deleteIpAliasPath, _timeout, s_logger);
         String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
         String args = "";
-        command.add(routerIp);
         List<IpAliasTO> revokedIpAliasTOs = cmd.getDeleteIpAliasTos();
         for (IpAliasTO ipAliasTO : revokedIpAliasTOs) {
             args = args + ipAliasTO.getAlias_count() + ":" + ipAliasTO.getRouterip() + ":" + ipAliasTO.getNetmask() + "-";
@@ -613,8 +605,7 @@ public class VirtualRoutingResource implements Manager {
         for (IpAliasTO ipAliasTO : activeIpAliasTOs) {
             args = args + ipAliasTO.getAlias_count() + ":" + ipAliasTO.getRouterip() + ":" + ipAliasTO.getNetmask() + "-";
         }
-        command.add(args);
-        final String result = command.execute();
+        final String result = routerProxy("deleteipAlias.sh", routerIp, args);
         return new Answer(cmd, result == null, result);
     }
 
@@ -1136,24 +1127,10 @@ public class VirtualRoutingResource implements Manager {
         }
         _privateEthIf = _privateEthIf.toLowerCase();
 
-        _bumpUpPriorityPath = findScript("bumpUpPriority.sh");
-        if (_bumpUpPriorityPath == null) {
-            throw new ConfigurationException("Unable to find bumpUpPriority.sh");
-        }
-
         _routerProxyPath = findScript("router_proxy.sh");
         if (_routerProxyPath == null) {
             throw new ConfigurationException("Unable to find router_proxy.sh");
         }
-        _createIpAliasPath = findScript("createipAlias.sh");
-        if (_createIpAliasPath == null) {
-            throw new ConfigurationException("unable to find createipAlias.sh");
-        }
-        _deleteIpAliasPath = findScript("deleteipAlias.sh");
-        if (_deleteIpAliasPath == null) {
-            throw new ConfigurationException("unable to find deleteipAlias.sh");
-        }
-
         return true;
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ce67e24d/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
index 5d7cf17..817fdec 100755
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
@@ -2181,14 +2181,14 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
             args = args + ipaliasto.getAlias_count() + ":" + ipaliasto.getRouterip() + ":" + ipaliasto.getNetmask() + "-";
         }
         if (s_logger.isDebugEnabled()) {
-            s_logger.debug("Run command on domR " + cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP) + ", /root/createIpAlias " + args);
+            s_logger.debug("Run command on domR " + cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP) + ", /opt/cloud/bin/createIpAlias " + args);
         }
 
         try {
             VmwareManager mgr = getServiceContext().getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
             String controlIp = getRouterSshControlIp(cmd);
             Pair<Boolean, String> result =
-                SshHelper.sshExecute(controlIp, DefaultDomRSshPort, "root", mgr.getSystemVMKeyFile(), null, "/root/createIpAlias.sh " + args);
+                SshHelper.sshExecute(controlIp, DefaultDomRSshPort, "root", mgr.getSystemVMKeyFile(), null, "/opt/cloud/bin/createIpAlias.sh " + args);
 
             if (!result.first()) {
                 s_logger.error("CreateIpAlias command on domr " + controlIp + " failed, message: " + result.second());
@@ -2225,14 +2225,14 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
             args = args + ipAliasTO.getAlias_count() + ":" + ipAliasTO.getRouterip() + ":" + ipAliasTO.getNetmask() + "-";
         }
         if (s_logger.isDebugEnabled()) {
-            s_logger.debug("Run command on domR " + cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP) + ", /root/deleteIpAlias " + args);
+            s_logger.debug("Run command on domR " + cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP) + ", /opt/cloud/bin/deleteIpAlias " + args);
         }
 
         try {
             VmwareManager mgr = getServiceContext().getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
             String controlIp = getRouterSshControlIp(cmd);
             Pair<Boolean, String> result =
-                SshHelper.sshExecute(controlIp, DefaultDomRSshPort, "root", mgr.getSystemVMKeyFile(), null, "/root/deleteIpAlias.sh " + args);
+                SshHelper.sshExecute(controlIp, DefaultDomRSshPort, "root", mgr.getSystemVMKeyFile(), null, "/opt/cloud/bin/deleteIpAlias.sh " + args);
 
             if (!result.first()) {
                 s_logger.error("deleteIpAlias command on domr " + controlIp + " failed, message: " + result.second());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ce67e24d/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
index ea812e3..ddb7912 100644
--- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
+++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
@@ -2194,14 +2194,13 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
     }
 
     protected Answer execute(final CreateIpAliasCommand cmd) {
-        Connection conn = getConnection();
         String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
         List<IpAliasTO> ipAliasTOs = cmd.getIpAliasList();
-        String args = routerIp + " ";
+        String args = "";
         for (IpAliasTO ipaliasto : ipAliasTOs) {
             args = args + ipaliasto.getAlias_count() + ":" + ipaliasto.getRouterip() + ":" + ipaliasto.getNetmask() + "-";
         }
-        String result = callHostPlugin(conn, "vmops", "createipAlias", "args", args);
+        String result = routerProxy("createipAlias.sh", routerIp, args);
         if (result == null || result.isEmpty()) {
             return new Answer(cmd, false, "CreateIPAliasCommand failed\n");
         }
@@ -2210,10 +2209,9 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
     }
 
     protected Answer execute(final DeleteIpAliasCommand cmd) {
-        Connection conn = getConnection();
         String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
         List<IpAliasTO> revokedIpAliasTOs = cmd.getDeleteIpAliasTos();
-        String args = routerIp + " ";
+        String args = "";
         for (IpAliasTO ipAliasTO : revokedIpAliasTOs) {
             args = args + ipAliasTO.getAlias_count() + ":" + ipAliasTO.getRouterip() + ":" + ipAliasTO.getNetmask() + "-";
         }
@@ -2223,7 +2221,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
         for (IpAliasTO ipAliasTO : activeIpAliasTOs) {
             args = args + ipAliasTO.getAlias_count() + ":" + ipAliasTO.getRouterip() + ":" + ipAliasTO.getNetmask() + "-";
         }
-        String result = callHostPlugin(conn, "vmops", "deleteipAlias", "args", args);
+        String result = routerProxy("deleteipAlias", routerIp, args);
         if (result == null || result.isEmpty()) {
             return new Answer(cmd, false, "DeleteipAliasCommand failed\n");
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ce67e24d/scripts/network/domr/createipAlias.sh
----------------------------------------------------------------------
diff --git a/scripts/network/domr/createipAlias.sh b/scripts/network/domr/createipAlias.sh
deleted file mode 100755
index c35658e..0000000
--- a/scripts/network/domr/createipAlias.sh
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/usr/bin/env bash
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-
-usage() {
-  printf " %s  routerip  <alias_count:ip:netmask;alias_count2:ip2:netmask2;....> \n" $(basename $0) >&2
-}
-
-set -x
-cert="/root/.ssh/id_rsa.cloud"
-ssh -p 3922 -q -o StrictHostKeyChecking=no -i $cert root@$1 "/root/createIpAlias.sh $2"

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ce67e24d/scripts/network/domr/deleteipAlias.sh
----------------------------------------------------------------------
diff --git a/scripts/network/domr/deleteipAlias.sh b/scripts/network/domr/deleteipAlias.sh
deleted file mode 100755
index 6816edd..0000000
--- a/scripts/network/domr/deleteipAlias.sh
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/usr/bin/env bash
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-usage() {
-  printf " %s  routerip  <alias_count:ip:netmask;alias_count2:ip2:netmask2;....> \n" $(basename $0) >&2
-}
-
-set -x
-cert="/root/.ssh/id_rsa.cloud"
-ssh -p 3922 -q -o StrictHostKeyChecking=no -i $cert root@$1 "/root/deleteIpAlias.sh $2 $3"

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ce67e24d/scripts/network/domr/s2s_vpn.sh
----------------------------------------------------------------------
diff --git a/scripts/network/domr/s2s_vpn.sh b/scripts/network/domr/s2s_vpn.sh
deleted file mode 100755
index 3ec3e26..0000000
--- a/scripts/network/domr/s2s_vpn.sh
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/bin/bash
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-
- 
-
-# @VERSION@
-
-cert="/root/.ssh/id_rsa.cloud"
-domr=$1
-shift
-ssh -p 3922 -o StrictHostKeyChecking=no -i $cert root@$domr "/opt/cloud/bin/ipsectunnel.sh $*" >/dev/null
-
-exit $?

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ce67e24d/scripts/vm/hypervisor/xenserver/vmops
----------------------------------------------------------------------
diff --git a/scripts/vm/hypervisor/xenserver/vmops b/scripts/vm/hypervisor/xenserver/vmops
index 1b04533..53a0002 100755
--- a/scripts/vm/hypervisor/xenserver/vmops
+++ b/scripts/vm/hypervisor/xenserver/vmops
@@ -255,8 +255,6 @@ def routerProxy(session, args):
 
     return txt
 
-
-
 @echo
 def setLoadBalancerRule(session, args):
     sargs = args['args']
@@ -273,34 +271,6 @@ def setLoadBalancerRule(session, args):
     return txt
 
 @echo
-def createipAlias(session, args):
-    args = args['args']
-    cmd = args.split(' ')
-    cmd.insert(0, "/opt/cloud/bin/createipAlias.sh")
-    cmd.insert(0, "bin/bash")
-    try:
-       txt=util.pread2(cmd)
-       txt='success'
-    except:
-       logging.debug("failed to create ip alias on router vm")
-       txt=''
-    return txt
-
-@echo
-def deleteipAlias(session, args):
-    args = args['args']
-    cmd = args.split(' ')
-    cmd.insert(0, "/opt/cloud/bin/deleteipAlias.sh")
-    cmd.insert(0, "bin/bash")
-    try:
-       txt=util.pread2(cmd)
-       txt='success'
-    except:
-       logging.debug("failed to create ip alias on router vm")
-       txt=''
-    return txt
-
-@echo
 def createFile(session, args):
     file_path = args['filepath']
     file_contents = args['filecontents']
@@ -1593,8 +1563,6 @@ if __name__ == "__main__":
                             "destroy_network_rules_for_vm":destroy_network_rules_for_vm, 
                             "default_network_rules_systemvm":default_network_rules_systemvm, 
                             "network_rules_vmSecondaryIp":network_rules_vmSecondaryIp,
-                            "createipAlias":createipAlias,
-                            "deleteipAlias":deleteipAlias,
                             "get_rule_logs_for_vms":get_rule_logs_for_vms, 
 			    "add_to_VCPUs_params_live":add_to_VCPUs_params_live,
                             "setLinkLocalIP":setLinkLocalIP,

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ce67e24d/systemvm/patches/debian/config/opt/cloud/bin/createIpAlias.sh
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/opt/cloud/bin/createIpAlias.sh b/systemvm/patches/debian/config/opt/cloud/bin/createIpAlias.sh
new file mode 100755
index 0000000..cd273f6
--- /dev/null
+++ b/systemvm/patches/debian/config/opt/cloud/bin/createIpAlias.sh
@@ -0,0 +1,100 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+usage() {
+  printf " %s   <alias_count:ip:netmask;alias_count2:ip2:netmask2;....> \n" $(basename $0) >&2
+}
+source /root/func.sh
+
+lock="biglock"
+locked=$(getLockFile $lock)
+if [ "$locked" != "1" ]
+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
+ var1=$(echo $var | cut -f1 -d "-")
+ alias_count=$( echo $var1 | cut -f1 -d ":" )
+ 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/ce67e24d/systemvm/patches/debian/config/opt/cloud/bin/deleteIpAlias.sh
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/opt/cloud/bin/deleteIpAlias.sh b/systemvm/patches/debian/config/opt/cloud/bin/deleteIpAlias.sh
new file mode 100755
index 0000000..47edb92
--- /dev/null
+++ b/systemvm/patches/debian/config/opt/cloud/bin/deleteIpAlias.sh
@@ -0,0 +1,60 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+usage() {
+  printf " %s   <alias_count:ip:netmask;alias_count2:ip2:netmask2;....> \n" $(basename $0) >&2
+}
+
+source /root/func.sh
+lock="biglock"
+locked=$(getLockFile $lock)
+if [ "$locked" != "1" ]
+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"
+
+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
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ce67e24d/systemvm/patches/debian/config/root/createIpAlias.sh
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/root/createIpAlias.sh b/systemvm/patches/debian/config/root/createIpAlias.sh
deleted file mode 100755
index cd273f6..0000000
--- a/systemvm/patches/debian/config/root/createIpAlias.sh
+++ /dev/null
@@ -1,100 +0,0 @@
-#!/usr/bin/env bash
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-usage() {
-  printf " %s   <alias_count:ip:netmask;alias_count2:ip2:netmask2;....> \n" $(basename $0) >&2
-}
-source /root/func.sh
-
-lock="biglock"
-locked=$(getLockFile $lock)
-if [ "$locked" != "1" ]
-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
- var1=$(echo $var | cut -f1 -d "-")
- alias_count=$( echo $var1 | cut -f1 -d ":" )
- 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/ce67e24d/systemvm/patches/debian/config/root/deleteIpAlias.sh
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/root/deleteIpAlias.sh b/systemvm/patches/debian/config/root/deleteIpAlias.sh
deleted file mode 100755
index 47edb92..0000000
--- a/systemvm/patches/debian/config/root/deleteIpAlias.sh
+++ /dev/null
@@ -1,60 +0,0 @@
-#!/usr/bin/env bash
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-usage() {
-  printf " %s   <alias_count:ip:netmask;alias_count2:ip2:netmask2;....> \n" $(basename $0) >&2
-}
-
-source /root/func.sh
-lock="biglock"
-locked=$(getLockFile $lock)
-if [ "$locked" != "1" ]
-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"
-
-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
\ No newline at end of file