mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
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:
parent
761b4f60a1
commit
1c0e2cf3f5
@ -264,8 +264,35 @@ public class VirtualRoutingResource implements Manager {
|
|||||||
|
|
||||||
return new SetPortForwardingRulesAnswer(cmd, results, endResult);
|
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) {
|
private Answer execute(SetStaticNatRulesCommand cmd) {
|
||||||
|
if ( cmd.getVpcId() != null ) {
|
||||||
|
return SetVPCStaticNatRules(cmd);
|
||||||
|
}
|
||||||
String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
|
String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
|
||||||
String[] results = new String[cmd.getRules().length];
|
String[] results = new String[cmd.getRules().length];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user