This is an automated email from the ASF dual-hosted git repository.
dahn pushed a commit to branch 4.13
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/4.13 by this push:
new 94474af consoleproxy: Enable console for vms in Stopping/Migrating
state (#3640)
94474af is described below
commit 94474af879bcc194576b37db52bfc04b9efe55e8
Author: Wei Zhou <[email protected]>
AuthorDate: Thu Nov 28 12:03:38 2019 +0100
consoleproxy: Enable console for vms in Stopping/Migrating state (#3640)
---
.../cloud/consoleproxy/ConsoleProxyManagerImpl.java | 5 +++--
.../java/com/cloud/server/ManagementServerImpl.java | 7 ++++++-
ui/scripts/instances.js | 8 +++++---
ui/scripts/system.js | 21 +++++++++------------
4 files changed, 23 insertions(+), 18 deletions(-)
diff --git
a/server/src/main/java/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
b/server/src/main/java/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
index 87dca70..83a53aa 100644
--- a/server/src/main/java/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
+++ b/server/src/main/java/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
@@ -401,9 +401,10 @@ public class ConsoleProxyManagerImpl extends ManagerBase
implements ConsoleProxy
return null;
}
- if (vm != null && vm.getState() != State.Starting && vm.getState() !=
State.Running) {
+ if (vm != null && vm.getState() != State.Starting && vm.getState() !=
State.Running
+ && vm.getState() != State.Stopping && vm.getState() !=
State.Migrating) {
if (s_logger.isInfoEnabled()) {
- s_logger.info("Detected that vm : " + vmId + " is not
currently in starting or running state, we will fail the proxy assignment for
it");
+ s_logger.info("Detected that vm : " + vmId + " is not
currently in starting or running or stopping or migrating state, we will fail
the proxy assignment for it");
}
return null;
}
diff --git a/server/src/main/java/com/cloud/server/ManagementServerImpl.java
b/server/src/main/java/com/cloud/server/ManagementServerImpl.java
index 6cb4574..147c527 100644
--- a/server/src/main/java/com/cloud/server/ManagementServerImpl.java
+++ b/server/src/main/java/com/cloud/server/ManagementServerImpl.java
@@ -2392,7 +2392,12 @@ public class ManagementServerImpl extends ManagerBase
implements ManagementServe
s_logger.trace("Trying to retrieve VNC port from agent about VM "
+ vm.getHostName());
}
- final GetVncPortAnswer answer =
(GetVncPortAnswer)_agentMgr.easySend(vm.getHostId(), new
GetVncPortCommand(vm.getId(), vm.getInstanceName()));
+ GetVncPortAnswer answer = null;
+ if (vm.getState() == State.Migrating && vm.getLastHostId() != null) {
+ answer = (GetVncPortAnswer)_agentMgr.easySend(vm.getLastHostId(),
new GetVncPortCommand(vm.getId(), vm.getInstanceName()));
+ } else {
+ answer = (GetVncPortAnswer)_agentMgr.easySend(vm.getHostId(), new
GetVncPortCommand(vm.getId(), vm.getInstanceName()));
+ }
if (answer != null && answer.getResult()) {
return new Pair<String, Integer>(answer.getAddress(),
answer.getPort());
}
diff --git a/ui/scripts/instances.js b/ui/scripts/instances.js
index 86d49c9..2017963 100644
--- a/ui/scripts/instances.js
+++ b/ui/scripts/instances.js
@@ -3711,9 +3711,6 @@
allowedActions.push("resetSSHKeyForVirtualMachine");
} else if (jsonObj.state == 'Starting') {
// allowedActions.push("stop");
- if (isAdmin()) {
- allowedActions.push("viewConsole");
- }
} else if (jsonObj.state == 'Error') {
allowedActions.push("destroy");
} else if (jsonObj.state == 'Expunging') {
@@ -3721,6 +3718,11 @@
allowedActions.push("expunge");
}
}
+
+ if (jsonObj.state == 'Starting' || jsonObj.state == 'Stopping' ||
jsonObj.state == 'Migrating') {
+ allowedActions.push("viewConsole");
+ }
+
return allowedActions;
}
diff --git a/ui/scripts/system.js b/ui/scripts/system.js
index f6ef03c..5ef561f 100755
--- a/ui/scripts/system.js
+++ b/ui/scripts/system.js
@@ -22071,10 +22071,6 @@
allowedActions.push("migrate");
allowedActions.push("diagnostics");
}
- } else if (jsonObj.state == 'Starting') {
- if (isAdmin()) {
- allowedActions.push("viewConsole");
- }
} else if (jsonObj.state == 'Stopped') {
allowedActions.push("start");
@@ -22083,6 +22079,9 @@
allowedActions.push("remove");
}
+ if (jsonObj.state == 'Starting' || jsonObj.state == 'Stopping' ||
jsonObj.state == 'Migrating') {
+ allowedActions.push("viewConsole");
+ }
return allowedActions;
}
@@ -22095,13 +22094,12 @@
allowedActions.push("viewConsole");
if (isAdmin())
allowedActions.push("migrate");
- } else if (jsonObj.state == 'Starting') {
- if (isAdmin()) {
- allowedActions.push("viewConsole");
- }
} else if (jsonObj.state == 'Stopped') {
allowedActions.push("start");
}
+ if (jsonObj.state == 'Starting' || jsonObj.state == 'Stopping' ||
jsonObj.state == 'Migrating') {
+ allowedActions.push("viewConsole");
+ }
return allowedActions;
}
@@ -22124,10 +22122,6 @@
allowedActions.push("migrate");
allowedActions.push("diagnostics");
}
- } else if (jsonObj.state == 'Starting') {
- if (isAdmin()) {
- allowedActions.push("viewConsole");
- }
} else if (jsonObj.state == 'Stopped') {
allowedActions.push("start");
@@ -22138,6 +22132,9 @@
} else if (jsonObj.state == 'Error') {
allowedActions.push("remove");
}
+ if (jsonObj.state == 'Starting' || jsonObj.state == 'Stopping' ||
jsonObj.state == 'Migrating') {
+ allowedActions.push("viewConsole");
+ }
return allowedActions;
}