Fix rubocop issues

This commit is contained in:
Brandon High 2019-12-04 16:40:57 -08:00
parent 9a2cd816df
commit 1e67715e2c
No known key found for this signature in database
GPG key ID: 270079C784FCAFDE
4 changed files with 27 additions and 26 deletions

View file

@ -18,6 +18,8 @@ Layout/HashAlignment:
EnforcedHashRocketStyle: table EnforcedHashRocketStyle: table
Layout/FirstHashElementIndentation: Layout/FirstHashElementIndentation:
EnforcedStyle: consistent EnforcedStyle: consistent
Metrics/ParameterLists:
Enabled: False
Style/StderrPuts: Style/StderrPuts:
Enabled: false Enabled: false

View file

@ -17,7 +17,7 @@ require 'vmfloaty/ssh'
class Vmfloaty class Vmfloaty
include Commander::Methods include Commander::Methods
def run def run # rubocop:disable Metrics/AbcSize
program :version, Vmfloaty::VERSION program :version, Vmfloaty::VERSION
program :description, 'A CLI helper tool for Puppet Labs VM poolers to help you stay afloat' program :description, 'A CLI helper tool for Puppet Labs VM poolers to help you stay afloat'

View file

@ -82,10 +82,10 @@ class ABS
jobs_to_delete = [] jobs_to_delete = []
retStatus = {} ret_status = {}
hosts.each do |host| hosts.each do |host|
retStatus[host] = { ret_status[host] = {
'ok' => false 'ok' => false,
} }
end end
@ -95,8 +95,8 @@ class ABS
req_hash['allocated_resources'].each do |vm_name, _i| req_hash['allocated_resources'].each do |vm_name, _i|
if hosts.include? vm_name['hostname'] if hosts.include? vm_name['hostname']
if all_job_resources_accounted_for(req_hash['allocated_resources'], hosts) if all_job_resources_accounted_for(req_hash['allocated_resources'], hosts)
retStatus[vm_name['hostname']] = { ret_status[vm_name['hostname']] = {
'ok' => true 'ok' => true,
} }
jobs_to_delete.push(req_hash) jobs_to_delete.push(req_hash)
else else
@ -118,7 +118,7 @@ class ABS
return_result = conn.post 'return', req_obj.to_json return_result = conn.post 'return', req_obj.to_json
req_obj['hosts'].each do |host| req_obj['hosts'].each do |host|
response_body[host["hostname"]] = { 'ok' => true } if return_result.body == "OK" response_body[host['hostname']] = { 'ok' => true } if return_result.body == 'OK'
end end
end end
@ -187,15 +187,15 @@ class ABS
}, },
} }
if options["priority"] if options['priority']
if options["priority"] == "high" req_obj[:priority] = if options['priority'] == 'high'
req_obj[:priority] = 1 1
elsif options["priority"] == "medium" elsif options['priority'] == 'medium'
req_obj[:priority] = 2 2
elsif options["priority"] == "low" elsif options['priority'] == 'low'
req_obj[:priority] = 3 3
else else
req_obj[:priority] = options["priority"].to_i options['priority'].to_i
end end
end end
@ -214,12 +214,11 @@ class ABS
queue_place, res_body = check_queue(conn, saved_job_id, req_obj) queue_place, res_body = check_queue(conn, saved_job_id, req_obj)
return translated(res_body) if res_body return translated(res_body) if res_body
sleep_seconds = 10 if i >= 10
sleep_seconds = i if i < 10
puts "Waiting #{sleep_seconds} seconds to check if ABS request has been filled. Queue Position: #{queue_place}... (x#{i})"
sleepSeconds = 10 if i >= 10 sleep(sleep_seconds)
sleepSeconds = i if i < 10
puts "Waiting #{sleepSeconds} seconds to check if ABS request has been filled. Queue Position: #{queue_place}... (x#{i})"
sleep(sleepSeconds)
end end
nil nil
end end
@ -264,7 +263,7 @@ class ABS
res = conn.get 'status' res = conn.get 'status'
return res.body == "OK" res.body == 'OK'
end end
def self.summary(verbose, url) def self.summary(verbose, url)

View file

@ -156,8 +156,8 @@ class Utils
end end
end end
when 'ABS' when 'ABS'
puts "ABS Not OK".red unless status_response puts 'ABS Not OK'.red unless status_response
puts "ABS is OK".green if status_response puts 'ABS is OK'.green if status_response
else else
raise "Invalid service type #{service.type}" raise "Invalid service type #{service.type}"
end end