mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 10:08:40 -05:00
Ensure domain is included in the reply for post and get ondemandvm when configured
This commit is contained in:
parent
dddbeba4a6
commit
8ffcafdc99
2 changed files with 43 additions and 0 deletions
|
|
@ -380,6 +380,7 @@ module Vmpooler
|
||||||
backend.hget('vmpooler__token__' + request.env['HTTP_X_AUTH_TOKEN'], 'user'))
|
backend.hget('vmpooler__token__' + request.env['HTTP_X_AUTH_TOKEN'], 'user'))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
result['domain'] = config['domain'] if config['domain']
|
||||||
result[:ok] = true
|
result[:ok] = true
|
||||||
result
|
result
|
||||||
end
|
end
|
||||||
|
|
@ -951,6 +952,7 @@ module Vmpooler
|
||||||
instances = backend.smembers("vmpooler__#{request_id}__#{pool_alias}__#{pool}")
|
instances = backend.smembers("vmpooler__#{request_id}__#{pool_alias}__#{pool}")
|
||||||
result[pool_alias] = { 'hostname': instances }
|
result[pool_alias] = { 'hostname': instances }
|
||||||
end
|
end
|
||||||
|
result['domain'] = config['domain'] if config['domain']
|
||||||
status 200
|
status 200
|
||||||
elsif request_hash['status'] == 'failed'
|
elsif request_hash['status'] == 'failed'
|
||||||
result['ready'] = false
|
result['ready'] = false
|
||||||
|
|
|
||||||
|
|
@ -86,6 +86,24 @@ describe Vmpooler::API::V1 do
|
||||||
expect(redis).to receive(:hset).with("vmpooler__odrequest__#{uuid}", 'requested', 'poolone:pool1:1')
|
expect(redis).to receive(:hset).with("vmpooler__odrequest__#{uuid}", 'requested', 'poolone:pool1:1')
|
||||||
post "#{prefix}/ondemandvm", '{"poolone":"1"}'
|
post "#{prefix}/ondemandvm", '{"poolone":"1"}'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'with domain set in the config' do
|
||||||
|
let(:domain) { 'example.com' }
|
||||||
|
before(:each) do
|
||||||
|
config[:config]['domain'] = domain
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should include domain in the return reply' do
|
||||||
|
post "#{prefix}/ondemandvm", '{"poolone":"1"}'
|
||||||
|
expect_json(true, 201)
|
||||||
|
expected = {
|
||||||
|
"ok": true,
|
||||||
|
"request_id": uuid,
|
||||||
|
"domain": domain
|
||||||
|
}
|
||||||
|
expect(last_response.body).to eq(JSON.pretty_generate(expected))
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with a resource request that exceeds the specified limit' do
|
context 'with a resource request that exceeds the specified limit' do
|
||||||
|
|
@ -225,6 +243,29 @@ describe Vmpooler::API::V1 do
|
||||||
}
|
}
|
||||||
expect(last_response.body).to eq(JSON.pretty_generate(expected))
|
expect(last_response.body).to eq(JSON.pretty_generate(expected))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'with domain set' do
|
||||||
|
let(:domain) { 'example.com' }
|
||||||
|
before(:each) do
|
||||||
|
config[:config]['domain'] = domain
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should include the domain in the result' do
|
||||||
|
get "#{prefix}/ondemandvm/#{uuid}"
|
||||||
|
expected = {
|
||||||
|
"ok": true,
|
||||||
|
"request_id": uuid,
|
||||||
|
"ready": true,
|
||||||
|
"pool1": {
|
||||||
|
"hostname": [
|
||||||
|
vmname
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"domain": domain
|
||||||
|
}
|
||||||
|
expect(last_response.body).to eq(JSON.pretty_generate(expected))
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with a deleted request' do
|
context 'with a deleted request' do
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue