mirror of
https://github.com/apache/cloudstack.git
synced 2025-12-20 20:43:43 +01:00
CLOUDSTACK-3003 Fixed static route issue in vpc vmware
This commit is contained in:
parent
49ab93cd23
commit
1ab87ef4be
@ -165,6 +165,8 @@ import com.cloud.agent.api.routing.SetSourceNatAnswer;
|
|||||||
import com.cloud.agent.api.routing.SetSourceNatCommand;
|
import com.cloud.agent.api.routing.SetSourceNatCommand;
|
||||||
import com.cloud.agent.api.routing.SetStaticNatRulesAnswer;
|
import com.cloud.agent.api.routing.SetStaticNatRulesAnswer;
|
||||||
import com.cloud.agent.api.routing.SetStaticNatRulesCommand;
|
import com.cloud.agent.api.routing.SetStaticNatRulesCommand;
|
||||||
|
import com.cloud.agent.api.routing.SetStaticRouteAnswer;
|
||||||
|
import com.cloud.agent.api.routing.SetStaticRouteCommand;
|
||||||
import com.cloud.agent.api.routing.Site2SiteVpnCfgCommand;
|
import com.cloud.agent.api.routing.Site2SiteVpnCfgCommand;
|
||||||
import com.cloud.agent.api.routing.VmDataCommand;
|
import com.cloud.agent.api.routing.VmDataCommand;
|
||||||
import com.cloud.agent.api.routing.VpnUsersCfgCommand;
|
import com.cloud.agent.api.routing.VpnUsersCfgCommand;
|
||||||
@ -541,6 +543,8 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||||||
return execute((ScaleVmCommand) cmd);
|
return execute((ScaleVmCommand) cmd);
|
||||||
} else if (clz == PvlanSetupCommand.class) {
|
} else if (clz == PvlanSetupCommand.class) {
|
||||||
return execute((PvlanSetupCommand) cmd);
|
return execute((PvlanSetupCommand) cmd);
|
||||||
|
} else if (clz == SetStaticRouteCommand.class) {
|
||||||
|
answer = execute((SetStaticRouteCommand) cmd);
|
||||||
} else {
|
} else {
|
||||||
answer = Answer.createUnsupportedCommandAnswer(cmd);
|
answer = Answer.createUnsupportedCommandAnswer(cmd);
|
||||||
}
|
}
|
||||||
@ -656,6 +660,52 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||||||
return answer;
|
return answer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private SetStaticRouteAnswer execute(SetStaticRouteCommand cmd) {
|
||||||
|
if (s_logger.isInfoEnabled()) {
|
||||||
|
s_logger.info("Executing resource SetStaticRouteCommand: " + _gson.toJson(cmd));
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean endResult = true;
|
||||||
|
|
||||||
|
String controlIp = getRouterSshControlIp(cmd);
|
||||||
|
String args = "";
|
||||||
|
String[] results = new String[cmd.getStaticRoutes().length];
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
// Extract and build the arguments for the command to be sent to the VR.
|
||||||
|
String [][] rules = cmd.generateSRouteRules();
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
String[] srRules = rules[0];
|
||||||
|
for (int j = 0; j < srRules.length; j++) {
|
||||||
|
sb.append(srRules[j]).append(',');
|
||||||
|
}
|
||||||
|
args += " -a " + sb.toString();
|
||||||
|
|
||||||
|
// Send over the command for execution, via ssh, to the VR.
|
||||||
|
try {
|
||||||
|
VmwareManager mgr = getServiceContext().getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
|
||||||
|
Pair<Boolean, String> result = SshHelper.sshExecute(controlIp, DEFAULT_DOMR_SSHPORT, "root", mgr.getSystemVMKeyFile(), null,
|
||||||
|
"/opt/cloud/bin/vpc_staticroute.sh " + args);
|
||||||
|
|
||||||
|
if (s_logger.isDebugEnabled())
|
||||||
|
s_logger.debug("Executing script on domain router " + controlIp + ": /opt/cloud/bin/vpc_staticroute.sh " + args);
|
||||||
|
|
||||||
|
if (!result.first()) {
|
||||||
|
s_logger.error("SetStaticRouteCommand failure on setting one rule. args: " + args);
|
||||||
|
results[i++] = "Failed";
|
||||||
|
endResult = false;
|
||||||
|
} else {
|
||||||
|
results[i++] = null;
|
||||||
|
}
|
||||||
|
} catch (Throwable e) {
|
||||||
|
s_logger.error("SetStaticRouteCommand(args: " + args + ") failed on setting one rule due to " + VmwareHelper.getExceptionMessage(e), e);
|
||||||
|
results[i++] = "Failed";
|
||||||
|
endResult = false;
|
||||||
|
}
|
||||||
|
return new SetStaticRouteAnswer(cmd, endResult, results);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
protected NetworkUsageAnswer VPCNetworkUsage(NetworkUsageCommand cmd) {
|
protected NetworkUsageAnswer VPCNetworkUsage(NetworkUsageCommand cmd) {
|
||||||
String privateIp = cmd.getPrivateIP();
|
String privateIp = cmd.getPrivateIP();
|
||||||
String option = cmd.getOption();
|
String option = cmd.getOption();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user