cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject git commit: Summary: Implement Static NAT for KVM VPC
Date Wed, 28 Nov 2012 02:16:13 GMT
Updated Branches:
  refs/heads/4.0 f58747426 -> 626ade99e


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 <marcus@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/626ade99
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/626ade99
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/626ade99

Branch: refs/heads/4.0
Commit: 626ade99ed1eb45555a84c31c62d87fc43687c1f
Parents: f587474
Author: Marcus Sorensen <marcus@betterservers.com>
Authored: Wed Oct 31 09:42:04 2012 -0600
Committer: Joe Brockmeier <jzb@zonker.net>
Committed: Tue Nov 27 20:08:56 2012 -0600

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


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/626ade99/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;


Mime
View raw message