mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 10:08:40 -05:00
Adding support for multiple vsphere providers
Refactoring the vmpooler.yaml format to support multiple providers. The second level key under :providers: is a unique key name that represents a provider that can be refered in the pool's parameter called provider. The code is still backward compatible to support the :vsphere: and :dummy: keys but in reality if you have more than one vsphere configuration you would give them a different name. For example :vsphere-pdx: and :vsphere-bfs: and the actual provider class would be specified as a parameter called 'provider_class'. See tests and examples for more information.
This commit is contained in:
parent
1fcb19bd7b
commit
d93ab332f7
5 changed files with 101 additions and 6 deletions
|
|
@ -1754,7 +1754,7 @@ EOT
|
|||
it 'should call create_provider_object idempotently' do
|
||||
# Even though there are two pools using the vsphere provider (the default), it should only
|
||||
# create the provider object once.
|
||||
expect(subject).to receive(:create_provider_object).with(Object, Object, Object, 'vsphere', Object).and_return(vsphere_provider)
|
||||
expect(subject).to receive(:create_provider_object).with(Object, Object, Object, 'vsphere', 'vsphere', Object).and_return(vsphere_provider)
|
||||
|
||||
subject.execute!(1,0)
|
||||
end
|
||||
|
|
@ -1774,6 +1774,50 @@ EOT
|
|||
end
|
||||
end
|
||||
|
||||
context 'creating multiple vsphere Providers' do
|
||||
let(:vsphere_provider) { double('vsphere_provider') }
|
||||
let(:vsphere_provider2) { double('vsphere_provider') }
|
||||
let(:provider1) { Vmpooler::PoolManager::Provider::Base.new(config, logger, metrics, 'vsphere', provider_options) }
|
||||
let(:provider2) { Vmpooler::PoolManager::Provider::Base.new(config, logger, metrics, 'secondvsphere', provider_options) }
|
||||
let(:config) {
|
||||
YAML.load(<<-EOT
|
||||
---
|
||||
:providers:
|
||||
:vsphere:
|
||||
server: 'blah1'
|
||||
provider_class: 'vsphere'
|
||||
:secondvsphere:
|
||||
server: 'blah2'
|
||||
provider_class: 'vsphere'
|
||||
:pools:
|
||||
- name: #{pool}
|
||||
provider: 'vsphere'
|
||||
- name: 'secondpool'
|
||||
provider: 'secondvsphere'
|
||||
EOT
|
||||
)}
|
||||
|
||||
it 'should call create_provider_object twice' do
|
||||
# The two pools use a different provider name, but each provider_class is vsphere
|
||||
expect(subject).to receive(:create_provider_object).with(Object, Object, Object, "vsphere", "vsphere", Object).and_return(vsphere_provider)
|
||||
expect(subject).to receive(:create_provider_object).with(Object, Object, Object, "vsphere", "secondvsphere", Object).and_return(vsphere_provider2)
|
||||
subject.execute!(1,0)
|
||||
end
|
||||
|
||||
it 'should have vsphere providers with different servers' do
|
||||
allow(subject).to receive(:get_provider_for_pool).with(pool).and_return(provider1)
|
||||
result = subject.get_provider_for_pool(pool)
|
||||
allow(provider1).to receive(:provider_config).and_call_original
|
||||
expect(result.provider_config['server']).to eq('blah1')
|
||||
|
||||
allow(subject).to receive(:get_provider_for_pool).with('secondpool').and_return(provider2)
|
||||
result = subject.get_provider_for_pool('secondpool')
|
||||
allow(provider1).to receive(:provider_config).and_call_original
|
||||
expect(result.provider_config['server']).to eq('blah2')
|
||||
subject.execute!(1,0)
|
||||
end
|
||||
end
|
||||
|
||||
context 'modify configuration on startup' do
|
||||
context 'move vSphere configuration to providers location' do
|
||||
let(:config) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue