mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 18:08:42 -05:00
This commit updates the dashboard for vmpooler to ensure it is synchronized with any redis based configuration values before displaying the dashboard. Without this change the pool size value may be displayed incorrectly if the value has been set via the /config/poolsize API endpoint.
49 lines
983 B
Ruby
49 lines
983 B
Ruby
module Vmpooler
|
|
class API < Sinatra::Base
|
|
def initialize
|
|
super
|
|
end
|
|
|
|
not_found do
|
|
content_type :json
|
|
|
|
result = {
|
|
ok: false
|
|
}
|
|
|
|
JSON.pretty_generate(result)
|
|
end
|
|
|
|
# Load dashboard components
|
|
begin
|
|
require 'dashboard'
|
|
rescue LoadError
|
|
require File.expand_path(File.join(File.dirname(__FILE__), 'dashboard'))
|
|
end
|
|
|
|
use Vmpooler::Dashboard
|
|
|
|
# Load API components
|
|
%w[helpers dashboard reroute v1].each do |lib|
|
|
begin
|
|
require "api/#{lib}"
|
|
rescue LoadError
|
|
require File.expand_path(File.join(File.dirname(__FILE__), 'api', lib))
|
|
end
|
|
end
|
|
|
|
use Vmpooler::API::Dashboard
|
|
use Vmpooler::API::Reroute
|
|
use Vmpooler::API::V1
|
|
|
|
def configure(config, redis, metrics)
|
|
self.settings.set :config, config
|
|
self.settings.set :redis, redis
|
|
self.settings.set :metrics, metrics
|
|
end
|
|
|
|
def execute!
|
|
self.settings.run!
|
|
end
|
|
end
|
|
end
|