Return-Path: X-Original-To: apmail-incubator-cloudstack-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-cloudstack-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A4C81CB78 for ; Wed, 22 Aug 2012 06:37:40 +0000 (UTC) Received: (qmail 72889 invoked by uid 500); 22 Aug 2012 06:37:40 -0000 Delivered-To: apmail-incubator-cloudstack-commits-archive@incubator.apache.org Received: (qmail 72666 invoked by uid 500); 22 Aug 2012 06:37:35 -0000 Mailing-List: contact cloudstack-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: cloudstack-dev@incubator.apache.org Delivered-To: mailing list cloudstack-commits@incubator.apache.org Received: (qmail 72641 invoked by uid 99); 22 Aug 2012 06:37:35 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 22 Aug 2012 06:37:35 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id C72E91ECF7; Wed, 22 Aug 2012 06:37:34 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: kishan@apache.org To: cloudstack-commits@incubator.apache.org X-Mailer: ASF-Git Admin Mailer Subject: git commit: bug CS-16112: During unplug nic iptables rules are cleaned up in both cloud_nic.sh and vpc_netusage.sh. Consolidated this code in cloud_nic.sh status CS-16112: resolved fixed Message-Id: <20120822063734.C72E91ECF7@tyr.zones.apache.org> Date: Wed, 22 Aug 2012 06:37:34 +0000 (UTC) Updated Branches: refs/heads/master 95347d2a5 -> b42a813ff bug CS-16112: During unplug nic iptables rules are cleaned up in both cloud_nic.sh and vpc_netusage.sh. Consolidated this code in cloud_nic.sh status CS-16112: resolved fixed Conflicts: patches/systemvm/debian/config/opt/cloud/bin/vpc_netusage.sh Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/b42a813f Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/b42a813f Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/b42a813f Branch: refs/heads/master Commit: b42a813ff1d1227767acb8dbd29bc925e2cab12b Parents: 95347d2 Author: kishan Authored: Tue Aug 21 20:16:35 2012 +0530 Committer: kishan Committed: Wed Aug 22 12:00:02 2012 +0530 ---------------------------------------------------------------------- .../debian/config/opt/cloud/bin/cloud-nic.sh | 14 +++++++-- .../debian/config/opt/cloud/bin/vpc_netusage.sh | 22 +-------------- .../VpcVirtualNetworkApplianceManagerImpl.java | 11 ------- 3 files changed, 12 insertions(+), 35 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/b42a813f/patches/systemvm/debian/config/opt/cloud/bin/cloud-nic.sh ---------------------------------------------------------------------- diff --git a/patches/systemvm/debian/config/opt/cloud/bin/cloud-nic.sh b/patches/systemvm/debian/config/opt/cloud/bin/cloud-nic.sh index 24596f7..b067a98 100755 --- a/patches/systemvm/debian/config/opt/cloud/bin/cloud-nic.sh +++ b/patches/systemvm/debian/config/opt/cloud/bin/cloud-nic.sh @@ -17,13 +17,21 @@ unplug_nic() { sudo sed -i /"$tableNo $tableName"/d /etc/iproute2/rt_tables 2>/dev/null sudo ip route flush cache # remove network usage rules - sudo iptables -t mangle -F NETWORK_STATS_$dev 2>/dev/null - iptables-save -t mangle | grep NETWORK_STATS_$dev | grep "\-A" | while read rule + sudo iptables -F NETWORK_STATS_$dev 2>/dev/null + iptables-save | grep NETWORK_STATS_$dev | grep "\-A" | while read rule + do + rule=$(echo $rule | sed 's/\-A/\-D/') + sudo iptables $rule + done + sudo iptables -X NETWORK_STATS_$dev 2>/dev/null + # remove vpn network usage rules + sudo iptables -t mangle -F VPN_STATS_$dev 2>/dev/null + iptables-save -t mangle | grep VPN_STATS_$dev | grep "\-A" | while read rule do rule=$(echo $rule | sed 's/\-A/\-D/') sudo iptables -t mangle $rule done - sudo iptables -t mangle -X NETWORK_STATS_$dev 2>/dev/null + sudo iptables -t mangle -X VPN_STATS_$dev 2>/dev/null # remove rules on this dev iptables-save -t mangle | grep $dev | grep "\-A" | while read rule do http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/b42a813f/patches/systemvm/debian/config/opt/cloud/bin/vpc_netusage.sh ---------------------------------------------------------------------- diff --git a/patches/systemvm/debian/config/opt/cloud/bin/vpc_netusage.sh b/patches/systemvm/debian/config/opt/cloud/bin/vpc_netusage.sh index 743ad32..393b4bb 100755 --- a/patches/systemvm/debian/config/opt/cloud/bin/vpc_netusage.sh +++ b/patches/systemvm/debian/config/opt/cloud/bin/vpc_netusage.sh @@ -53,31 +53,11 @@ create_vpn_usage_rules () { } remove_usage_rules () { - echo $ethDev >> /root/removedVifs - return $? + return 0 } get_usage () { iptables -L NETWORK_STATS_$ethDev -n -v -x 2> /dev/null | awk '$1 ~ /^[0-9]+$/ { printf "%s:", $2}'; > /dev/null - if [ -f /root/removedVifs ] - then - var=`cat /root/removedVifs` - # loop through vifs to be cleared - for i in $var; do - # Make sure vif doesn't exist - if [ ! -f /sys/class/net/$i ] - then - # flush rules and remove chain - iptables -F NETWORK_STATS_$i > /dev/null; - iptables -D FORWARD -j NETWORK_STATS_$i > /dev/null; - iptables -X NETWORK_STATS_$i > /dev/null; - iptables -t mangle -F VPN_STATS_$i > /dev/null; - iptables -t mangle -D FORWARD -j VPN_STATS_$i > /dev/null; - iptables -t mangle -X VPN_STATS_$i > /dev/null; - fi - done - rm /root/removedVifs - fi return 0 } http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/b42a813f/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java index a915561..98613b8 100644 --- a/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java +++ b/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java @@ -366,10 +366,6 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian if (router.getState() == State.Running) { try { Commands cmds = new Commands(OnError.Stop); - if(network.getTrafficType() == TrafficType.Public){ - NetworkUsageCommand netUsageCmd = new NetworkUsageCommand(router.getPrivateIpAddress(), router.getInstanceName(), "remove", true, nic.getIp()); - cmds.addCommand(netUsageCmd); - } UnPlugNicCommand unplugNicCmd = new UnPlugNicCommand(nic, vm.getName()); cmds.addCommand("unplugnic", unplugNicCmd); _agentMgr.send(dest.getHost().getId(), cmds); @@ -378,13 +374,6 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian if (!(unplugNicAnswer != null && unplugNicAnswer.getResult())) { s_logger.warn("Unable to unplug nic from router " + router); result = false; - } else { - if(network.getTrafficType() == TrafficType.Public){ - NetworkUsageCommand netUsageCmd = new NetworkUsageCommand(router.getPrivateIpAddress(), router.getInstanceName(), "remove", true, nic.getIp()); - cmds = new Commands(OnError.Stop); - cmds.addCommand(netUsageCmd); - _agentMgr.send(dest.getHost().getId(), cmds); - } } } catch (OperationTimedoutException e) { throw new AgentUnavailableException("Unable to unplug nic from rotuer " + router + " from network " + network,