class Yao::Client::ClientSet
Attributes
admin_pool[R]
pool
and admin_pool
returns Hash like below structure
{
"identity" => #<Faraday::Connection:...>, "image" => #<Faraday::Connection:...>,
}
@return [Hash { String => Faraday::Connection }]
pool[R]
pool
and admin_pool
returns Hash like below structure
{
"identity" => #<Faraday::Connection:...>, "image" => #<Faraday::Connection:...>,
}
@return [Hash { String => Faraday::Connection }]
Public Class Methods
new()
click to toggle source
# File lib/yao/client.rb, line 11 def initialize @pool = {} @admin_pool = {} end
Public Instance Methods
register_endpoints(endpoints, token: nil)
click to toggle source
endpoints is a Hash like below structure
{
"identity" => { public_url: "https://example.com/mitaka/keystone/v3", internal_url: "https://example.com/mitaka/keystone/v3", admin_url: "https://example.com/mitaka/admin/keystone/v3" }, "image" => { ... },
}
@param endpoints [Hash{ String => Hash }]
# File lib/yao/client.rb, line 53 def register_endpoints(endpoints, token: nil) # type is String (e.g. network, identity, ... ) # urls is Hash{ Symbol => String } endpoints.each_pair do |type, urls| # XXX: neutron just have v2.0 API and endpoint may not have version prefix if type == "network" urls = urls.map {|public_or_admin, url| url = File.join(url, "v2.0") [public_or_admin, url] }.to_h end # User can override the public_url and admin_url of endpoints by setting Yao.configure # For example. # # Yao.configure do # endpoints identity: { public: "http://override-endpoint.example.com:35357/v3.0" } # end # force_public_url = Yao.config.endpoints[type.to_sym][:public] rescue nil force_admin_url = Yao.config.endpoints[type.to_sym][:admin] rescue nil if force_public_url || urls[:public_url] self.pool[type] = Yao::Client.gen_client(force_public_url || urls[:public_url], token: token) end if force_admin_url || urls[:admin_url] self.admin_pool[type] = Yao::Client.gen_client(force_admin_url || urls[:admin_url], token: token) end end end