Github user kevinxu021 commented on a diff in the pull request:
https://github.com/apache/trafodion/pull/1427#discussion_r172736094
--- Diff: dcs/src/main/java/org/trafodion/dcs/master/FloatingIp.java ---
@@ -61,6 +61,43 @@ public boolean isEnabled() {
return isEnabled;
}
+ public synchronized int unbindScript() throws Exception {
+ if (isEnabled)
+ LOG.info("Floating IP is enabled");
+ else {
+ LOG.info("Floating IP is disabled");
+ return 0;
+ }
+
+ ScriptContext scriptContext = new ScriptContext();
+ scriptContext.setScriptName(Constants.SYS_SHELL_SCRIPT_NAME);
+ scriptContext.setStripStdOut(false);
+ scriptContext.setStripStdErr(false);
+
+ String command =
master.getConfiguration().get(Constants.DCS_MASTER_FLOATING_IP_COMMAND_UNBIND,
+ Constants.DEFAULT_DCS_MASTER_FLOATING_IP_COMMAND_UNBIND);
+
+ scriptContext.setCommand(command);
+ LOG.info("Unbind Floating IP [" + scriptContext.getCommand() +
"]");
+ ScriptManager.getInstance().runScript(scriptContext);// Blocking
call
+
+ StringBuilder sb = new StringBuilder();
+ sb.append("exit code [" + scriptContext.getExitCode() + "]");
+ if (!scriptContext.getStdOut().toString().isEmpty())
+ sb.append(", stdout [" + scriptContext.getStdOut().toString()
+ "]");
+ if (!scriptContext.getStdErr().toString().isEmpty())
+ sb.append(", stderr [" + scriptContext.getStdErr().toString()
+ "]");
+ if (LOG.isErrorEnabled())
+ LOG.info(sb.toString());
+
+ if (scriptContext.getExitCode() == 0)
+ LOG.info("Unbind Floating IP successful");
+ else
+ LOG.error("Unbind Floating IP failed");
--- End diff --
It's better to print exit code.
---