summaryrefslogtreecommitdiffstats
path: root/app/server-control
diff options
context:
space:
mode:
authorDeepak Kodihalli <dkodihal@in.ibm.com>2018-04-17 05:49:46 -0500
committerGunnar Mills <gmills@us.ibm.com>2018-05-03 03:20:39 +0000
commit15374c85c8ffa3335c815506a0c7f51cf55cac99 (patch)
tree5db5115735fabf3d42d49b991ecb670b6fadff53 /app/server-control
parentdb44b09744fd042123013050010046ada92df0aa (diff)
downloadphosphor-webui-15374c85c8ffa3335c815506a0c7f51cf55cac99.tar.gz
phosphor-webui-15374c85c8ffa3335c815506a0c7f51cf55cac99.zip
Get the Serial over LAN console working
This commit hooks up hterm to a websocket that the BMC's REST server exposes as an access to the host serial console. Writes to the terminal are sent over the websocket and reads from the websocket are written to the terminal. The websocket is open only when the console page in the GUI is loaded. Tested: - The host console can be accessed as expected from the GUI page. - The "Open in new tab" is still unimplemented. I'll code that up in a subsequent commit. - One issue that I've noticed is if you have the console open before the host is powered on, and then you power on the host, at the time the petitboot config menu shows, the text in the terminal stops scrolling and starts wrapping. The work-around is to refresh the page. This doesn't happen for example if you access the console after the host has powered on, or at any other time for that matter. I think this is an hterm.js issue. I'm still investigating. - The console looks desirably performant. The REST server's performance to serve other routes is not impacted when the /console websocket is open. Change-Id: I35fa39d7f63094552061b097c46be0fda79ed14f Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
Diffstat (limited to 'app/server-control')
-rw-r--r--app/server-control/controllers/remote-console-controller.js51
1 files changed, 32 insertions, 19 deletions
diff --git a/app/server-control/controllers/remote-console-controller.js b/app/server-control/controllers/remote-console-controller.js
index d20115e..ee6a591 100644
--- a/app/server-control/controllers/remote-console-controller.js
+++ b/app/server-control/controllers/remote-console-controller.js
@@ -23,35 +23,48 @@ window.angular && (function (angular) {
// See https://github.com/macton/hterm for available hterm options
- //Storage
hterm.defaultStorage = new lib.Storage.Local();
+ var term = new hterm.Terminal("host-console");
+ term.decorate(document.querySelector('#terminal'));
+ //Set cursor color
+ term.prefs_.set('cursor-color', 'rgba(83, 146, 255, .5)');
+ //Set background color
+ term.prefs_.set('background-color', '#19273c');
+ //Allows keyboard input
+ term.installKeyboard();
+
+ //The BMC exposes a websocket at /console0. This can be read
+ //or written to access the host serial console.
+ var hostname = dataService.getHost().replace("https://", '');
+ var host = "wss://" + hostname + "/console0";
+ var ws = new WebSocket(host);
+ ws.onmessage = function (evt) {
+ //websocket -> terminal
+ term.io.print(evt.data);
+ };
- var term = new hterm.Terminal("foo");
+ //terminal -> websocket
term.onTerminalReady = function() {
var io = term.io.push();
io.onVTKeystroke = function(str) {
- console.log(str)
- term.io.print(str);
+ ws.send(str);
};
io.sendString = function(str) {
- console.log(str)
+ ws.send(str);
};
};
- term.decorate(document.querySelector('#terminal'));
- //Set cursor color
- term.prefs_.set('cursor-color', 'rgba(83, 146, 255, .5)');
-
- //Set background color
- term.prefs_.set('background-color', '#19273c');
-
- //Print to console window
- term.io.println('OpenBMC ver.00');
- term.io.println('This is not an actual live connection.');
- term.io.print('root@OpenBmc:');
-
- //Allows keyboard input
- term.installKeyboard();
+ ws.onopen = function() {
+ console.log("websocket opened");
+ };
+ ws.onclose = function() {
+ console.log("websocket closed");
+ };
+ $scope.$on("$destroy", function() {
+ if(ws) {
+ ws.close();
+ }
+ });
$scope.openTerminalWindow = function(){
dataService.setRemoteWindowActive();
OpenPOWER on IntegriCloud