mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 01:58:41 -05:00
Merge pull request #191 from glennsarti/maint-rubocop
(maint) Fix rubocop offenses
This commit is contained in:
commit
04124a0e7a
4 changed files with 22 additions and 41 deletions
|
|
@ -12,7 +12,7 @@ module Vmpooler
|
|||
require 'yaml'
|
||||
require 'set'
|
||||
|
||||
%w( api graphite logger pool_manager vsphere_helper statsd dummy_statsd ).each do |lib|
|
||||
%w(api graphite logger pool_manager vsphere_helper statsd dummy_statsd).each do |lib|
|
||||
begin
|
||||
require "vmpooler/#{lib}"
|
||||
rescue LoadError
|
||||
|
|
@ -20,12 +20,12 @@ module Vmpooler
|
|||
end
|
||||
end
|
||||
|
||||
def self.config(filepath='vmpooler.yaml')
|
||||
def self.config(filepath = 'vmpooler.yaml')
|
||||
parsed_config = {}
|
||||
|
||||
if ENV['VMPOOLER_CONFIG']
|
||||
# Load configuration from ENV
|
||||
parsed_config = YAML.load(ENV['VMPOOLER_CONFIG'])
|
||||
parsed_config = YAML.safe_load(ENV['VMPOOLER_CONFIG'])
|
||||
else
|
||||
# Load the configuration file from disk
|
||||
config_file = File.expand_path(filepath)
|
||||
|
|
@ -37,8 +37,8 @@ module Vmpooler
|
|||
if parsed_config[:auth]['provider'] == 'dummy'
|
||||
unless ENV['VMPOOLER_DEBUG']
|
||||
warning = [
|
||||
"Dummy authentication should not be used outside of debug mode",
|
||||
"please set environment variable VMPOOLER_DEBUG to 'true' if you want to use dummy authentication",
|
||||
'Dummy authentication should not be used outside of debug mode',
|
||||
'please set environment variable VMPOOLER_DEBUG to \'true\' if you want to use dummy authentication'
|
||||
]
|
||||
|
||||
raise warning.join(";\s")
|
||||
|
|
@ -60,13 +60,13 @@ module Vmpooler
|
|||
parsed_config[:pools].each do |pool|
|
||||
parsed_config[:pool_names] << pool['name']
|
||||
if pool['alias']
|
||||
if pool['alias'].kind_of?(Array)
|
||||
if pool['alias'].is_a?(Array)
|
||||
pool['alias'].each do |a|
|
||||
parsed_config[:alias] ||= {}
|
||||
parsed_config[:alias][a] = pool['name']
|
||||
parsed_config[:pool_names] << a
|
||||
end
|
||||
elsif pool['alias'].kind_of?(String)
|
||||
elsif pool['alias'].is_a?(String)
|
||||
parsed_config[:alias][pool['alias']] = pool['name']
|
||||
parsed_config[:pool_names] << pool['alias']
|
||||
end
|
||||
|
|
@ -83,7 +83,7 @@ module Vmpooler
|
|||
parsed_config
|
||||
end
|
||||
|
||||
def self.new_redis(host='localhost')
|
||||
def self.new_redis(host = 'localhost')
|
||||
Redis.new(host: host)
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -436,7 +436,7 @@ module Vmpooler
|
|||
|
||||
unless maxloop.zero?
|
||||
break if loop_count >= maxloop
|
||||
loop_count = loop_count + 1
|
||||
loop_count += 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -468,7 +468,7 @@ module Vmpooler
|
|||
|
||||
unless maxloop.zero?
|
||||
break if loop_count >= maxloop
|
||||
loop_count = loop_count + 1
|
||||
loop_count += 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -569,7 +569,7 @@ module Vmpooler
|
|||
finish
|
||||
end
|
||||
|
||||
def check_pool(pool,maxloop = 0, loop_delay = 5)
|
||||
def check_pool(pool, maxloop = 0, loop_delay = 5)
|
||||
$logger.log('d', "[*] [#{pool['name']}] starting worker thread")
|
||||
|
||||
$vsphere[pool['name']] ||= Vmpooler::VsphereHelper.new $config, $metrics
|
||||
|
|
@ -582,7 +582,7 @@ module Vmpooler
|
|||
|
||||
unless maxloop.zero?
|
||||
break if loop_count >= maxloop
|
||||
loop_count = loop_count + 1
|
||||
loop_count += 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -722,7 +722,7 @@ module Vmpooler
|
|||
if $redis.get('vmpooler__tasks__clone').to_i < $config[:config]['task_limit'].to_i
|
||||
begin
|
||||
$redis.incr('vmpooler__tasks__clone')
|
||||
clone_vm(pool,vsphere)
|
||||
clone_vm(pool, vsphere)
|
||||
rescue => err
|
||||
$logger.log('s', "[!] [#{pool['name']}] clone failed during check_pool with an error: #{err}")
|
||||
$redis.decr('vmpooler__tasks__clone')
|
||||
|
|
@ -736,7 +736,7 @@ module Vmpooler
|
|||
raise
|
||||
end
|
||||
|
||||
def execute!(maxloop = 0, loop_delay = 1)
|
||||
def execute!(maxloop = 0, loop_delay = 1)
|
||||
$logger.log('d', 'starting vmpooler')
|
||||
|
||||
# Clear out the tasks manager, as we don't know about any tasks at this point
|
||||
|
|
@ -773,7 +773,7 @@ module Vmpooler
|
|||
|
||||
unless maxloop.zero?
|
||||
break if loop_count >= maxloop
|
||||
loop_count = loop_count + 1
|
||||
loop_count += 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue