mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-25 02:50:08 +03:00
F #3951: Fireedge fallback noVNC private ip
Signed-off-by: Frederick Borges <fborges@opennebula.io>
This commit is contained in:
parent
746db18a17
commit
bb8e071348
@ -81,9 +81,7 @@ define(function(require) {
|
||||
}
|
||||
}
|
||||
|
||||
if (FireedgeValidator.fireedgeToken == ""){
|
||||
FireedgeValidator.validateFireedgeToken(create_socket);
|
||||
}
|
||||
FireedgeValidator.checkFireedgePublicURL(FireedgeValidator.validateFireedgeToken, create_socket);
|
||||
|
||||
$('#loading').hide();
|
||||
});
|
||||
|
@ -181,7 +181,6 @@ define(function(require) {
|
||||
"isExtendedVmInfo": _config["system_config"] && _config["system_config"]["get_extended_vm_info"] && _config["system_config"]["get_extended_vm_info"] === "true",
|
||||
"isLogEnabled": _config["zone_id"] === _config["id_own_federation"] ? true : false,
|
||||
"publicFireedgeEndpoint": _config["system_config"]["public_fireedge_endpoint"],
|
||||
"maxWaitingTries": _config["system_config"]["max_waiting_tries"],
|
||||
};
|
||||
|
||||
return Config;
|
||||
|
@ -178,9 +178,7 @@ define(function(require) {
|
||||
}
|
||||
}
|
||||
|
||||
if (FireedgeValidator.fireedgeToken == ""){
|
||||
FireedgeValidator.validateFireedgeToken(create_socket);
|
||||
}
|
||||
FireedgeValidator.validateFireedgeToken(create_socket);
|
||||
|
||||
}
|
||||
|
||||
@ -303,13 +301,8 @@ define(function(require) {
|
||||
callVNC();
|
||||
}
|
||||
}
|
||||
|
||||
if (FireedgeValidator.fireedgeToken == "") {
|
||||
FireedgeValidator.validateFireedgeToken(remote_connections, callVNC);
|
||||
}
|
||||
else{
|
||||
remote_connections(FireedgeValidator.fireedgeToken);
|
||||
}
|
||||
|
||||
FireedgeValidator.validateFireedgeToken(remote_connections, callVNC);
|
||||
|
||||
return false;
|
||||
});
|
||||
|
@ -175,37 +175,40 @@ define(function(require) {
|
||||
TemplateTable.setup(strippedTemplate, RESOURCE, this.element.ID, context, unshownValues, strippedTemplateVcenter);
|
||||
TemplateTableVcenter.setup(strippedTemplateVcenter, RESOURCE, this.element.ID, context, unshownValues, strippedTemplate);
|
||||
|
||||
var show_buttons = function(){
|
||||
if (fireedge_token != ""){
|
||||
$(".vnc-button").hide();
|
||||
if(that && that.element && that.element.USER_TEMPLATE && that.element.USER_TEMPLATE.HYPERVISOR){
|
||||
if (that.element.USER_TEMPLATE.HYPERVISOR == "vcenter"){
|
||||
$(".vmrc-button").show();
|
||||
$(".guac-button").hide();
|
||||
}
|
||||
if (that.element.USER_TEMPLATE.HYPERVISOR == "kvm"){
|
||||
$(".guac-button").show();
|
||||
$(".vmrc-button").hide();
|
||||
}
|
||||
var show_noVNC_buttons = function(){
|
||||
$(".vnc-button").show();
|
||||
$(".guac-button").hide();
|
||||
$(".vmrc-button").hide();
|
||||
}
|
||||
|
||||
var show_fireedge_buttons = function(){
|
||||
$(".vnc-button").hide();
|
||||
if(that && that.element && that.element.USER_TEMPLATE && that.element.USER_TEMPLATE.HYPERVISOR){
|
||||
if (that.element.USER_TEMPLATE.HYPERVISOR == "vcenter"){
|
||||
$(".vmrc-button").show();
|
||||
$(".guac-button").hide();
|
||||
}
|
||||
else{
|
||||
if (that.element.USER_TEMPLATE.HYPERVISOR == "kvm"){
|
||||
$(".guac-button").show();
|
||||
$(".vmrc-button").hide();
|
||||
}
|
||||
}
|
||||
else{
|
||||
$(".vnc-button").show();
|
||||
$(".guac-button").hide();
|
||||
$(".guac-button").show();
|
||||
$(".vmrc-button").hide();
|
||||
}
|
||||
}
|
||||
|
||||
if (FireedgeValidator.fireedgeToken == ""){
|
||||
FireedgeValidator.validateFireedgeToken(show_buttons);
|
||||
}
|
||||
else{
|
||||
show_buttons();
|
||||
var show_buttons = function(fireedgeToken){
|
||||
if (fireedgeToken != ""){
|
||||
show_fireedge_buttons();
|
||||
}
|
||||
else{
|
||||
show_noVNC_buttons();
|
||||
}
|
||||
}
|
||||
|
||||
FireedgeValidator.validateFireedgeToken(show_buttons, show_noVNC_buttons);
|
||||
|
||||
}
|
||||
});
|
||||
|
@ -16,11 +16,32 @@
|
||||
|
||||
define(function (require) {
|
||||
|
||||
var Config = require("sunstone-config");
|
||||
var Config = require("sunstone-config");
|
||||
var Notifier = require('utils/notifier');
|
||||
|
||||
// user config
|
||||
const fireedge_endpoint = Config.publicFireedgeEndpoint;
|
||||
|
||||
const STATUS = {
|
||||
DISCONNECTED: 0,
|
||||
CONNECTED: 1,
|
||||
PROCESSING: 2
|
||||
};
|
||||
|
||||
var connection = STATUS.DISCONNECTED;
|
||||
|
||||
var _connected = function(){
|
||||
return connection == STATUS.CONNECTED;
|
||||
}
|
||||
|
||||
var _disconnected = function(){
|
||||
return connection == STATUS.DISCONNECTED;
|
||||
}
|
||||
|
||||
var _processing = function(){
|
||||
return connection == STATUS.PROCESSING;
|
||||
}
|
||||
|
||||
/**
|
||||
* Aux function to change the fireedge_token value.
|
||||
*
|
||||
@ -44,27 +65,70 @@ define(function (require) {
|
||||
* be "".
|
||||
*/
|
||||
var _validate_fireedge_token = function(success, error) {
|
||||
$.ajax({
|
||||
url: "/fireedge",
|
||||
type: "GET",
|
||||
success: function(data) {
|
||||
set_fireedge_token(data.token);
|
||||
if (typeof success == "function"){
|
||||
success(fireedge_token);
|
||||
}
|
||||
},
|
||||
error: function(request, response, data) {
|
||||
clear_fireedge_token();
|
||||
if (typeof error == "function"){
|
||||
error();
|
||||
if (is_fireedge_configured && fireedge_token == "" && fireedge_endpoint){
|
||||
console.log("HELLO");
|
||||
$.ajax({
|
||||
url: "/fireedge",
|
||||
type: "GET",
|
||||
success: function(data) {
|
||||
set_fireedge_token(data.token);
|
||||
if (typeof success == "function"){
|
||||
success(fireedge_token);
|
||||
}
|
||||
},
|
||||
error: function(request, response, data) {
|
||||
Notifier.onError(request, {error:{ message: "Fireedge private endpoint is not working, please contact you cloud administrator"}});
|
||||
is_fireedge_configured = false;
|
||||
clear_fireedge_token();
|
||||
if (typeof error == "function"){
|
||||
error();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else if (is_fireedge_configured){
|
||||
if (typeof success == "function"){
|
||||
success(fireedge_token);
|
||||
}
|
||||
});
|
||||
}
|
||||
else{
|
||||
if (typeof error == "function"){
|
||||
error();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var _check_fireedge_public_url = function (success, aux, error) {
|
||||
if (fireedge_endpoint){
|
||||
$.ajax({
|
||||
url: fireedge_endpoint,
|
||||
type: "GET",
|
||||
success: function() {
|
||||
is_fireedge_configured = true;
|
||||
if (typeof success == "function" && typeof aux == "function"){
|
||||
success(aux);
|
||||
}
|
||||
},
|
||||
error: function(request, response, data) {
|
||||
Notifier.onError(request, {error:{ message: "Fireedge public endpoint is not working, please contact you cloud administrator"}});
|
||||
is_fireedge_configured = false;
|
||||
if (typeof error == "function"){
|
||||
error();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
is_fireedge_configured = false;
|
||||
if (typeof error == "function"){
|
||||
error();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var fireedge_validator = {
|
||||
"validateFireedgeToken": _validate_fireedge_token,
|
||||
"fireedgeToken": fireedge_token
|
||||
"checkFireedgePublicURL": _check_fireedge_public_url
|
||||
};
|
||||
|
||||
return fireedge_validator;
|
||||
|
@ -927,12 +927,12 @@ get '/fireedge' do
|
||||
session[:fireedge_token] = fireedge_token
|
||||
|
||||
response = {:token => fireedge_token}
|
||||
[200, response.to_json]
|
||||
rescue StandardError => error
|
||||
logger.info("Fireedge server is not running. Error: #{error}")
|
||||
response = {:token => ""}
|
||||
[400, response.to_json]
|
||||
end
|
||||
|
||||
[200, response.to_json]
|
||||
end
|
||||
|
||||
##############################################################################
|
||||
|
@ -19,6 +19,7 @@
|
||||
<script type="text/javascript">
|
||||
var csrftoken = '<%= session[:csrftoken] %>';
|
||||
var fireedge_token = '<%= session[:fireedge_token] %>';
|
||||
var is_fireedge_configured = <%= !$conf[:public_fireedge_endpoint].nil? && !$conf[:private_fireedge_endpoint].nil? %>
|
||||
var view = JSON.parse('<%= view.to_json %>')
|
||||
var available_views = JSON.parse('["<%=
|
||||
$views_config.available_views(session[:user], session[:user_gname]).join('","')
|
||||
@ -55,8 +56,7 @@
|
||||
'leases' : <%= $conf[:leases] ? $conf[:leases].to_json : "null" %>,
|
||||
'mapped_ips' : '<%= $conf[:mapped_ips] ? $conf[:mapped_ips] : false %>',
|
||||
'get_extended_vm_info': '<%= $conf[:get_extended_vm_info] ? $conf[:get_extended_vm_info] : false %>',
|
||||
'public_fireedge_endpoint': '<%= $conf[:public_fireedge_endpoint] ? $conf[:public_fireedge_endpoint] : "http://localhost:2616" %>',
|
||||
'max_waiting_tries': '<%= $conf[:max_waiting_tries] ? $conf[:max_waiting_tries] : 5 %>',
|
||||
'public_fireedge_endpoint': '<%= $conf[:public_fireedge_endpoint] %>',
|
||||
},
|
||||
'view' : view,
|
||||
'available_views' : available_views,
|
||||
|
Loading…
x
Reference in New Issue
Block a user