mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-22 18:50:08 +03:00
* F #2346: upgrade no-vnc Signed-off-by: Jorge Lobo <jlobo@opennebula.systems> (cherry picked from commit 0da407fd10267c4b9d2a4def62f673d8dadd492e)
This commit is contained in:
parent
7bb7a19151
commit
beb85ef212
@ -15,45 +15,23 @@
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
define(function(require) {
|
||||
require('vnc-util');
|
||||
require('vnc-webutil');
|
||||
require('vnc-base64');
|
||||
require('vnc-websock');
|
||||
require('vnc-des');
|
||||
require('vnc-keysymdef');
|
||||
require('vnc-keyboard');
|
||||
require('vnc-input');
|
||||
require('vnc-display');
|
||||
require('vnc-jsunzip');
|
||||
require('vnc-rfb');
|
||||
require('vnc-keysym');
|
||||
|
||||
var RFB = require("vnc-rfb").default;
|
||||
var Config = require("sunstone-config");
|
||||
var rfb;
|
||||
var encrypt = WebUtil.getQueryVar('encrypt', (window.location.protocol === "https:"));
|
||||
var repeaterID = WebUtil.getQueryVar('repeaterID', '');
|
||||
var true_color = WebUtil.getQueryVar('true_color', true);
|
||||
var local_cursor = WebUtil.getQueryVar('cursor', true);
|
||||
var shared = WebUtil.getQueryVar('shared', true);
|
||||
var view_only = WebUtil.getQueryVar('view_only', false);
|
||||
var host = WebUtil.getQueryVar('host', window.location.hostname);
|
||||
var port = WebUtil.getQueryVar('port', window.location.port);
|
||||
var token = WebUtil.getQueryVar('token', null);
|
||||
var password = WebUtil.getQueryVar('password', null);
|
||||
var path = WebUtil.getQueryVar('path', 'websockify');
|
||||
|
||||
function passwordRequired(rfb) {
|
||||
var msg;
|
||||
msg = '<form id="setPasswordForm"';
|
||||
msg += ' style="margin-bottom: 0px">';
|
||||
msg += 'Password Required: ';
|
||||
msg += '<input type=password size=10 id="password_input" class="noVNC_status">';
|
||||
msg += '<\/form>';
|
||||
$D('noVNC_status_bar').setAttribute("class", "noVNC_status_warn");
|
||||
$D('noVNC_status').innerHTML = msg;
|
||||
document.getElementById("setPasswordForm").addEventListener("submit", setPassword);
|
||||
msg = "<form id=\"setPasswordForm\"";
|
||||
msg += " style=\"margin-bottom: 0px\">";
|
||||
msg += "Password Required: ";
|
||||
msg += "<input type=password size=10 id=\"password_input\" class=\"noVNC_status\">";
|
||||
msg += "<\/form>";
|
||||
document.querySelector("#noVNC_status_bar").setAttribute("class", "noVNC_status_warn");
|
||||
document.querySelector("#noVNC_status").innerHTML = msg;
|
||||
document.querySelector("#setPasswordForm").addEventListener("submit", setPassword);
|
||||
}
|
||||
function setPassword(event) {
|
||||
rfb.sendPassword($D('password_input').value);
|
||||
rfb.sendPassword(document.querySelector("#password_input").value);
|
||||
event.preventDefault();
|
||||
return false;
|
||||
}
|
||||
@ -75,15 +53,15 @@ define(function(require) {
|
||||
}
|
||||
function updateState(rfb, state, oldstate, msg) {
|
||||
var s, sb, cad, level;
|
||||
s = $D('noVNC_status');
|
||||
sb = $D('noVNC_status_bar');
|
||||
cad = $D('sendCtrlAltDelButton');
|
||||
s = document.querySelector("#noVNC_status");
|
||||
sb = document.querySelector("#noVNC_status_bar");
|
||||
cad = document.querySelector("#sendCtrlAltDelButton");
|
||||
switch (state) {
|
||||
case 'failed': level = "error"; break;
|
||||
case 'fatal': level = "error"; break;
|
||||
case 'normal': level = "normal"; break;
|
||||
case 'disconnected': level = "normal"; break;
|
||||
case 'loaded': level = "normal"; break;
|
||||
case "failed": level = "error"; break;
|
||||
case "fatal": level = "error"; break;
|
||||
case "normal": level = "normal"; break;
|
||||
case "disconnected": level = "normal"; break;
|
||||
case "loaded": level = "normal"; break;
|
||||
default: level = "warn"; break;
|
||||
}
|
||||
|
||||
@ -94,7 +72,7 @@ define(function(require) {
|
||||
xvpInit(0);
|
||||
}
|
||||
|
||||
if (typeof(msg) !== 'undefined') {
|
||||
if (typeof(msg) !== "undefined") {
|
||||
sb.setAttribute("class", "noVNC_status_" + level);
|
||||
s.innerHTML = msg;
|
||||
}
|
||||
@ -102,62 +80,59 @@ define(function(require) {
|
||||
|
||||
function xvpInit(ver) {
|
||||
var xvpbuttons;
|
||||
xvpbuttons = $D('noVNC_xvp_buttons');
|
||||
xvpbuttons = document.querySelector("#noVNC_xvp_buttons");
|
||||
if (ver >= 1) {
|
||||
xvpbuttons.style.display = 'inline';
|
||||
xvpbuttons.style.display = "inline";
|
||||
} else {
|
||||
xvpbuttons.style.display = 'none';
|
||||
xvpbuttons.style.display = "none";
|
||||
}
|
||||
}
|
||||
|
||||
var host, port, password, path, token;
|
||||
function getQueryVariable(variable)
|
||||
{
|
||||
var query = window.location.search.substring(1);
|
||||
var vars = query.split("&");
|
||||
for (var i=0;i<vars.length;i++) {
|
||||
var pair = vars[i].split("=");
|
||||
if(pair[0] == variable){return pair[1];}
|
||||
}
|
||||
return(false);
|
||||
}
|
||||
|
||||
$D('sendCtrlAltDelButton').style.display = "inline";
|
||||
$D('sendCtrlAltDelButton').onclick = sendCtrlAltDel;
|
||||
$D('xvpShutdownButton').onclick = xvpShutdown;
|
||||
$D('xvpRebootButton').onclick = xvpReboot;
|
||||
$D('xvpResetButton').onclick = xvpReset;
|
||||
token = window.token;
|
||||
var URL = "";
|
||||
var proxy_host = window.location.hostname;
|
||||
var proxy_port = Config.vncProxyPort;
|
||||
var token = getQueryVariable("token");
|
||||
|
||||
WebUtil.init_logging(WebUtil.getQueryVar('logging', 'warn'));
|
||||
document.title = unescape(WebUtil.getQueryVar('title', 'noVNC'));
|
||||
// By default, use the host and port of server that served this file
|
||||
if (window.location.protocol === "https:") {
|
||||
URL = "wss";
|
||||
} else {
|
||||
URL = "ws";
|
||||
}
|
||||
URL += "://" + window.location.hostname;
|
||||
URL += ":" + proxy_port;
|
||||
URL += "?host=" + proxy_host;
|
||||
URL += "&port=" + proxy_port;
|
||||
if(token){
|
||||
URL += "&token=" + token;
|
||||
}
|
||||
URL += "&encrypt=" + Config.vncWSS;
|
||||
|
||||
// if port == 80 (or 443) then it won't be present and should be
|
||||
// set manually
|
||||
if (!port) {
|
||||
if (window.location.protocol.substring(0, 4) == 'http') {
|
||||
port = 80;
|
||||
} else if (window.location.protocol.substring(0, 5) == 'https') {
|
||||
port = 443;
|
||||
}
|
||||
}
|
||||
document.querySelector("#sendCtrlAltDelButton").style.display = "inline";
|
||||
document.querySelector("#sendCtrlAltDelButton").onclick = sendCtrlAltDel;
|
||||
document.querySelector("#xvpShutdownButton").onclick = xvpShutdown;
|
||||
document.querySelector("#xvpRebootButton").onclick = xvpReboot;
|
||||
document.querySelector("#xvpResetButton").onclick = xvpReset;
|
||||
|
||||
// If a token variable is passed in, set the parameter in a cookie.
|
||||
// This is used by nova-novncproxy.
|
||||
if (token) {
|
||||
WebUtil.createCookie('token', token, 1)
|
||||
}
|
||||
|
||||
if ((!host) || (!port)) {
|
||||
updateState('failed',
|
||||
"Must specify host and port in URL");
|
||||
return;
|
||||
}
|
||||
|
||||
rfb = new RFB({'target': $D('noVNC_canvas'),
|
||||
'encrypt': encrypt,
|
||||
'repeaterID': repeaterID,
|
||||
'true_color': true_color,
|
||||
'local_cursor': local_cursor,
|
||||
'shared': shared,
|
||||
'view_only': view_only,
|
||||
'onUpdateState': updateState,
|
||||
'onXvpInit': xvpInit,
|
||||
'onPasswordRequired': passwordRequired});
|
||||
|
||||
if (password) {
|
||||
rfb.connect(host, port, password, path + "?token=" + token);
|
||||
} else {
|
||||
rfb.connect(host, port, undefined, path + "?token=" + token);
|
||||
}
|
||||
})
|
||||
if ((!proxy_host) || (!proxy_port)) {
|
||||
updateState("failed",
|
||||
"Must specify host and port in URL");
|
||||
return;
|
||||
}
|
||||
try{
|
||||
rfb = new RFB(document.querySelector("#VNC_canvas"), URL);
|
||||
}catch(err){
|
||||
console.log("error start NOVNC ", err);
|
||||
}
|
||||
});
|
||||
|
@ -16,6 +16,9 @@
|
||||
|
||||
require.config({
|
||||
paths: {
|
||||
/* Config */
|
||||
"sunstone-config": "sunstone-config",
|
||||
|
||||
/* Almond */
|
||||
"almond": "../bower_components/almond/almond",
|
||||
|
||||
@ -69,18 +72,7 @@ require.config({
|
||||
"flot.tooltip": "../bower_components/flot.tooltip/js/jquery.flot.tooltip",
|
||||
|
||||
/* VNC */
|
||||
"vnc-util": "../bower_components/no-vnc/include/util",
|
||||
"vnc-webutil": "../bower_components/no-vnc/include/webutil",
|
||||
"vnc-base64": "../bower_components/no-vnc/include/base64",
|
||||
"vnc-websock": "../bower_components/no-vnc/include/websock",
|
||||
"vnc-des": "../bower_components/no-vnc/include/des",
|
||||
"vnc-keysymdef": "../bower_components/no-vnc/include/keysymdef",
|
||||
"vnc-keyboard": "../bower_components/no-vnc/include/keyboard",
|
||||
"vnc-input": "../bower_components/no-vnc/include/input",
|
||||
"vnc-display": "../bower_components/no-vnc/include/display",
|
||||
"vnc-jsunzip": "../bower_components/no-vnc/include/jsunzip",
|
||||
"vnc-rfb": "../bower_components/no-vnc/include/rfb",
|
||||
"vnc-keysym": "../bower_components/no-vnc/include/keysym",
|
||||
"vnc-rfb": "../bower_components/no-vnc/lib/rfb",
|
||||
|
||||
/* Spice */
|
||||
"spice-main": "../bower_components/spice-html5/main",
|
||||
@ -263,45 +255,9 @@ require.config({
|
||||
"flot.tooltip": {
|
||||
deps: ["flot"]
|
||||
},
|
||||
|
||||
/* VNC */
|
||||
"vnc-util": {
|
||||
exports: "Util"
|
||||
},
|
||||
"vnc-webutil": {
|
||||
deps: ["vnc-util"]
|
||||
},
|
||||
"vnc-base64": {
|
||||
deps: ["vnc-util"]
|
||||
},
|
||||
"vnc-websock": {
|
||||
deps: ["vnc-util"]
|
||||
},
|
||||
"vnc-des": {
|
||||
deps: ["vnc-util"]
|
||||
},
|
||||
"vnc-keysymdef": {
|
||||
deps: ["vnc-util"]
|
||||
},
|
||||
"vnc-keyboard": {
|
||||
deps: ["vnc-util"]
|
||||
},
|
||||
"vnc-input": {
|
||||
deps: ["vnc-util"]
|
||||
},
|
||||
"vnc-display": {
|
||||
deps: ["vnc-util"]
|
||||
},
|
||||
"vnc-jsunzip": {
|
||||
deps: ["vnc-util"]
|
||||
},
|
||||
"vnc-rfb": {
|
||||
deps: ["vnc-util"]
|
||||
deps: ["sunstone-config"]
|
||||
},
|
||||
"vnc-keysym": {
|
||||
deps: ["vnc-util"]
|
||||
},
|
||||
|
||||
"spice-main": {
|
||||
exports: "SpiceMainConn",
|
||||
deps: [
|
||||
|
@ -847,7 +847,6 @@ define(function(require) {
|
||||
|
||||
// returns true if the vnc button should be enabled
|
||||
function isVNCSupported(element) {
|
||||
console.log("inVNCSupport_function -> ",element);
|
||||
var graphics = element.TEMPLATE.GRAPHICS;
|
||||
var state = parseInt(element.LCM_STATE);
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
<div class="large-12 columns">
|
||||
<h5 class="subheader" id="vnc_dialog">
|
||||
{{tr "VNC"}}
|
||||
<span id="VNC_status">{{tr "Loading"}}</span>
|
||||
<span id="VNC_status"></span>
|
||||
<span id="VNC_buttons" class="right">
|
||||
<button class="button alert" value="Send CtrlAltDel" id="sendCtrlAltDelButton">{{tr "Send CtrlAltDel"}}</button>
|
||||
<a class="button" id="open_in_a_new_window" href="" target="_blank" title="{{tr "Open in a new window"}}">
|
||||
@ -33,7 +33,9 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="reveal-body text-center" style="width:100%; overflow-x:auto">
|
||||
<canvas id="VNC_canvas" width="640px">{{tr "Canvas not supported."}}</canvas>
|
||||
<div id="VNC_canvas" width="640px">
|
||||
<div class="NOVNC_message"></div>
|
||||
</div>
|
||||
<div id="VNC_status_bar" class="VNC_status_bar"></div>
|
||||
</div>
|
||||
</div>
|
@ -15,33 +15,21 @@
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
define(function(require) {
|
||||
INCLUDE_URI = "bower_components/no-vnc/include/";
|
||||
require('vnc-util');
|
||||
require('vnc-webutil');
|
||||
require('vnc-base64');
|
||||
require('vnc-websock');
|
||||
require('vnc-des');
|
||||
require('vnc-keysymdef');
|
||||
require('vnc-keyboard');
|
||||
require('vnc-input');
|
||||
require('vnc-display');
|
||||
require('vnc-jsunzip');
|
||||
require('vnc-rfb');
|
||||
require('vnc-keysym');
|
||||
|
||||
var Config = require('sunstone-config');
|
||||
|
||||
var RFB = require("vnc-rfb").default;
|
||||
var Config = require("sunstone-config");
|
||||
var _lock = false;
|
||||
var _rfb;
|
||||
var _message = "";
|
||||
var _status = "Loading";
|
||||
|
||||
return {
|
||||
'lockStatus': lockStatus,
|
||||
'lock': lock,
|
||||
'unlock': unlock,
|
||||
'vncCallback': vncCallback,
|
||||
'disconnect': disconnect,
|
||||
'sendCtrlAltDel': sendCtrlAltDel
|
||||
}
|
||||
"lockStatus": lockStatus,
|
||||
"lock": lock,
|
||||
"unlock": unlock,
|
||||
"vncCallback": vncCallback,
|
||||
"disconnect": disconnect,
|
||||
"sendCtrlAltDel": sendCtrlAltDel
|
||||
};
|
||||
|
||||
function lockStatus() {
|
||||
return _lock;
|
||||
@ -55,34 +43,64 @@ define(function(require) {
|
||||
_lock = false;
|
||||
}
|
||||
|
||||
function vncCallback(response) {
|
||||
_rfb = new RFB({'target': $D('VNC_canvas'),
|
||||
'encrypt': Config.vncWSS == "yes",
|
||||
'true_color': true,
|
||||
'local_cursor': true,
|
||||
'shared': true,
|
||||
'onUpdateState': updateVNCState});
|
||||
function connected(){
|
||||
status("","Loaded");
|
||||
}
|
||||
|
||||
function status(message="", status=""){
|
||||
_message = message;
|
||||
_status = status;
|
||||
$(".NOVNC_message").text(_message);
|
||||
$("#VNC_status").text(_status);
|
||||
}
|
||||
|
||||
function disconnectedFromServer(e){
|
||||
if (e.detail.clean) {
|
||||
status("", "Loaded");
|
||||
} else {
|
||||
status("Something went wrong, connection is closed", "Failed");
|
||||
}
|
||||
}
|
||||
|
||||
function vncCallback(response) {
|
||||
var URL = "";
|
||||
var proxy_host = window.location.hostname;
|
||||
var proxy_port = Config.vncProxyPort;
|
||||
var pw = response["password"];
|
||||
var token = response["token"];
|
||||
var vm_name = response["vm_name"];
|
||||
var path = '?token=' + token;
|
||||
|
||||
var url = "vnc?";
|
||||
url += "host=" + proxy_host;
|
||||
url += "&port=" + proxy_port;
|
||||
url += "&token=" + token;
|
||||
url += "&encrypt=" + Config.vncWSS;
|
||||
url += "&title=" + vm_name;
|
||||
var protocol = window.location.protocol;
|
||||
var hostname = window.location.hostname;
|
||||
var port = window.location.port;
|
||||
if (protocol === "https:") {
|
||||
URL = "wss";
|
||||
} else {
|
||||
URL = "ws";
|
||||
}
|
||||
URL += "://" + hostname;
|
||||
URL += ":" + proxy_port;
|
||||
URL += "?host=" + proxy_host;
|
||||
URL += "&port=" + proxy_port;
|
||||
URL += "&token=" + token;
|
||||
URL += "&encrypt=" + Config.vncWSS;
|
||||
URL += "&title=" + vm_name;
|
||||
|
||||
if (!Config.requestVNCPassword) {
|
||||
url += "&password=" + pw;
|
||||
URL += "&password=" + pw;
|
||||
}
|
||||
var re = new RegExp("^(ws|wss):\\/\\/[\\w\\D]*?\\?", "gi");
|
||||
var link = URL.replace(re, protocol + "//" + hostname + ":" + port + "/vnc?");
|
||||
|
||||
try{
|
||||
_rfb = new RFB(document.querySelector("#VNC_canvas"), URL);
|
||||
_rfb.addEventListener("connect", connected);
|
||||
_rfb.addEventListener("disconnect", disconnectedFromServer);
|
||||
}catch(err){
|
||||
status("Something went wrong, connection is closed", "Failed");
|
||||
console.log("error start NOVNC ", err);
|
||||
}
|
||||
|
||||
$("#open_in_a_new_window").attr('href', url);
|
||||
_rfb.connect(proxy_host, proxy_port, pw, path);
|
||||
$("#open_in_a_new_window").attr("href", link);
|
||||
}
|
||||
|
||||
function disconnect() {
|
||||
@ -92,31 +110,4 @@ define(function(require) {
|
||||
function sendCtrlAltDel() {
|
||||
if (_rfb) { _rfb.sendCtrlAltDel(); }
|
||||
}
|
||||
|
||||
//This is taken from noVNC examples
|
||||
function updateVNCState(rfb, state, oldstate, msg) {
|
||||
var s, sb, cad, klass;
|
||||
s = $D('VNC_status');
|
||||
sb = $D('VNC_status_bar');
|
||||
cad = $D('sendCtrlAltDelButton');
|
||||
switch (state) {
|
||||
case 'failed': level = "error"; break;
|
||||
case 'fatal': level = "error"; break;
|
||||
case 'normal': level = "normal"; break;
|
||||
case 'disconnected': level = "normal"; break;
|
||||
case 'loaded': level = "normal"; break;
|
||||
default: level = "warn"; break;
|
||||
}
|
||||
|
||||
if (state === "normal") {
|
||||
cad.disabled = false;
|
||||
} else {
|
||||
cad.disabled = true;
|
||||
}
|
||||
|
||||
if (typeof(msg) !== 'undefined') {
|
||||
sb.setAttribute("class", "noVNC_status_" + level);
|
||||
s.innerHTML = msg;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -5,7 +5,7 @@
|
||||
"jgrowl": "1.4.2",
|
||||
"fontawesome": "5.0.7",
|
||||
"flot.tooltip": "0.8.4",
|
||||
"no-vnc": "0.5.1",
|
||||
"no-vnc": "1.1.0",
|
||||
"resumablejs": "git://github.com/23/resumable.js.git#420cd351c5",
|
||||
"spice-html5": "git://anongit.freedesktop.org/spice/spice-html5#spice-html5-0.1.6",
|
||||
"require-handlebars-plugin": "0.11.2",
|
||||
|
@ -31,6 +31,8 @@ install_patch() {
|
||||
|
||||
bower install --force --allow-root --config.interactive=false
|
||||
|
||||
(cd bower_components/no-vnc/ && npm install && ./utils/use_require.js --clean --as amd && sed -i -e "s/'\.\//'\.\.\/bower_components\/no-vnc\/lib\//g" lib/rfb.js )
|
||||
|
||||
PATCH_DIR="./patches/"
|
||||
|
||||
for i in `ls ${PATCH_DIR}` ; do
|
||||
|
@ -115,10 +115,13 @@ html {
|
||||
}
|
||||
#noVNC_screen {
|
||||
text-align: center;
|
||||
display: table;
|
||||
width:100%;
|
||||
height:100%;
|
||||
/*border-top-left-radius: 800px 600px;*/
|
||||
width: 100%;
|
||||
display: inline-flex;
|
||||
height: 100%;
|
||||
flex-direction: column;
|
||||
}
|
||||
#noVNC_screen > #VNC_canvas{
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
#noVNC_container, #noVNC_canvas {
|
||||
|
@ -1,16 +0,0 @@
|
||||
diff -ru public.old/bower_components/no-vnc/include/keyboard.js public.new/bower_components/no-vnc/include/keyboard.js
|
||||
--- public.old/bower_components/no-vnc/include/keyboard.js 2014-11-29 10:46:27.000000000 +0100
|
||||
+++ public.new/bower_components/no-vnc/include/keyboard.js 2017-05-25 17:02:59.184008613 +0200
|
||||
@@ -407,12 +407,6 @@
|
||||
case 'keydown':
|
||||
// is the next element a keypress? Then we should merge the two
|
||||
if (queue.length !== 0 && queue[0].type === 'keypress') {
|
||||
- // Firefox sends keypress even when no char is generated.
|
||||
- // so, if keypress keysym is the same as we'd have guessed from keydown,
|
||||
- // the modifier didn't have any effect, and should not be escaped
|
||||
- if (queue[0].escape && (!cur.keysym || cur.keysym.keysym !== queue[0].keysym.keysym)) {
|
||||
- cur.escape = queue[0].escape;
|
||||
- }
|
||||
cur.keysym = queue[0].keysym;
|
||||
queue = queue.splice(1);
|
||||
}
|
@ -251,6 +251,46 @@ helpers do
|
||||
session[:ip] && session[:ip] == request.ip
|
||||
end
|
||||
|
||||
def build_conf_locals
|
||||
logos_conf = nil
|
||||
begin
|
||||
logos_conf = YAML.load_file(LOGOS_CONFIGURATION_FILE)
|
||||
rescue Exception => e
|
||||
logger.error { "Error parsing config file #{LOGOS_CONFIGURATION_FILE}: #{e.message}" }
|
||||
error 500, ""
|
||||
end
|
||||
serveradmin_client = $cloud_auth.client(nil, session[:active_zone_endpoint])
|
||||
rc = OpenNebula::System.new(serveradmin_client).get_configuration
|
||||
if OpenNebula.is_error?(rc)
|
||||
logger.error { rc.message }
|
||||
error 500, ""
|
||||
end
|
||||
oned_conf_template = rc.to_hash()['TEMPLATE']
|
||||
oned_conf = {}
|
||||
ONED_CONF_OPTS['ALLOWED_KEYS'].each do |key|
|
||||
value = oned_conf_template[key]
|
||||
if key == 'DEFAULT_COST'
|
||||
if value
|
||||
oned_conf[key] = value
|
||||
else
|
||||
oned_conf[key] = ONED_CONF_OPTS['DEFAULT_COST']
|
||||
end
|
||||
else
|
||||
if ONED_CONF_OPTS['ARRAY_KEYS'].include?(key) && !value.is_a?(Array)
|
||||
oned_conf[key] = [value]
|
||||
else
|
||||
oned_conf[key] = value
|
||||
end
|
||||
end
|
||||
end
|
||||
$conf[:locals] = {
|
||||
:logos_conf => logos_conf,
|
||||
:oned_conf => oned_conf,
|
||||
:support => SUPPORT,
|
||||
:upgrade => UPGRADE
|
||||
}
|
||||
end
|
||||
|
||||
def build_session
|
||||
begin
|
||||
result = $cloud_auth.auth(request.env, params)
|
||||
@ -474,51 +514,16 @@ get '/' do
|
||||
return erb :login
|
||||
end
|
||||
|
||||
logos_conf = nil
|
||||
|
||||
begin
|
||||
logos_conf = YAML.load_file(LOGOS_CONFIGURATION_FILE)
|
||||
rescue Exception => e
|
||||
logger.error { "Error parsing config file #{LOGOS_CONFIGURATION_FILE}: #{e.message}" }
|
||||
error 500, ""
|
||||
end
|
||||
|
||||
serveradmin_client = $cloud_auth.client(nil, session[:active_zone_endpoint])
|
||||
|
||||
rc = OpenNebula::System.new(serveradmin_client).get_configuration
|
||||
|
||||
if OpenNebula.is_error?(rc)
|
||||
logger.error { rc.message }
|
||||
error 500, ""
|
||||
end
|
||||
|
||||
oned_conf_template = rc.to_hash()['TEMPLATE']
|
||||
|
||||
oned_conf = {}
|
||||
ONED_CONF_OPTS['ALLOWED_KEYS'].each do |key|
|
||||
value = oned_conf_template[key]
|
||||
if key == 'DEFAULT_COST'
|
||||
if value
|
||||
oned_conf[key] = value
|
||||
else
|
||||
oned_conf[key] = ONED_CONF_OPTS['DEFAULT_COST']
|
||||
end
|
||||
else
|
||||
if ONED_CONF_OPTS['ARRAY_KEYS'].include?(key) && !value.is_a?(Array)
|
||||
oned_conf[key] = [value]
|
||||
else
|
||||
oned_conf[key] = value
|
||||
end
|
||||
end
|
||||
if $conf[:locals].nil?
|
||||
build_conf_locals
|
||||
end
|
||||
|
||||
response.set_cookie("one-user", :value=>"#{session[:user]}")
|
||||
|
||||
erb :index, :locals => {
|
||||
:logos_conf => logos_conf,
|
||||
:oned_conf => oned_conf,
|
||||
:support => SUPPORT,
|
||||
:upgrade => UPGRADE
|
||||
erb :index, :locals => {
|
||||
:logos_conf => $conf[:locals][:logos_conf],
|
||||
:oned_conf => $conf[:locals][:oned_conf],
|
||||
:support => $conf[:locals][:support],
|
||||
:upgrade => $conf[:locals][:upgrade]
|
||||
}
|
||||
end
|
||||
|
||||
@ -536,7 +541,12 @@ get '/vnc' do
|
||||
if !authorized?
|
||||
erb :login
|
||||
else
|
||||
erb :vnc
|
||||
erb :vnc, :locals => {
|
||||
:logos_conf => $conf[:locals][:logos_conf],
|
||||
:oned_conf => $conf[:locals][:oned_conf],
|
||||
:support => $conf[:locals][:support],
|
||||
:upgrade => $conf[:locals][:upgrade]
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1,71 +1,97 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<!--
|
||||
Based on the original:
|
||||
noVNC example: simple example using default UI
|
||||
Copyright (C) 2012 Joel Martin
|
||||
Copyright (C) 2013 Samuel Mannehed for Cendio AB
|
||||
noVNC is licensed under the MPL 2.0 (see LICENSE.txt)
|
||||
This file is licensed under the 2-Clause BSD license (see LICENSE.txt).
|
||||
|
||||
Connect parameters are provided in query string:
|
||||
http://example.com/?host=HOST&port=PORT&encrypt=1&true_color=1
|
||||
-->
|
||||
|
||||
<title><%= params['vm_name']%></title>
|
||||
|
||||
<meta charset="utf-8">
|
||||
|
||||
<!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame
|
||||
Remove this if you use the .htaccess -->
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
|
||||
<!-- Apple iOS Safari settings -->
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
|
||||
<!-- App Start Icon -->
|
||||
<link rel="apple-touch-startup-image" href="images/screen_320x460.png" />
|
||||
<!-- For iOS devices set the icon to use if user bookmarks app on their homescreen -->
|
||||
<link rel="apple-touch-icon" href="images/screen_57x57.png">
|
||||
<!--
|
||||
<link rel="apple-touch-icon-precomposed" href="images/screen_57x57.png" />
|
||||
-->
|
||||
<!-- Stylesheets -->
|
||||
<link rel="stylesheet" type="text/css" href="css/novnc-custom.css" title="plain">
|
||||
<script src="dist/console/vnc.js?v=<%= OpenNebula::VERSION %>"></script>
|
||||
</head>
|
||||
|
||||
<body style="margin: 0px;">
|
||||
<div id="noVNC_screen">
|
||||
<div style="background: #f7f7f7; border-bottom: 1px solid #dfdfdf; padding: 10px 0px 15px 0px">
|
||||
<div id="noVNC_status_bar" class="noVNC_status_bar" style="margin-top: 0px;">
|
||||
<table border=0 width="100%">
|
||||
<tr>
|
||||
<td width="1%" >
|
||||
<img src="images/one_small_logo.png" style="height:40px; vertical-align:top; margin-left: 30px"></td>
|
||||
<td>
|
||||
<div id="noVNC_status" style="position: relative; height: auto;">Loading</div>
|
||||
</td>
|
||||
<td width="1%" >
|
||||
<div id="noVNC_buttons" style="margin-right: 30px">
|
||||
<input type=button value="Send CtrlAltDel"
|
||||
id="sendCtrlAltDelButton">
|
||||
<span id="noVNC_xvp_buttons">
|
||||
<input type=button value="Shutdown"
|
||||
id="xvpShutdownButton">
|
||||
<input type=button value="Reboot"
|
||||
id="xvpRebootButton">
|
||||
<input type=button value="Reset"
|
||||
id="xvpResetButton"></span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<html>
|
||||
<head>
|
||||
<title><%= params['vm_name']%></title>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
|
||||
<link rel="apple-touch-startup-image" href="images/screen_320x460.png" />
|
||||
<link rel="apple-touch-icon" href="images/screen_57x57.png">
|
||||
<!-- Stylesheets -->
|
||||
<link rel="stylesheet" type="text/css" href="css/novnc-custom.css" title="plain">
|
||||
<% view = $views_config.view(session[:user], session[:user_gname], session[:default_view]) %>
|
||||
<script type="text/javascript">
|
||||
var csrftoken = '<%= session[:csrftoken] %>';
|
||||
var view = JSON.parse('<%= view.to_json %>')
|
||||
var available_views = JSON.parse('["<%=
|
||||
$views_config.available_views(session[:user], session[:user_gname]).join('","')
|
||||
%>"]')
|
||||
var all_labels = JSON.parse('["<%=
|
||||
$views_config.get_all_labels(session[:user_gname]).join('","')
|
||||
%>"]')
|
||||
var all_views = JSON.parse('["<%=
|
||||
$views_config.get_all_views.join('","')
|
||||
%>"]')
|
||||
if ('<%= $conf[:addons] %>'){
|
||||
var addons = JSON.parse('<%= $conf[:addons].to_json %>');
|
||||
}
|
||||
var config = {
|
||||
'user_config' : {
|
||||
'lang' : '<%= session[:lang] %>',
|
||||
'vnc_wss' : '<%= session[:vnc_wss] %>',
|
||||
'table_order' : '<%= session[:table_order] %>',
|
||||
'default_view' : '<%= session[:default_view] %>',
|
||||
'page_length' : '<%= session[:page_length] %>'
|
||||
},
|
||||
'system_config' : {
|
||||
'marketplace_url' : '<%= $conf[:marketplace_url] %>',
|
||||
'vnc_request_password' : <%= $conf[:vnc_request_password] || false %>,
|
||||
'vnc_proxy_port' : '<%= $vnc.proxy_port %>',
|
||||
'vnc_client_port' : '<%= $conf[:vnc_client_port] %>',
|
||||
'max_upload_file_size' : <%= $conf[:max_upload_file_size] ? $conf[:max_upload_file_size] : "undefined" %>
|
||||
},
|
||||
'view' : view,
|
||||
'available_views' : available_views,
|
||||
'all_labels' : all_labels,
|
||||
'all_views' : all_views,
|
||||
'user_id' : '<%= session[:user_id] %>',
|
||||
'user_gid' : '<%= session[:user_gid] %>',
|
||||
'display_name' : '<%= session[:display_name] %>',
|
||||
'zone_name' : '<%= session[:zone_name] %>',
|
||||
'zone_id' : '<%= session[:zone_id] %>',
|
||||
'federation_mode' : '<%= session[:federation_mode] %>',
|
||||
'vm_logos' : <%= logos_conf.to_json %>,
|
||||
'oned_conf' : <%= oned_conf.to_json %>,
|
||||
'support' : <%= support.to_json %>,
|
||||
'upgrade' : <%= upgrade.to_json %>,
|
||||
'mode' : '<%= session[:mode] %>'
|
||||
};
|
||||
</script>
|
||||
<script src="dist/console/vnc.js?v=<%= OpenNebula::VERSION %>"></script>
|
||||
</head>
|
||||
<body style="margin: 0px;">
|
||||
<div id="noVNC_screen">
|
||||
<div style="background: #f7f7f7; border-bottom: 1px solid #dfdfdf; padding: 10px 0px 15px 0px">
|
||||
<div id="noVNC_status_bar" class="noVNC_status_bar" style="margin-top: 0px;">
|
||||
<table border=0 width="100%">
|
||||
<tr>
|
||||
<td width="1%" >
|
||||
<img src="images/one_small_logo.png" style="height:40px; vertical-align:top; margin-left: 30px"></td>
|
||||
<td>
|
||||
<div id="noVNC_status" style="position: relative; height: auto;">Loading</div>
|
||||
</td>
|
||||
<td width="1%" >
|
||||
<div id="noVNC_buttons" style="margin-right: 30px">
|
||||
<input type=button value="Send CtrlAltDel"
|
||||
id="sendCtrlAltDelButton">
|
||||
<span id="noVNC_xvp_buttons">
|
||||
<input type=button value="Shutdown"
|
||||
id="xvpShutdownButton">
|
||||
<input type=button value="Reboot"
|
||||
id="xvpRebootButton">
|
||||
<input type=button value="Reset"
|
||||
id="xvpResetButton"></span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div id="VNC_canvas" width="640px" height="20px">
|
||||
<div class="NOVNC_message"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<canvas id="noVNC_canvas" width="640px" height="20px">Canvas not supported.</canvas>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
</body>
|
||||
</html>
|
Loading…
x
Reference in New Issue
Block a user