You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ml...@apache.org on 2012/10/31 16:43:13 UTC

git commit: Summary: Implement Static NAT for KVM VPC

Updated Branches:
  refs/heads/master 761b4f60a -> 1c0e2cf3f


Summary: Implement Static NAT for KVM VPC

Detail: SetVPCStaticNatRules was one command that was left off of the initial
VPC implementation. This adds it in.

BUG-ID : CLOUDSTACK-426
Reviewed-by: Marcus Sorensen
Reported-by: Marcus Sorensen
Signed-off-by: Marcus Sorensen <ma...@betterservers.com> 1351698124 -0600


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

Branch: refs/heads/master
Commit: 1c0e2cf3f5969305346cd8190f30f4813c19c6c1
Parents: 761b4f6
Author: Marcus Sorensen <ma...@betterservers.com>
Authored: Wed Oct 31 09:42:04 2012 -0600
Committer: Marcus Sorensen <ma...@betterservers.com>
Committed: Wed Oct 31 09:42:04 2012 -0600

----------------------------------------------------------------------
 .../virtualnetwork/VirtualRoutingResource.java     |   27 +++++++++++++++
 1 files changed, 27 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1c0e2cf3/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 7e53f03..2dc7950 100755
--- a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
+++ b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
@@ -264,8 +264,35 @@ public class VirtualRoutingResource implements Manager {
 
         return new SetPortForwardingRulesAnswer(cmd, results, endResult);
     }
+
+    protected Answer SetVPCStaticNatRules(SetStaticNatRulesCommand cmd) {
+        String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
+        String[] results = new String[cmd.getRules().length];
+        int i = 0;
+        boolean endResult = true;
+
+        for (StaticNatRuleTO rule : cmd.getRules()) {
+            String args = rule.revoked() ? " -D" : " -A";
+            args += " -l " + rule.getSrcIp();
+            args += " -r " + rule.getDstIp();
+
+            String result = routerProxy("vpc_staticnat.sh", routerIp, args);
+            
+            if(result == null) {
+                results[i++] = null;
+            } else {
+                results[i++] = "Failed";
+                endResult = false;
+            }
+        }
+        return new SetStaticNatRulesAnswer(cmd, results, endResult);
+
+    }
     
     private Answer execute(SetStaticNatRulesCommand cmd) {
+        if ( cmd.getVpcId() != null ) {
+            return SetVPCStaticNatRules(cmd);
+        }
         String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
         String[] results = new String[cmd.getRules().length];
         int i = 0;