From 0fd8263f06c0bf7ecae671f3d362a3adf4fb2300 Mon Sep 17 00:00:00 2001 From: Frederick Borges Date: Mon, 19 Oct 2020 15:49:48 +0200 Subject: [PATCH] F #~: Cleaning opennebula_guac (#329) Signed-off-by: Frederick Borges --- src/sunstone/opennebula_guac.rb | 65 --------------------------------- 1 file changed, 65 deletions(-) diff --git a/src/sunstone/opennebula_guac.rb b/src/sunstone/opennebula_guac.rb index 782b651239..4ce60c09fd 100644 --- a/src/sunstone/opennebula_guac.rb +++ b/src/sunstone/opennebula_guac.rb @@ -117,18 +117,6 @@ class OpenNebulaGuac end def proxy(vm_resource, type_connection = 'vnc') - # Check configurations and VM attributes - unless lockfile? - return error(400, 'Guacamole server is not running') - end - - unless running? - return error(400, 'Guacamole server is not running') - end - - unless guacd_running? - return error(400, 'Guacamole proxy daemon is not running') - end # Check configurations and VM attributes if !GUAC_STATES.include?(vm_resource['LCM_STATE']) @@ -179,16 +167,6 @@ class OpenNebulaGuac [200, { :token => data }.to_json] end - def status - if running? - STDOUT.puts 'Guacamole server is running' - true - else - STDOUT.puts 'Guacamole server is NOT running' - false - end - end - private def error(code, msg) @@ -199,49 +177,6 @@ class OpenNebulaGuac [code, OpenNebula::Error.new(msg).to_json] end - def 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 get_guac_pid running? - - def guacd_running? - if File.exist?(@guacd_pid_file) - pid=File.read(@guacd_pid_file).strip - - if system("ps #{pid} 1> /dev/null") - return pid.to_i - end - end - - false - end - alias get_guacd_pid guacd_running? - - def 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 do