From cccfec2b21d7d00daf2f214f9f5186dfa63e50a7 Mon Sep 17 00:00:00 2001 From: Tino Vazquez Date: Thu, 30 Apr 2020 17:06:20 +0200 Subject: [PATCH] M #-: Minor adjustements in ruby library load --- .../remotes/vcenter-probes.d/host/system/nsx.rb | 12 +++++------- .../remotes/vcenter-probes.d/host/system/vcenter.rb | 2 +- .../remotes/vcenter-probes.d/vms/monitor/monitor.rb | 2 +- .../remotes/vcenter-probes.d/vms/status/state.rb | 2 +- src/sunstone/sunstone-server.rb | 2 +- 5 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/im_mad/remotes/vcenter-probes.d/host/system/nsx.rb b/src/im_mad/remotes/vcenter-probes.d/host/system/nsx.rb index 387302104b..b87ca8d9d3 100755 --- a/src/im_mad/remotes/vcenter-probes.d/host/system/nsx.rb +++ b/src/im_mad/remotes/vcenter-probes.d/host/system/nsx.rb @@ -16,14 +16,14 @@ # limitations under the License. # #--------------------------------------------------------------------------- # -ONE_LOCATION = ENV['ONE_LOCATION'] if !defined?(ONE_LOCATION) +ONE_LOCATION ||= ENV['ONE_LOCATION'] if !ONE_LOCATION - RUBY_LIB_LOCATION = '/usr/lib/one/ruby' if !defined?(RUBY_LIB_LOCATION) - GEMS_LOCATION = '/usr/share/one/gems' if !defined?(GEMS_LOCATION) + RUBY_LIB_LOCATION ||= '/usr/lib/one/ruby' + GEMS_LOCATION ||= '/usr/share/one/gems' else - RUBY_LIB_LOCATION = ONE_LOCATION + '/lib/ruby' if !defined?(RUBY_LIB_LOCATION) - GEMS_LOCATION = ONE_LOCATION + '/share/gems' if !defined?(GEMS_LOCATION) + RUBY_LIB_LOCATION ||= ONE_LOCATION + '/lib/ruby' + GEMS_LOCATION ||= ONE_LOCATION + '/share/gems' end if File.directory?(GEMS_LOCATION) @@ -51,5 +51,3 @@ rescue StandardError => e STDERR.puts "IM poll for NSX cluster #{host_id} failed due to "\ "\"#{e.message}\"\n#{e.backtrace}" end - - diff --git a/src/im_mad/remotes/vcenter-probes.d/host/system/vcenter.rb b/src/im_mad/remotes/vcenter-probes.d/host/system/vcenter.rb index d61aac29e0..c141f57fad 100755 --- a/src/im_mad/remotes/vcenter-probes.d/host/system/vcenter.rb +++ b/src/im_mad/remotes/vcenter-probes.d/host/system/vcenter.rb @@ -16,7 +16,7 @@ # limitations under the License. # #--------------------------------------------------------------------------- # -ONE_LOCATION = ENV['ONE_LOCATION'] unless defined? ONE_LOCATION +ONE_LOCATION ||= ENV['ONE_LOCATION'] if !ONE_LOCATION RUBY_LIB_LOCATION ||= '/usr/lib/one/ruby' diff --git a/src/im_mad/remotes/vcenter-probes.d/vms/monitor/monitor.rb b/src/im_mad/remotes/vcenter-probes.d/vms/monitor/monitor.rb index c055ff5dec..b59358702d 100755 --- a/src/im_mad/remotes/vcenter-probes.d/vms/monitor/monitor.rb +++ b/src/im_mad/remotes/vcenter-probes.d/vms/monitor/monitor.rb @@ -16,7 +16,7 @@ # limitations under the License. # # -------------------------------------------------------------------------- # -ONE_LOCATION ||= ENV['ONE_LOCATION'] unless defined? ONE_LOCATION +ONE_LOCATION ||= ENV['ONE_LOCATION'] if !ONE_LOCATION RUBY_LIB_LOCATION ||= '/usr/lib/one/ruby' diff --git a/src/im_mad/remotes/vcenter-probes.d/vms/status/state.rb b/src/im_mad/remotes/vcenter-probes.d/vms/status/state.rb index 807728194b..8a94f1c716 100755 --- a/src/im_mad/remotes/vcenter-probes.d/vms/status/state.rb +++ b/src/im_mad/remotes/vcenter-probes.d/vms/status/state.rb @@ -16,7 +16,7 @@ # limitations under the License. # # -------------------------------------------------------------------------- # -ONE_LOCATION = ENV['ONE_LOCATION'] unless defined? ONE_LOCATION +ONE_LOCATION ||= ENV['ONE_LOCATION'] if !ONE_LOCATION RUBY_LIB_LOCATION ||= '/usr/lib/one/ruby' diff --git a/src/sunstone/sunstone-server.rb b/src/sunstone/sunstone-server.rb index 849bf43d0b..55bb7527b1 100755 --- a/src/sunstone/sunstone-server.rb +++ b/src/sunstone/sunstone-server.rb @@ -370,7 +370,7 @@ helpers do if !two_factor_auth_token || two_factor_auth_token == "" return [202, { code: "two_factor_auth", uid: user.id }.to_json] end - serverResponse = + serverResponse = isTwoFactorAuthSuccessful = false if isHOTPConfigured && Sunstone2FAuth.authenticate(user[TWO_FACTOR_AUTH_SECRET_XPATH], two_factor_auth_token) isTwoFactorAuthSuccessful = true