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 24596f794e2..b067a98fb00 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 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 743ad32ca3b..393b4bb12eb 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 } diff --git a/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java index a9155613244..98613b86a06 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,