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
This commit is contained in:
Marcus Sorensen 2012-10-31 09:42:04 -06:00
parent 761b4f60a1
commit 1c0e2cf3f5

View File

@ -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;