On 02/04/2016 05:47 PM, Jose Ricardo Ziviani wrote:
- Kimchi needs to display an interface which clients can navigate
to
the web serial console, this commits add a button and the Guest
tab to handles it plus a new api entry.
Signed-off-by: Jose Ricardo Ziviani <joserz(a)linux.vnet.ibm.com>
---
kimchi.conf | 6 ++++++
ui/js/src/kimchi.api.js | 25 +++++++++++++++++++++++++
ui/js/src/kimchi.guest_main.js | 16 ++++++++++++++--
ui/pages/guest.html.tmpl | 5 +++--
4 files changed, 48 insertions(+), 4 deletions(-)
diff --git a/kimchi.conf b/kimchi.conf
index 1b0dbb3..211bfb6 100644
--- a/kimchi.conf
+++ b/kimchi.conf
@@ -22,6 +22,12 @@ tools.staticdir.on = True
tools.staticdir.dir = wok.config.PluginPaths('kimchi').state_dir +
'/screenshots'
tools.nocache.on = False
+[/serial]
+tools.staticdir.on = True
+tools.staticdir.dir = wok.config.PluginPaths('kimchi').ui_dir +
'/serial'
+tools.nocache.on = False
+tools.wokauth.on = True
+
This is not an information that user can change (I know there are more
cases in the same scenario in the kimchi.conf file and I am trying to
fix them time by time).
So it is better to have it add into config.py.in
[/help]
tools.staticdir.on = True
tools.staticdir.dir = wok.config.PluginPaths('kimchi').ui_dir +
'/pages/help'
diff --git a/ui/js/src/kimchi.api.js b/ui/js/src/kimchi.api.js
index af3034b..4534b50 100644
--- a/ui/js/src/kimchi.api.js
+++ b/ui/js/src/kimchi.api.js
@@ -291,6 +291,31 @@ var kimchi = {
});
},
+ serialToVM : function(vm) {
+ wok.requestJSON({
+ url : 'config/',
+ type : 'GET',
+ dataType : 'json'
+ }).done(function(data, textStatus, xhr) {
+ proxy_port = data['websockets_port'];
+ ssl_port = data['ssl_port'];
+ wok.requestJSON({
+ url : "plugins/kimchi/vms/" + encodeURIComponent(vm) +
"/serial",
+ type : "POST",
+ dataType : "json"
+ }).done(function() {
+ url = 'https://' + location.hostname + ':' + ssl_port;
+ url += "/plugins/kimchi/serial/serial.html";
+ url += "?port=" + ssl_port;
+ url += "&path=websockify?token=" +
wok.urlSafeB64Encode(vm+'-console').replace(/=*$/g, "");
+ url += '&encrypt=1';
+ window.open(url);
+ });
+ }).error(function() {
+ wok.message.error.code('KCHAPI6002E');
+ });
+ },
+
vncToVM : function(vm) {
wok.requestJSON({
url : 'config/',
diff --git a/ui/js/src/kimchi.guest_main.js b/ui/js/src/kimchi.guest_main.js
index 257d76e..10138a8 100644
--- a/ui/js/src/kimchi.guest_main.js
+++ b/ui/js/src/kimchi.guest_main.js
@@ -1,7 +1,7 @@
/*
* Project Kimchi
*
- * Copyright IBM, Corp. 2013-2015
+ * Copyright IBM, Corp. 2013-2016
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -233,6 +233,12 @@ kimchi.vmedit = function(event) {
});
};
+kimchi.openVmSerialConsole = function(event) {
+ var button = event.target;
+ var vm = $(button).closest('li[name=guest]');
+ kimchi.serialToVM($(vm).attr('id'));
+};
+
kimchi.openVmConsole = function(event) {
var button = event.target;
var vm = $(button).closest('li[name=guest]');
@@ -595,7 +601,7 @@ kimchi.createGuestLi = function(vmObject, prevScreenImage, openMenu)
{
result.addClass('inactive');
result.find('.distro-icon').addClass('inactive');
result.find('.vnc-link').css("display", "none");
- result.find('.column-vnc').html('--');
+ result.find('.column-vnc').html('--');
//Hide PowerOff
guestActions.find(".shutoff-hidden").hide();
//Hide Pause
@@ -604,6 +610,12 @@ kimchi.createGuestLi = function(vmObject, prevScreenImage, openMenu)
{
guestActions.find(".resume-hidden").hide();
}
+ var serialConsoleLinkActions =
guestActions.find("[name=vm-serial-console]");
+ serialConsoleLinkActions.on("click", function(event) {
+ event.preventDefault();
+ kimchi.openVmSerialConsole(event);
+ });
+
var consoleActions = guestActions.find("[name=vm-console]");
var consoleLinkActions = result.find(".vnc-link");
diff --git a/ui/pages/guest.html.tmpl b/ui/pages/guest.html.tmpl
index c2d9ba8..ef8d9e3 100644
--- a/ui/pages/guest.html.tmpl
+++ b/ui/pages/guest.html.tmpl
@@ -1,7 +1,7 @@
#*
* Project Kimchi
*
- * Copyright IBM, Corp. 2013-2015
+ * Copyright IBM, Corp. 2013-2016
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,6 +38,7 @@
</button>
<ul class="dropdown-menu"
role="menu">
<li role="presentation"><a
nwAct="connect-vnc" class='shutoff-disabled' name="vm-console"
href="#"><i class="fa fa-list-alt"></i>$_("Connect
VNC")</a></li>
+ <li role="presentation"><a
nwAct="connect-serial-console" class='shutoff-hidden'
name="vm-serial-console" href="#"><i class="fa
fa-list-alt"></i>$_("Connect Serial")</a></li>
<!-- <li role="presentation"><a
nwAct="view-vnc" class='shutoff-disabled' name="vm-view-vnc"
href="#"><i class="fa fa-eye"></i>$_("View VNC
Console")</a></li> -->
<li role="presentation"><a
nwAct="edit" name="vm-edit" href="#"><i class="fa
fa-pencil"></i>$_("Edit")</a></li>
<li role="presentation"><a
href="#" nwAct="clone" class='running-disabled'
name="vm-clone"><i class="fa
fa-copy"></i>$_("Clone")</a></li>
@@ -53,7 +54,7 @@
</span>
</span><!--
--><span class='column-type distro-icon'
style='padding-left: 40px !important'></span><!--
- --><span class='column-vnc'><i class="fa fa-spinner
fa-spin"></i><a nwAct="connect-vnc" name="vm-console"
class="vnc-link" href="#">$_("View
Console")</a></span><!--
+ --><span class='column-vnc'><i class="fa fa-spinner
fa-spin"></i><a nwAct="connect-vnc" name="vm-console"
class="vnc-link" href="#">$_("Open
VNC")</a></span><!--
--><span class='column-processors'>
<div class="percentage-label processors-percentage">
</div>