vmpooler/lib/vmpooler/api.rb
kirby@puppetlabs.com 5704488cc5 (POOLER-132) Sync pool size on dashboard start
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.
2018-10-03 13:07:20 -07:00

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