diff --git a/install.sh b/install.sh index 570e849996..c847549aa5 100755 --- a/install.sh +++ b/install.sh @@ -460,8 +460,7 @@ VAR_DIRS="$VAR_LOCATION/remotes \ SUNSTONE_DIRS="$SUNSTONE_LOCATION/routes \ $SUNSTONE_LOCATION/models \ $SUNSTONE_LOCATION/models/OpenNebulaJSON \ - $SUNSTONE_LOCATION/views \ - $SUNSTONE_LOCATION/services" + $SUNSTONE_LOCATION/views" SUNSTONE_MINIFIED_DIRS="$SUNSTONE_LOCATION/public \ $SUNSTONE_LOCATION/public/dist \ @@ -736,7 +735,6 @@ INSTALL_SUNSTONE_FILES=( SUNSTONE_MODELS_JSON_FILES:$SUNSTONE_LOCATION/models/OpenNebulaJSON SUNSTONE_VIEWS_FILES:$SUNSTONE_LOCATION/views SUNSTONE_ROUTES_FILES:$SUNSTONE_LOCATION/routes - SUNSTONE_SERVICES_FILES:$SUNSTONE_LOCATION/services ) INSTALL_SUNSTONE_PUBLIC_MINIFIED_FILES=( @@ -771,7 +769,6 @@ INSTALL_SUNSTONE_PUBLIC_MINIFIED_FILES=( INSTALL_SUNSTONE_PUBLIC_DEV_DIR=( SUNSTONE_PUBLIC_DEV_DIR:$SUNSTONE_LOCATION SUNSTONE_GUAC_DEV_DIR:$SUNSTONE_LOCATION - SUNSTONE_AUTOREFRESH_DEV_DIR:$SUNSTONE_LOCATION/services/autorefresh ) INSTALL_SUNSTONE_ETC_FILES=( @@ -901,7 +898,6 @@ RUBY_LIB_FILES="src/mad/ruby/ActionManager.rb \ src/oca/ruby/opennebula.rb \ src/sunstone/OpenNebulaVNC.rb \ src/sunstone/OpenNebulaGuac.rb \ - src/sunstone/OpenNebulaAutorefresh.rb \ src/sunstone/OpenNebulaAddons.rb \ src/vmm_mad/remotes/vcenter/vcenter_driver.rb \ src/vmm_mad/remotes/nsx/nsx_driver.rb \ @@ -2381,8 +2377,7 @@ SUNSTONE_FILES="src/sunstone/sunstone-server.rb \ SUNSTONE_BIN_FILES="src/sunstone/bin/sunstone-server \ src/sunstone/bin/guac-server \ - src/sunstone/bin/novnc-server\ - src/sunstone/bin/autorefresh-server" + src/sunstone/bin/novnc-server" SUNSTONE_ETC_FILES="src/sunstone/etc/sunstone-server.conf \ src/sunstone/etc/sunstone-views.yaml \ @@ -2456,8 +2451,6 @@ SUNSTONE_PUBLIC_JS_CONSOLE_FILES="src/sunstone/public/dist/console/vnc.js \ SUNSTONE_PUBLIC_DEV_DIR="src/sunstone/public" -SUNSTONE_AUTOREFRESH_DEV_DIR="src/sunstone/services/autorefresh" - SUNSTONE_ROUTES_FILES="src/sunstone/routes/oneflow.rb \ src/sunstone/routes/vcenter.rb \ src/sunstone/routes/support.rb \ diff --git a/src/sunstone/OpenNebulaAutorefresh.rb b/src/sunstone/OpenNebulaAutorefresh.rb deleted file mode 100644 index d6c739d54a..0000000000 --- a/src/sunstone/OpenNebulaAutorefresh.rb +++ /dev/null @@ -1,209 +0,0 @@ -# -------------------------------------------------------------------------- # -# Copyright 2002-2020, OpenNebula Project, OpenNebula Systems # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); you may # -# not use this file except in compliance with the License. You may obtain # -# a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -#--------------------------------------------------------------------------- # - -require 'opennebula' - -############################################################################## -# Global Variables -############################################################################## - -if !ONE_LOCATION - AUTOREFRESH_LOCK_FILE = "/var/lock/one/.autorefresh.lock" -else - AUTOREFRESH_LOCK_FILE = ONE_LOCATION + "/var/.autorefresh.lock" -end - -KEEPALIVE_TIME = 15 - -LIB_LOCATION="/usr/lib/one" -SUNSTONE_SERVICES_LOCATION=LIB_LOCATION+"/sunstone/services" - -############################################################################## -# Server -############################################################################## - -class OpenNebulaAutorefresh - def initialize(config, logger) - # Basics - @logger = logger - - # Autorefresh - @lock_file = AUTOREFRESH_LOCK_FILE - @server_ip = config[:autorefresh_ip] - @server_port = config[:autorefresh_port] - end - - def start - # Launch error if Autorefresh server is running - if is_autorefresh_running? - message="Autorefresh server already running" - STDERR.puts message - @logger.info message - return false - end - - config_dir = SUNSTONE_SERVICES_LOCATION + "/autorefresh" - config_file = config_dir + "/config.ru" - - # Start Autorefresh server - cmd = "thin start -R #{config_file} -p #{@server_port} -a #{@server_ip}"; - - begin - @logger.info { "Starting Autorefresh server: #{cmd}" } - pid=start_daemon(cmd, AUTOREFRESH_LOG) - rescue Exception => e - @logger.error e.message - return false - end - - begin - File.open(@lock_file, "w") do |f| - f.write(pid.to_s) - end - rescue Exception => e - @logger.error e.message - Process.kill('-KILL', pid) - - return false - end - - # Verify if Autorefresh server is running - sleep 1 - - if !is_autorefresh_running? - message="Error starting Autorefresh server" - STDERR.puts message - @logger.error message - File.delete(@lock_file) if File.exist?(@lock_file) - - return false - end - - - STDOUT.puts "Autorefresh server started" - - true - - end - - def stop(force=false) - pid=get_autorefresh_pid - - if pid - @logger.info "Killing Autorefresh server" - - signal=(force ? '-KILL' : '-TERM') - Process.kill(signal ,pid) - - sleep 1 - - begin - Process.getpgid(pid) - - Process.kill('-KILL', pid) - rescue - end - - if is_autorefresh_running? - message="Autorefresh server is still running" - STDERR.puts message - logger.error message - return false - end - - else - message="Autorefresh server is not running" - @logger.info message - STDERR.puts message - end - true - end - - def status - if is_autorefresh_running? - STDOUT.puts "Autorefresh server is running" - true - else - STDOUT.puts "Autorefresh server is NOT running" - false - end - end - - private - - def is_autorefresh_running? - if File.exist?(@lock_file) - pid=File.read(@lock_file).strip - - if system("ps #{pid} 1> /dev/null") - return pid.to_i - end - - @logger.info "Deleting stale lock file" - File.delete(@lock_file) - end - - false - end - alias_method :get_autorefresh_pid, :is_autorefresh_running? - - def is_lockfile? - dn = File.dirname(@lock_file) - bn = File.basename(@lock_file) - - # Due to restrictions which doesn't allow to stat the lock file - # when Sunstone is running under Apache with SELinux enabled, - # as a workaround we read content of the whole lock directory. - begin - Dir.entries(dn).include?(bn) - rescue StandardError - false - end - end - - if RUBY_VERSION<'1.9' - def spawn(*args) - fork { - command=args[0..-2] - - # Close stdin and point out and err to log file - $stdout.reopen(AUTOREFRESH_LOG, "a") - $stderr.reopen(AUTOREFRESH_LOG, "a") - $stdin.close - - # Detach process from the parent - Process.setsid - - exec(*command) - } - end - end - - def start_daemon(cmd, log) - options={ - :pgroup => true, - :in => :close, - [:out, :err] => [log, "a"], - :close_others => true } - - params=cmd.split(" ")+[options] - pid=spawn( *params ) - - Process.detach(pid) - - pid - end -end diff --git a/src/sunstone/bin/autorefresh-server b/src/sunstone/bin/autorefresh-server deleted file mode 100755 index 0c0d14187b..0000000000 --- a/src/sunstone/bin/autorefresh-server +++ /dev/null @@ -1,90 +0,0 @@ -#!/usr/bin/env ruby -# -*- coding: utf-8 -*- - -# -------------------------------------------------------------------------- # -# Copyright 2002-2020, OpenNebula Project, OpenNebula Systems # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); you may # -# not use this file except in compliance with the License. You may obtain # -# a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -#--------------------------------------------------------------------------- # - -ONE_LOCATION = ENV['ONE_LOCATION'] - -if !ONE_LOCATION - LOG_LOCATION = '/var/log/one' - VAR_LOCATION = '/var/lib/one' - SHARE_LOCATION = '/usr/share/one' - ETC_LOCATION = '/etc/one' - RUBY_LIB_LOCATION = '/usr/lib/one/ruby' - GEMS_LOCATION = '/usr/share/one/gems' -else - VAR_LOCATION = ONE_LOCATION + '/var' - LOG_LOCATION = ONE_LOCATION + '/var' - SHARE_LOCATION = ONE_LOCATION + '/share' - ETC_LOCATION = ONE_LOCATION + '/etc' - RUBY_LIB_LOCATION = ONE_LOCATION + '/lib/ruby' - GEMS_LOCATION = ONE_LOCATION + '/share/gems' -end - -AUTOREFRESH_LOG = LOG_LOCATION + "/autorefresh.log" -CONFIGURATION_FILE = ETC_LOCATION + "/sunstone-server.conf" -PLUGIN_CONFIGURATION_FILE = ETC_LOCATION + "/sunstone-plugins.yaml" -SUNSTONE_ROOT_DIR = File.dirname(__FILE__) - -if File.directory?(GEMS_LOCATION) - $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ } - require 'rubygems' - Gem.use_paths(File.realpath(GEMS_LOCATION)) -end - -$LOAD_PATH << RUBY_LIB_LOCATION -$LOAD_PATH << RUBY_LIB_LOCATION + '/cloud' -$LOAD_PATH << SUNSTONE_ROOT_DIR -$LOAD_PATH << SUNSTONE_ROOT_DIR + '/models' - -require 'logger' -require 'yaml' -require 'OpenNebulaAutorefresh' - -$log=Logger.new(AUTOREFRESH_LOG) - - -begin - conf = YAML.load_file(CONFIGURATION_FILE) -rescue Exception => e - STDERR.puts "Error parsing config file #{CONFIGURATION_FILE}: #{e.message}" - exit 1 -end - -autorefresh=OpenNebulaAutorefresh.new(conf, $log) - -if ARGV[0] - res=case ARGV[0].downcase.to_sym - when :start - autorefresh.start - when :stop - autorefresh.stop(true) - when :restart - autorefresh.stop(true) - sleep 1 - autorefresh.start - when :status - autorefresh.status - end - - if !res - STDERR.puts "Error, check #{AUTOREFRESH_LOG}" - exit(-1) - end -else - exit(-1) -end diff --git a/src/sunstone/bin/sunstone-server b/src/sunstone/bin/sunstone-server index c030b856ee..c2c7acf211 100755 --- a/src/sunstone/bin/sunstone-server +++ b/src/sunstone/bin/sunstone-server @@ -26,7 +26,6 @@ if [ -z "$ONE_LOCATION" ]; then SUNSTONE_CONF=/etc/one/sunstone-server.conf NOVNC_SERVER=/usr/bin/novnc-server GUACAMOLE_SERVER=/usr/bin/guac-server - AUTOREFRESH_SERVER=/usr/bin/autorefresh-server else SUNSTONE_PID=$ONE_LOCATION/var/sunstone.pid SUNSTONE_SERVER=$ONE_LOCATION/lib/sunstone/sunstone-server.rb @@ -36,7 +35,6 @@ else SUNSTONE_CONF=$ONE_LOCATION/etc/sunstone-server.conf NOVNC_SERVER=$ONE_LOCATION/bin/novnc-server GUACAMOLE_SERVER=$ONE_LOCATION/bin/guac-server - AUTOREFRESH_SERVER=$ONE_LOCATION/bin/autorefresh-server fi setup() @@ -65,11 +63,10 @@ setup() start() { - while getopts "ngr" opt; do + while getopts "ng" opt; do case "${opt}" in n) novnc=1 ;; g) guacamole=1 ;; - r) autorefresh=1 ;; *) echo "Invalid option: $OPTARG" 1>&2 ;; esac done @@ -97,15 +94,6 @@ start() fi fi - if [ "$autorefresh" = "1" ]; then - # Start Autorefresh server - $AUTOREFRESH_SERVER start - - if [ "$?" != "0" ]; then - echo "Could not start Autorefresh server" 1>&2 - fi - fi - # Start the sunstone daemon touch $SUNSTONE_LOCK_FILE @@ -114,7 +102,6 @@ start() $NOVNC_SERVER stop $GUACAMOLE_SERVER stop - $AUTOREFRESH_SERVER stop exit 1 fi @@ -126,7 +113,6 @@ start() echo "Check $SUNSTONE_LOG_ERROR and $SUNSTONE_LOG for more information" [ "$novnc" = "1" ] && $NOVNC_SERVER stop [ "$guacamole" = "1" ] && $GUACAMOLE_SERVER stop - [ "$autorefresh" = "1" ] && $AUTOREFRESH_SERVER stop exit 1 else echo $LASTPID > $SUNSTONE_PID @@ -140,7 +126,6 @@ start() echo "Check $SUNSTONE_LOG_ERROR and $SUNSTONE_LOG for more information" [ "$novnc" = "1" ] && $NOVNC_SERVER stop [ "$guacamole" = "1" ] && $GUACAMOLE_SERVER stop - [ "$autorefresh" = "1" ] && $AUTOREFRESH_SERVER stop exit 1 fi @@ -152,11 +137,10 @@ start() # stop() { - while getopts "ngr" opt; do + while getopts "ng" opt; do case "${opt}" in n) novnc=1 ;; g) guacamole=1 ;; - r) autorefresh=1 ;; *) echo "Invalid option: $OPTARG" 1>&2 ;; esac done @@ -167,9 +151,6 @@ stop() # Stop guacamole server [ "$guacamole" = "1" ] && $GUACAMOLE_SERVER stop - # Stop autorefresh server - [ "$autorefresh" = "1" ] && $AUTOREFRESH_SERVER stop - if [ ! -f $SUNSTONE_PID ]; then echo "Couldn't find sunstone-server process pid." >&2 return 1 @@ -189,16 +170,16 @@ stop() case "$1" in start) setup - start -ngr + start -ng ;; stop) - stop -ngr + stop -ng exit $? ;; restart) - stop -ngr 2> /dev/null + stop -ng 2> /dev/null setup - start -ngr + start -ng ;; start-sunstone) setup @@ -208,7 +189,7 @@ case "$1" in stop ;; restart-sunstone) - stop -ngr 2> /dev/null + stop -ng 2> /dev/null setup start ;; diff --git a/src/sunstone/etc/sunstone-server.conf b/src/sunstone/etc/sunstone-server.conf index ef80d62dc2..4b6b58752a 100644 --- a/src/sunstone/etc/sunstone-server.conf +++ b/src/sunstone/etc/sunstone-server.conf @@ -257,12 +257,4 @@ # This change the thresholds of dashboard resource usage :threshold_min: 0 :threshold_low: 33 -:threshold_high: 66 - -################################################################################ -# Autorefresh websocket configuration -################################################################################ - -:zeromq_server: tcp://localhost:2101 -:autorefresh_ip: 127.0.0.1 -:autorefresh_port: 2346 \ No newline at end of file +:threshold_high: 66 \ No newline at end of file diff --git a/src/sunstone/models/SunstoneServer.rb b/src/sunstone/models/SunstoneServer.rb index fe74c6d9be..232e9f4873 100644 --- a/src/sunstone/models/SunstoneServer.rb +++ b/src/sunstone/models/SunstoneServer.rb @@ -21,7 +21,6 @@ include OpenNebulaJSON require 'OpenNebulaVNC' require 'OpenNebulaGuac' -require 'OpenNebulaAutorefresh' require 'OpenNebulaAddons' require 'OpenNebulaJSON/JSONUtils' #include JSONUtils diff --git a/src/sunstone/public/app/app.js b/src/sunstone/public/app/app.js index d18384ec15..5f2cf79c48 100644 --- a/src/sunstone/public/app/app.js +++ b/src/sunstone/public/app/app.js @@ -39,7 +39,6 @@ define(function(require) { var Menu = require('utils/menu'); var Locale = require('utils/locale'); var UserAndZoneTemplate = require('hbs!sunstone/user_and_zone'); - var Websocket = require("utils/websocket"); var _commonDialogs = [ require('utils/dialogs/confirm'), @@ -74,8 +73,6 @@ define(function(require) { Sunstone.showTab(PROVISION_TAB_ID); } - Websocket.start(); - $('#loading').hide(); }); diff --git a/src/sunstone/public/app/sunstone-config.js b/src/sunstone/public/app/sunstone-config.js index 4abebd233e..16ed93bb6d 100644 --- a/src/sunstone/public/app/sunstone-config.js +++ b/src/sunstone/public/app/sunstone-config.js @@ -181,9 +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, - "autorefreshWSS": _config["system_config"]["autorefresh_wss"], - "autorefreshIP": _config["system_config"]["autorefresh_ip"], - "autorefreshPort": _config["system_config"]["autorefresh_port"], }; return Config; diff --git a/src/sunstone/public/app/sunstone.js b/src/sunstone/public/app/sunstone.js index 3edd425b1f..4c9cce3082 100644 --- a/src/sunstone/public/app/sunstone.js +++ b/src/sunstone/public/app/sunstone.js @@ -811,7 +811,7 @@ define(function(require) { return context.data("element"); }; - var _insertPanels = function(tabName, info, contextTabId, context, autorefresh=false) { + var _insertPanels = function(tabName, info, contextTabId, context) { var context = context || $(".sunstone-info", $("#" + tabName)); context.data("element", info[Object.keys(info)[0]]); @@ -885,12 +885,10 @@ define(function(require) { context.html(html); $.each(SunstoneCfg["tabs"][tabName]["panelInstances"], function(panelName, panel) { - if (!autorefresh || panelName == "vm_info_tab"){ - panel.setup(context); + panel.setup(context); - if(isRefresh && prevPanelStates[panelName] && panel.setState){ - panel.setState( prevPanelStates[panelName], context ); - } + if(isRefresh && prevPanelStates[panelName] && panel.setState){ + panel.setState( prevPanelStates[panelName], context ); } }); @@ -916,11 +914,6 @@ define(function(require) { } }; - var _autorefreshVM = function(tabName, info, contextTabId, context) { - _insertPanels(tabName, info, contextTabId, context, true); - }; - - //Runs a predefined action. Wraps the calls to opennebula.js and //can be use to run action depending on conditions and notify them //if desired. Returns 1 if some problem has been detected: i.e @@ -1365,7 +1358,6 @@ define(function(require) { "insertTabs": _insertTabs, "insertPanels": _insertPanels, - "autorefreshVM": _autorefreshVM, "getElementRightInfo": _getElementRightInfo, "showTab": _showTab, diff --git a/src/sunstone/public/app/tabs/vms-tab/panels/info.js b/src/sunstone/public/app/tabs/vms-tab/panels/info.js index ba4d51a1d5..eb82445f60 100644 --- a/src/sunstone/public/app/tabs/vms-tab/panels/info.js +++ b/src/sunstone/public/app/tabs/vms-tab/panels/info.js @@ -27,7 +27,6 @@ define(function(require) { var TemplateTableVcenter = require("utils/panel/template-table"); var OpenNebula = require("opennebula"); var Navigation = require("utils/navigation"); - var Websocket = require("utils/websocket"); /* TEMPLATES @@ -170,8 +169,5 @@ define(function(require) { } TemplateTable.setup(strippedTemplate, RESOURCE, this.element.ID, context, unshownValues, strippedTemplateVcenter); TemplateTableVcenter.setup(strippedTemplateVcenter, RESOURCE, this.element.ID, context, unshownValues, strippedTemplate); - - Websocket.subscribe(this.element.ID); - } }); diff --git a/src/sunstone/public/app/tabs/vms-tab/panels/info/html.hbs b/src/sunstone/public/app/tabs/vms-tab/panels/info/html.hbs index bfe04f510d..aa02804fff 100644 --- a/src/sunstone/public/app/tabs/vms-tab/panels/info/html.hbs +++ b/src/sunstone/public/app/tabs/vms-tab/panels/info/html.hbs @@ -33,12 +33,12 @@ {{{renameTrHTML}}}