mirror of
https://github.com/puppetlabs/vmfloaty.git
synced 2026-01-26 05:28:40 -05:00
Fix rubocop issues
This commit is contained in:
parent
9a2cd816df
commit
1e67715e2c
4 changed files with 27 additions and 26 deletions
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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,11 +95,11 @@ 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
|
||||||
puts "When using ABS you must delete all vms that you requested at the same time: Can't delete #{req_hash['request']['job']['id']}: #{hosts} does not include all of #{req_hash['allocated_resources']}"
|
puts "When using ABS you must delete all vms that you requested at the same time: Can't delete #{req_hash['request']['job']['id']}: #{hosts} does not include all of #{req_hash['allocated_resources']}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -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,16 +187,16 @@ 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
|
||||||
|
|
||||||
puts "Posting to ABS #{req_obj.to_json}" if verbose
|
puts "Posting to ABS #{req_obj.to_json}" if verbose
|
||||||
|
|
@ -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)
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue