Skip to content

Commit 1c0e2cf

Browse files
author
Marcus Sorensen
committed
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
1 parent 761b4f6 commit 1c0e2cf

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

‎core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,35 @@ private Answer execute(SetPortForwardingRulesCommand cmd) {
264264

265265
return new SetPortForwardingRulesAnswer(cmd, results, endResult);
266266
}
267+
268+
protected Answer SetVPCStaticNatRules(SetStaticNatRulesCommand cmd) {
269+
String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
270+
String[] results = new String[cmd.getRules().length];
271+
int i = 0;
272+
boolean endResult = true;
273+
274+
for (StaticNatRuleTO rule : cmd.getRules()) {
275+
String args = rule.revoked() ? " -D" : " -A";
276+
args += " -l " + rule.getSrcIp();
277+
args += " -r " + rule.getDstIp();
278+
279+
String result = routerProxy("vpc_staticnat.sh", routerIp, args);
280+
281+
if(result == null) {
282+
results[i++] = null;
283+
} else {
284+
results[i++] = "Failed";
285+
endResult = false;
286+
}
287+
}
288+
return new SetStaticNatRulesAnswer(cmd, results, endResult);
289+
290+
}
267291

268292
private Answer execute(SetStaticNatRulesCommand cmd) {
293+
if ( cmd.getVpcId() != null ) {
294+
return SetVPCStaticNatRules(cmd);
295+
}
269296
String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
270297
String[] results = new String[cmd.getRules().length];
271298
int i = 0;

0 commit comments

Comments
 (0)