From c5c248cbcac08249bbb4abd7bcc91418676ab9fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tino=20V=C3=A1zquez?= Date: Thu, 5 Jan 2023 13:56:38 +0100 Subject: [PATCH] =?UTF-8?q?L=C2=A0#-:=20YodaStyle=20new=20cop=20compliance?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit abeccc507f83b3ad39cca3f3d5acf6edc0fdc5a6) --- src/cli/oneuser | 2 +- .../dummy-probes.d/vm/monitor/monitor.rb | 4 +-- src/oneprovision/lib/provision/provision.rb | 36 +++++++++---------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/cli/oneuser b/src/cli/oneuser index 2d7a2f5347..e0f1034100 100755 --- a/src/cli/oneuser +++ b/src/cli/oneuser @@ -709,7 +709,7 @@ CommandParser::CmdParser.new(ARGV) do tokens = helper.find_token(user, token_hint, group, false) - if tokens.length.zero? + if tokens.empty? exit_with_code 1, 'No valid tokens found.' end diff --git a/src/im_mad/remotes/dummy-probes.d/vm/monitor/monitor.rb b/src/im_mad/remotes/dummy-probes.d/vm/monitor/monitor.rb index 3beb2b685f..3859651763 100755 --- a/src/im_mad/remotes/dummy-probes.d/vm/monitor/monitor.rb +++ b/src/im_mad/remotes/dummy-probes.d/vm/monitor/monitor.rb @@ -87,8 +87,8 @@ vmpool.each do |vm| base_net = Time.now.to_i % 10000 mon_s = unindent(<<-EOS) - NETTX=#{base_net + (50 * rand(3))} - NETRX=#{base_net + (100 * rand(4))} + NETTX=#{base_net + (rand(3) * 50)} + NETRX=#{base_net + (rand(4) * 100)} MEMORY=#{max_memory * rand(20..100)/100} CPU=#{max_cpu * rand(5..100)/100} DISKRDBYTES=#{rand(1000)} diff --git a/src/oneprovision/lib/provision/provision.rb b/src/oneprovision/lib/provision/provision.rb index 32fadb3f0c..f25cc7bc3e 100644 --- a/src/oneprovision/lib/provision/provision.rb +++ b/src/oneprovision/lib/provision/provision.rb @@ -1034,26 +1034,26 @@ module OneProvision ['ansible_processor_count'] # Compute reserved CPU shares for host - res_cpu = 100 * case host_cpu - when 1..4 - 0 # looks like testing environment - when 5..10 then 1 # reserve 1 core - when 11..20 then 2 # 2 cores - else 3 # 3 cores - end + res_cpu = case host_cpu + when 1..4 + 0 # looks like testing environment + when 5..10 then 1 # reserve 1 core + when 11..20 then 2 # 2 cores + else 3 # 3 cores + end * 100 # Compute reserved MEMORY for host (in KB) - res_mem = 1024 * case host_mem - when 0..4000 - 0 # looks like testing environment - when 4001..6001 then 1000 # reserv - when 6001..10000 then 2000 # 2GB - when 10001..20000 then 4000 # 4GB - when 20001..40000 then 5000 # 5GB - when 40001..64000 then 8000 # 8GB - when 64001..128000 then 12000 # 12GB - else 16000 # 16GB - end + res_mem = case host_mem + when 0..4000 + 0 # looks like testing environment + when 4001..6001 then 1000 # reserv + when 6001..10000 then 2000 # 2GB + when 10001..20000 then 4000 # 4GB + when 20001..40000 then 5000 # 5GB + when 40001..64000 then 8000 # 8GB + when 64001..128000 then 12000 # 12GB + else 16000 # 16GB + end * 1024 rescue StandardError raise OneProvisionLoopException, \ "Missing facts for #{hostname}" \