(POOLER-70) Move vSphere configuration into providers section

Previously the vSphere based configuration was in the root of the configuration
YAML.  As there is deprecation support to move the old configuration to the new
location, the vSphere provider can be updated.  This commit updates the vSphere
Provider and tests to use the new configuration location under:

:providers:
  :vsphere:
This commit is contained in:
Glenn Sarti 2017-04-14 16:08:12 -07:00
parent 57eba4a8e4
commit 2e255a5a43
4 changed files with 138 additions and 128 deletions

View file

@ -2,12 +2,6 @@ module Vmpooler
class PoolManager
class Provider
class VSphere < Vmpooler::PoolManager::Provider::Base
def initialize(config, logger, metrics, name, options)
super(config, logger, metrics, name, options)
@credentials = provider_config
@conf = global_config[:config]
end
def name
'vsphere'
end
@ -239,12 +233,6 @@ module Vmpooler
true
end
def provider_config
# The vSphere configuration is currently in it's own root. This will
# eventually shift into the same location base expects it
global_config[:vsphere]
end
# VSphere Helper methods
def get_target_cluster_from_config(pool_name)
@ -279,21 +267,21 @@ module Vmpooler
begin
@connection.serviceInstance.CurrentTime
rescue
@connection = connect_to_vsphere @credentials
@connection = connect_to_vsphere
end
@connection
end
def connect_to_vsphere(credentials)
max_tries = @conf['max_tries'] || 3
retry_factor = @conf['retry_factor'] || 10
def connect_to_vsphere
max_tries = global_config[:config]['max_tries'] || 3
retry_factor = global_config[:config]['retry_factor'] || 10
try = 1
begin
connection = RbVmomi::VIM.connect host: credentials['server'],
user: credentials['username'],
password: credentials['password'],
insecure: credentials['insecure'] || true
connection = RbVmomi::VIM.connect host: provider_config['server'],
user: provider_config['username'],
password: provider_config['password'],
insecure: provider_config['insecure'] || true
metrics.increment('connect.open')
return connection
rescue => err