Skip to content

Commit 069bc36

Browse files
author
Sheng Yang
committed
CLOUDSTACK-5779: Make CitrixResource to use VirtualRoutingResource
1 parent 285f23f commit 069bc36

2 files changed

Lines changed: 195 additions & 917 deletions

File tree

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

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,6 @@ private Answer execute(RemoteAccessVpnCfgCommand cmd) {
215215

216216
private Answer execute(SetFirewallRulesCommand cmd) {
217217
String[] results = new String[cmd.getRules().length];
218-
for (int i = 0; i < cmd.getRules().length; i++) {
219-
results[i] = "Failed";
220-
}
221218
String routerAccessIp = cmd.getRouterAccessIp();
222219
String egressDefault = cmd.getAccessDetail(NetworkElementCommand.FIREWALL_EGRESS_DEFAULT);
223220

@@ -260,9 +257,13 @@ private Answer execute(SetFirewallRulesCommand cmd) {
260257
}
261258

262259
if (!result.isSuccess()) {
260+
//FIXME - in the future we have to process each rule separately; now we temporarily set every rule to be false if single rule fails
261+
for (int i = 0; i < results.length; i++) {
262+
results[i] = "Failed: " + result.getDetails();
263+
}
263264
return new SetFirewallRulesAnswer(cmd, false, results);
264265
}
265-
return new SetFirewallRulesAnswer(cmd, true, null);
266+
return new SetFirewallRulesAnswer(cmd, true, results);
266267

267268
}
268269

@@ -292,7 +293,7 @@ private Answer execute(SetPortForwardingRulesCommand cmd) {
292293
return new SetPortForwardingRulesAnswer(cmd, results, endResult);
293294
}
294295

295-
protected Answer SetVPCStaticNatRules(SetStaticNatRulesCommand cmd) {
296+
protected SetStaticNatRulesAnswer SetVPCStaticNatRules(SetStaticNatRulesCommand cmd) {
296297
String[] results = new String[cmd.getRules().length];
297298
int i = 0;
298299
boolean endResult = true;
@@ -315,7 +316,7 @@ protected Answer SetVPCStaticNatRules(SetStaticNatRulesCommand cmd) {
315316

316317
}
317318

318-
private Answer execute(SetStaticNatRulesCommand cmd) {
319+
private SetStaticNatRulesAnswer execute(SetStaticNatRulesCommand cmd) {
319320
if (cmd.getVpcId() != null) {
320321
return SetVPCStaticNatRules(cmd);
321322
}
@@ -364,7 +365,11 @@ private Answer execute(LoadBalancerConfigCommand cmd) {
364365
tmpCfgFileContents += "\n";
365366
}
366367

367-
if (!_vrDeployer.createFileInVR(cmd.getRouterAccessIp(), "/etc/haproxy/", "haproxy.cfg.new", tmpCfgFileContents).isSuccess()) {
368+
String tmpCfgFilePath = "/etc/haproxy/";
369+
String tmpCfgFileName = "haproxy.cfg.new";
370+
ExecutionResult result = _vrDeployer.createFileInVR(cmd.getRouterAccessIp(), tmpCfgFilePath, tmpCfgFileName, tmpCfgFileContents);
371+
372+
if (!result.isSuccess()) {
368373
return new Answer(cmd, false, "Fail to copy LB config file to VR");
369374
}
370375

@@ -401,8 +406,6 @@ private Answer execute(LoadBalancerConfigCommand cmd) {
401406
args += " -s " + sb.toString();
402407
}
403408

404-
ExecutionResult result;
405-
406409
if (cmd.getVpcId() == null) {
407410
args = " -i " + routerIp + args;
408411
result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), "loadbalancer.sh", args);
@@ -490,6 +493,7 @@ protected Answer execute(final DeleteIpAliasCommand cmd) {
490493
for (IpAliasTO ipAliasTO : revokedIpAliasTOs) {
491494
args = args + ipAliasTO.getAlias_count() + ":" + ipAliasTO.getRouterip() + ":" + ipAliasTO.getNetmask() + "-";
492495
}
496+
//this is to ensure that thre is some argument passed to the deleteipAlias script when there are no revoked rules.
493497
args = args + "- ";
494498
List<IpAliasTO> activeIpAliasTOs = cmd.getCreateIpAliasTos();
495499
for (IpAliasTO ipAliasTO : activeIpAliasTOs) {
@@ -514,7 +518,7 @@ private CheckS2SVpnConnectionsAnswer execute(CheckS2SVpnConnectionsCommand cmd)
514518

515519
String args = "";
516520
for (String ip : cmd.getVpnIps()) {
517-
args += " " + ip;
521+
args += ip + " ";
518522
}
519523

520524
ExecutionResult result = _vrDeployer.executeInVR(routerIP, "checkbatchs2svpn.sh", args);
@@ -551,9 +555,9 @@ protected Answer execute(GetDomRVersionCmd cmd) {
551555
}
552556

553557
protected Answer execute(Site2SiteVpnCfgCommand cmd) {
554-
String args;
558+
String args = "";
555559
if (cmd.isCreate()) {
556-
args = "-A";
560+
args += "-A";
557561
args += " -l ";
558562
args += cmd.getLocalPublicIp();
559563
args += " -n ";
@@ -584,7 +588,7 @@ protected Answer execute(Site2SiteVpnCfgCommand cmd) {
584588
args += " -p ";
585589
}
586590
} else {
587-
args = "-D";
591+
args += "-D";
588592
args += " -r ";
589593
args += cmd.getPeerGatewayIp();
590594
args += " -n ";

0 commit comments

Comments
 (0)