mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 01:58:41 -05:00
Merge pull request #244 from puppetlabs/POOLER-92
(POOLER-92) Add the alias information in the API status page for each…
This commit is contained in:
commit
abdc86f164
3 changed files with 95 additions and 5 deletions
74
examples/vmpooler.yaml.dummy-example.aliasedpools
Normal file
74
examples/vmpooler.yaml.dummy-example.aliasedpools
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
---
|
||||
:providers:
|
||||
:dummy:
|
||||
filename: '/tmp/dummy-backing.yaml'
|
||||
|
||||
:redis:
|
||||
server: 'localhost'
|
||||
|
||||
:auth:
|
||||
provider: 'dummy'
|
||||
|
||||
:tagfilter:
|
||||
url: '(.*)\/'
|
||||
|
||||
:config:
|
||||
site_name: 'vmpooler'
|
||||
logfile: '/Users/samuel/workspace/vmpooler/vmpooler.log'
|
||||
task_limit: 10
|
||||
timeout: 15
|
||||
vm_checktime: 15
|
||||
vm_lifetime: 12
|
||||
vm_lifetime_auth: 24
|
||||
allowed_tags:
|
||||
- 'created_by'
|
||||
- 'project'
|
||||
domain: 'company.com'
|
||||
prefix: 'poolvm-'
|
||||
|
||||
:pools:
|
||||
- name: 'debian-7-i386'
|
||||
alias: [ 'debian-7-32' ]
|
||||
template: 'Templates/debian-7-i386'
|
||||
folder: 'Pooled VMs/debian-7-i386'
|
||||
datastore: 'vmstorage'
|
||||
size: 5
|
||||
timeout: 15
|
||||
ready_ttl: 1440
|
||||
provider: dummy
|
||||
- name: 'debian-7-i386-stringalias'
|
||||
alias: 'debian-7-32-stringalias'
|
||||
template: 'Templates/debian-7-i386'
|
||||
folder: 'Pooled VMs/debian-7-i386'
|
||||
datastore: 'vmstorage'
|
||||
size: 5
|
||||
timeout: 15
|
||||
ready_ttl: 1440
|
||||
provider: dummy
|
||||
- name: 'debian-7-x86_64'
|
||||
alias: [ 'debian-7-64', 'debian-7-amd64' ]
|
||||
template: 'Templates/debian-7-x86_64'
|
||||
folder: 'Pooled VMs/debian-7-x86_64'
|
||||
datastore: 'vmstorage'
|
||||
size: 5
|
||||
timeout: 15
|
||||
ready_ttl: 1440
|
||||
provider: dummy
|
||||
- name: 'debian-7-i386-noalias'
|
||||
template: 'Templates/debian-7-i386'
|
||||
folder: 'Pooled VMs/debian-7-i386'
|
||||
datastore: 'vmstorage'
|
||||
size: 5
|
||||
timeout: 15
|
||||
ready_ttl: 1440
|
||||
provider: dummy
|
||||
- name: 'debian-7-x86_64-alias-otherpool-extended'
|
||||
alias: [ 'debian-7-x86_64' ]
|
||||
template: 'Templates/debian-7-x86_64'
|
||||
folder: 'Other Pooled VMs/debian-7-x86_64'
|
||||
datastore: 'other-vmstorage'
|
||||
size: 5
|
||||
timeout: 15
|
||||
ready_ttl: 1440
|
||||
provider: dummy
|
||||
|
||||
|
|
@ -199,6 +199,7 @@ module Vmpooler
|
|||
running = backend.scard('vmpooler__running__' + pool['name']).to_i
|
||||
pending = backend.scard('vmpooler__pending__' + pool['name']).to_i
|
||||
max = pool['size']
|
||||
aka = pool['alias']
|
||||
|
||||
result[:pools][pool['name']] = {
|
||||
ready: ready,
|
||||
|
|
@ -207,6 +208,10 @@ module Vmpooler
|
|||
max: max
|
||||
}
|
||||
|
||||
if aka
|
||||
result[:pools][pool['name']][:alias] = aka
|
||||
end
|
||||
|
||||
# for backwards compatibility, include separate "empty" stats in "status" block
|
||||
if ready == 0
|
||||
result[:status][:empty] ||= []
|
||||
|
|
|
|||
|
|
@ -32,10 +32,10 @@ describe Vmpooler::API::V1 do
|
|||
'vm_lifetime_auth' => 2,
|
||||
},
|
||||
pools: [
|
||||
{'name' => 'pool1', 'size' => 5},
|
||||
{'name' => 'pool2', 'size' => 10}
|
||||
],
|
||||
alias: { 'poolone' => 'pool1' },
|
||||
{'name' => 'pool1', 'size' => 5, 'alias' => ['poolone', 'poolun']},
|
||||
{'name' => 'pool2', 'size' => 10},
|
||||
{'name' => 'pool3', 'size' => 10, 'alias' => 'NotArray'}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -98,13 +98,24 @@ describe Vmpooler::API::V1 do
|
|||
expect(result["pools"]["pool2"]["pending"]).to be(4)
|
||||
end
|
||||
|
||||
it 'returns aliases if configured in the pool' do
|
||||
get "#{prefix}/status/"
|
||||
|
||||
# of course /status doesn't conform to the weird standard everything else uses...
|
||||
expect(last_response.header['Content-Type']).to eq('application/json')
|
||||
result = JSON.parse(last_response.body)
|
||||
expect(result["pools"]["pool1"]["alias"]).to eq(['poolone', 'poolun'])
|
||||
expect(result["pools"]["pool2"]["alias"]).to be(nil)
|
||||
expect(result["pools"]["pool3"]["alias"]).to eq('NotArray')
|
||||
end
|
||||
|
||||
it '(for v1 backwards compatibility) lists any empty pools in the status section' do
|
||||
get "#{prefix}/status/"
|
||||
|
||||
# of course /status doesn't conform to the weird standard everything else uses...
|
||||
expect(last_response.header['Content-Type']).to eq('application/json')
|
||||
result = JSON.parse(last_response.body)
|
||||
expect(result["status"]["empty"].sort).to eq(["pool1", "pool2"])
|
||||
expect(result["status"]["empty"].sort).to eq(["pool1", "pool2", "pool3"])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue