mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 18:08:42 -05:00
Merge pull request #360 from highb/2020-03-05_unsafe_rubocop_fixes
"Unsafe" rubocop fixes
This commit is contained in:
commit
f85f5126e8
19 changed files with 46 additions and 9 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env ruby
|
#!/usr/bin/env ruby
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require 'vmpooler'
|
require 'vmpooler'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module Vmpooler
|
module Vmpooler
|
||||||
require 'date'
|
require 'date'
|
||||||
require 'json'
|
require 'json'
|
||||||
|
|
@ -41,7 +43,7 @@ module Vmpooler
|
||||||
|
|
||||||
# Bail out if someone attempts to start vmpooler with dummy authentication
|
# Bail out if someone attempts to start vmpooler with dummy authentication
|
||||||
# without enbaling debug mode.
|
# without enbaling debug mode.
|
||||||
if parsed_config.has_key? :auth
|
if parsed_config.key? :auth
|
||||||
if parsed_config[:auth]['provider'] == 'dummy'
|
if parsed_config[:auth]['provider'] == 'dummy'
|
||||||
unless ENV['VMPOOLER_DEBUG']
|
unless ENV['VMPOOLER_DEBUG']
|
||||||
warning = [
|
warning = [
|
||||||
|
|
@ -94,7 +96,7 @@ module Vmpooler
|
||||||
parsed_config[:graphite]['port'] = string_to_int(ENV['GRAPHITE_PORT']) if ENV['GRAPHITE_PORT']
|
parsed_config[:graphite]['port'] = string_to_int(ENV['GRAPHITE_PORT']) if ENV['GRAPHITE_PORT']
|
||||||
|
|
||||||
parsed_config[:auth] = parsed_config[:auth] || {} if ENV['AUTH_PROVIDER']
|
parsed_config[:auth] = parsed_config[:auth] || {} if ENV['AUTH_PROVIDER']
|
||||||
if parsed_config.has_key? :auth
|
if parsed_config.key? :auth
|
||||||
parsed_config[:auth]['provider'] = ENV['AUTH_PROVIDER'] if ENV['AUTH_PROVIDER']
|
parsed_config[:auth]['provider'] = ENV['AUTH_PROVIDER'] if ENV['AUTH_PROVIDER']
|
||||||
parsed_config[:auth][:ldap] = parsed_config[:auth][:ldap] || {} if parsed_config[:auth]['provider'] == 'ldap'
|
parsed_config[:auth][:ldap] = parsed_config[:auth][:ldap] || {} if parsed_config[:auth]['provider'] == 'ldap'
|
||||||
parsed_config[:auth][:ldap]['host'] = ENV['LDAP_HOST'] if ENV['LDAP_HOST']
|
parsed_config[:auth][:ldap]['host'] = ENV['LDAP_HOST'] if ENV['LDAP_HOST']
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module Vmpooler
|
module Vmpooler
|
||||||
class API < Sinatra::Base
|
class API < Sinatra::Base
|
||||||
def initialize
|
def initialize
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module Vmpooler
|
module Vmpooler
|
||||||
class API
|
class API
|
||||||
class Dashboard < Sinatra::Base
|
class Dashboard < Sinatra::Base
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module Vmpooler
|
module Vmpooler
|
||||||
|
|
||||||
class API
|
class API
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module Vmpooler
|
module Vmpooler
|
||||||
class API
|
class API
|
||||||
class Reroute < Sinatra::Base
|
class Reroute < Sinatra::Base
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module Vmpooler
|
module Vmpooler
|
||||||
class API
|
class API
|
||||||
class V1 < Sinatra::Base
|
class V1 < Sinatra::Base
|
||||||
|
|
@ -934,7 +936,7 @@ module Vmpooler
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if failure.size > 0
|
if !failure.empty?
|
||||||
status 400
|
status 400
|
||||||
result['failure'] = failure
|
result['failure'] = failure
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module Vmpooler
|
module Vmpooler
|
||||||
class Dashboard < Sinatra::Base
|
class Dashboard < Sinatra::Base
|
||||||
def config
|
def config
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module Vmpooler
|
module Vmpooler
|
||||||
class DummyStatsd
|
class DummyStatsd
|
||||||
attr_reader :server, :port, :prefix
|
attr_reader :server, :port, :prefix
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require 'connection_pool'
|
require 'connection_pool'
|
||||||
|
|
||||||
module Vmpooler
|
module Vmpooler
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require 'rubygems' unless defined?(Gem)
|
require 'rubygems' unless defined?(Gem)
|
||||||
|
|
||||||
module Vmpooler
|
module Vmpooler
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require 'rubygems' unless defined?(Gem)
|
require 'rubygems' unless defined?(Gem)
|
||||||
|
|
||||||
module Vmpooler
|
module Vmpooler
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require 'vmpooler/providers'
|
require 'vmpooler/providers'
|
||||||
require 'spicy-proton'
|
require 'spicy-proton'
|
||||||
|
|
||||||
|
|
@ -54,7 +56,7 @@ module Vmpooler
|
||||||
pool_keys.each do |k|
|
pool_keys.each do |k|
|
||||||
to_set[k] = pool[k]
|
to_set[k] = pool[k]
|
||||||
end
|
end
|
||||||
to_set['alias'] = pool['alias'].join(',') if to_set.has_key?('alias')
|
to_set['alias'] = pool['alias'].join(',') if to_set.key?('alias')
|
||||||
$redis.hmset("vmpooler__pool__#{pool['name']}", to_set.to_a.flatten) unless to_set.empty?
|
$redis.hmset("vmpooler__pool__#{pool['name']}", to_set.to_a.flatten) unless to_set.empty?
|
||||||
end
|
end
|
||||||
previously_configured_pools.each do |pool|
|
previously_configured_pools.each do |pool|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require 'pathname'
|
require 'pathname'
|
||||||
|
|
||||||
module Vmpooler
|
module Vmpooler
|
||||||
|
|
@ -37,7 +39,7 @@ module Vmpooler
|
||||||
# we don't exactly know if the provider name matches the main file name that should be loaded
|
# we don't exactly know if the provider name matches the main file name that should be loaded
|
||||||
# so we use globs to get everything like the name
|
# so we use globs to get everything like the name
|
||||||
# this could mean that vsphere5 and vsphere6 are loaded when only vsphere5 is used
|
# this could mean that vsphere5 and vsphere6 are loaded when only vsphere5 is used
|
||||||
Dir.glob(File.join(gem_path, "*#{name}*.rb")).each do |file|
|
Dir.glob(File.join(gem_path, "*#{name}*.rb")).sort.each do |file|
|
||||||
require file
|
require file
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module Vmpooler
|
module Vmpooler
|
||||||
class PoolManager
|
class PoolManager
|
||||||
class Provider
|
class Provider
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require 'yaml'
|
require 'yaml'
|
||||||
require 'vmpooler/providers/base'
|
require 'vmpooler/providers/base'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require 'vmpooler/providers/base'
|
require 'vmpooler/providers/base'
|
||||||
|
|
||||||
module Vmpooler
|
module Vmpooler
|
||||||
|
|
@ -483,9 +485,9 @@ module Vmpooler
|
||||||
end
|
end
|
||||||
|
|
||||||
# vSphere helper methods
|
# vSphere helper methods
|
||||||
ADAPTER_TYPE = 'lsiLogic'.freeze
|
ADAPTER_TYPE = 'lsiLogic'
|
||||||
DISK_TYPE = 'thin'.freeze
|
DISK_TYPE = 'thin'
|
||||||
DISK_MODE = 'persistent'.freeze
|
DISK_MODE = 'persistent'
|
||||||
|
|
||||||
def ensured_vsphere_connection(connection_pool_object)
|
def ensured_vsphere_connection(connection_pool_object)
|
||||||
connection_pool_object[:connection] = connect_to_vsphere unless vsphere_connection_ok?(connection_pool_object[:connection])
|
connection_pool_object[:connection] = connect_to_vsphere unless vsphere_connection_ok?(connection_pool_object[:connection])
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require 'rubygems' unless defined?(Gem)
|
require 'rubygems' unless defined?(Gem)
|
||||||
require 'statsd'
|
require 'statsd'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module Vmpooler
|
module Vmpooler
|
||||||
VERSION = '0.10.3'.freeze
|
VERSION = '0.10.3'
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue