Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -480,11 +480,34 @@ private void handle(UpdateConsoleProxyAgentMsg msg) {
ConsoleProxyAgentVO vo;
String oldProxyIp;
int oldProxyPort;
int newProxyPort = msg.getConsoleProxyPort() == 0 ? CoreGlobalProperty.CONSOLE_PROXY_PORT : msg.getConsoleProxyPort();
int newProxyPort = msg.getConsoleProxyPort() == null ? CoreGlobalProperty.CONSOLE_PROXY_PORT : msg.getConsoleProxyPort();


@Override
public void setup() {
flow(new NoRollbackFlow() {
String __name__ = "verify-console-proxy-port";
@Override
public void run(FlowTrigger trigger, Map data) {
if (msg.getConsoleProxyPort() == null) {
trigger.next();
return;
}

ShellUtils.ShellRunner runner = new ShellUtils.ShellRunner();
runner.setCommand(String.format("netstat -nltp4 | grep -E '%d\\s+'", msg.getConsoleProxyPort()));
runner.setVerbose(false);
runner.setWithSudo(true);
runner.setSuppressTraceLog(true);
ShellResult res = runner.run();
String stdout = res.getStdout();
if (res.getRetCode() == 0) {
trigger.fail(argerr("there is other process using the port: %s", stdout));
} else {
trigger.next();
}
}
});
flow(new Flow() {
String __name__ = "update-console-proxy-agent-vo";
@Override
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/org/zstack/core/CoreGlobalProperty.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ public class CoreGlobalProperty {
public static boolean IS_UPGRADE_START;
@GlobalProperty(name = "shadowEntityOn", defaultValue = "false")
public static boolean SHADOW_ENTITY_ON;
@NumberRange({1024, 49151})
@NumberRange({1, 65535})
@GlobalProperty(name = "consoleProxyPort", defaultValue = "4900")
public static int CONSOLE_PROXY_PORT; // for vnc
@GlobalProperty(name = "httpConsoleProxyPort", defaultValue = "4901")
@NumberRange({1024, 49151})
@NumberRange({1, 65535})
public static int HTTP_CONSOLE_PROXY_PORT; // for terminal
@GlobalProperty(name = "consoleProxyCertFile", defaultValue = "")
public static String CONSOLE_PROXY_CERT_FILE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ public class APIUpdateConsoleProxyAgentMsg extends APIMessage implements Console
private String uuid;
@APIParam
private String consoleProxyOverriddenIp;
@APIParam(required = false)
private int consoleProxyPort;
@APIParam(required = false, numberRange={1, 65535})
private Integer consoleProxyPort;

public int getConsoleProxyPort() {
public Integer getConsoleProxyPort() {
return consoleProxyPort;
}

public void setConsoleProxyPort(int consoleProxyPort) {
public void setConsoleProxyPort(Integer consoleProxyPort) {
this.consoleProxyPort = consoleProxyPort;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ doc {
enclosedIn "updateConsoleProxyAgent"
desc ""
location "body"
type "int"
type "Integer"
optional true
since "4.1.0"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public Result throwExceptionIfError() {
@Param(required = true, nonempty = false, nullElements = false, emptyString = true, noTrim = false)
public java.lang.String consoleProxyOverriddenIp;

@Param(required = false, nonempty = false, nullElements = false, emptyString = true, noTrim = false)
public int consoleProxyPort = 0;
@Param(required = false, nonempty = false, nullElements = false, emptyString = true, numberRange = {1L,65535L}, noTrim = false)
public java.lang.Integer consoleProxyPort;

@Param(required = false)
public java.util.List systemTags;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,14 @@ class ConsoleProxyCase extends SubCase {
}

ConsoleProxyAgentVO agent = dbf.listAll(ConsoleProxyAgentVO)[0]

updateConsoleProxyAgent {
uuid = agent.uuid
consoleProxyOverriddenIp = "127.0.0.2"
}
agent = dbf.reload(agent)
assert agent.consoleProxyOverriddenIp == "127.0.0.2"

updateConsoleProxyAgent {
uuid = agent.uuid
consoleProxyOverriddenIp = "127.0.0.1"
Expand Down