mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 10:08:40 -05:00
Merge pull request #59 from sschneid/maint
Set HTTP status codes, a bit of code standardization
This commit is contained in:
commit
b965ce3a55
1 changed files with 20 additions and 5 deletions
|
|
@ -59,7 +59,9 @@ module Vmpooler
|
||||||
end
|
end
|
||||||
|
|
||||||
get '/dashboard/stats/vmpooler/pool/?' do
|
get '/dashboard/stats/vmpooler/pool/?' do
|
||||||
result = Hash.new
|
content_type :json
|
||||||
|
|
||||||
|
result = {}
|
||||||
|
|
||||||
$config[:pools].each do |pool|
|
$config[:pools].each do |pool|
|
||||||
result[pool['name']] ||= Hash.new
|
result[pool['name']] ||= Hash.new
|
||||||
|
|
@ -108,12 +110,13 @@ module Vmpooler
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
content_type :json
|
|
||||||
JSON.pretty_generate(result)
|
JSON.pretty_generate(result)
|
||||||
end
|
end
|
||||||
|
|
||||||
get '/dashboard/stats/vmpooler/running/?' do
|
get '/dashboard/stats/vmpooler/running/?' do
|
||||||
result = Hash.new
|
content_type :json
|
||||||
|
|
||||||
|
result = {}
|
||||||
|
|
||||||
$config[:pools].each do |pool|
|
$config[:pools].each do |pool|
|
||||||
running = $redis.scard('vmpooler__running__' + pool['name'])
|
running = $redis.scard('vmpooler__running__' + pool['name'])
|
||||||
|
|
@ -159,7 +162,6 @@ module Vmpooler
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
content_type :json
|
|
||||||
JSON.pretty_generate(result)
|
JSON.pretty_generate(result)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -240,6 +242,8 @@ module Vmpooler
|
||||||
end
|
end
|
||||||
|
|
||||||
get '/summary/?' do
|
get '/summary/?' do
|
||||||
|
content_type :json
|
||||||
|
|
||||||
result = {
|
result = {
|
||||||
clone: {
|
clone: {
|
||||||
duration: {
|
duration: {
|
||||||
|
|
@ -359,7 +363,6 @@ module Vmpooler
|
||||||
result[:clone][:count][:average] = mean(total_clones_per_day)
|
result[:clone][:count][:average] = mean(total_clones_per_day)
|
||||||
end
|
end
|
||||||
|
|
||||||
content_type :json
|
|
||||||
JSON.pretty_generate(result)
|
JSON.pretty_generate(result)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -418,11 +421,13 @@ module Vmpooler
|
||||||
else
|
else
|
||||||
result[key]['ok'] = false ##
|
result[key]['ok'] = false ##
|
||||||
|
|
||||||
|
status 503
|
||||||
result['ok'] = false
|
result['ok'] = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
status 503
|
||||||
result['ok'] = false
|
result['ok'] = false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -477,10 +482,12 @@ module Vmpooler
|
||||||
else
|
else
|
||||||
result[template]['ok'] = false ##
|
result[template]['ok'] = false ##
|
||||||
|
|
||||||
|
status 503
|
||||||
result['ok'] = false
|
result['ok'] = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
status 503
|
||||||
result['ok'] = false
|
result['ok'] = false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -496,11 +503,13 @@ module Vmpooler
|
||||||
|
|
||||||
result = {}
|
result = {}
|
||||||
|
|
||||||
|
status 404
|
||||||
result['ok'] = false
|
result['ok'] = false
|
||||||
|
|
||||||
params[:hostname] = hostname_shorten(params[:hostname])
|
params[:hostname] = hostname_shorten(params[:hostname])
|
||||||
|
|
||||||
if $redis.exists('vmpooler__vm__' + params[:hostname])
|
if $redis.exists('vmpooler__vm__' + params[:hostname])
|
||||||
|
stauts 200
|
||||||
result['ok'] = true
|
result['ok'] = true
|
||||||
|
|
||||||
result[params[:hostname]] = {}
|
result[params[:hostname]] = {}
|
||||||
|
|
@ -522,6 +531,7 @@ module Vmpooler
|
||||||
|
|
||||||
result = {}
|
result = {}
|
||||||
|
|
||||||
|
status 404
|
||||||
result['ok'] = false
|
result['ok'] = false
|
||||||
|
|
||||||
params[:hostname] = hostname_shorten(params[:hostname])
|
params[:hostname] = hostname_shorten(params[:hostname])
|
||||||
|
|
@ -530,6 +540,8 @@ module Vmpooler
|
||||||
if $redis.sismember('vmpooler__running__' + pool['name'], params[:hostname])
|
if $redis.sismember('vmpooler__running__' + pool['name'], params[:hostname])
|
||||||
$redis.srem('vmpooler__running__' + pool['name'], params[:hostname])
|
$redis.srem('vmpooler__running__' + pool['name'], params[:hostname])
|
||||||
$redis.sadd('vmpooler__completed__' + pool['name'], params[:hostname])
|
$redis.sadd('vmpooler__completed__' + pool['name'], params[:hostname])
|
||||||
|
|
||||||
|
status 200
|
||||||
result['ok'] = true
|
result['ok'] = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -542,6 +554,7 @@ module Vmpooler
|
||||||
|
|
||||||
result = {}
|
result = {}
|
||||||
|
|
||||||
|
status 404
|
||||||
result['ok'] = false
|
result['ok'] = false
|
||||||
|
|
||||||
params[:hostname] = hostname_shorten(params[:hostname])
|
params[:hostname] = hostname_shorten(params[:hostname])
|
||||||
|
|
@ -556,6 +569,8 @@ module Vmpooler
|
||||||
|
|
||||||
if arg > 0
|
if arg > 0
|
||||||
$redis.hset('vmpooler__vm__' + params[:hostname], param, arg)
|
$redis.hset('vmpooler__vm__' + params[:hostname], param, arg)
|
||||||
|
|
||||||
|
status 200
|
||||||
result['ok'] = true
|
result['ok'] = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue