Class: Yao::Client::ClientSet
- Inherits:
-
Object
- Object
- Yao::Client::ClientSet
- Defined in:
- lib/yao/client.rb
Instance Attribute Summary collapse
-
#admin_pool ⇒ Object
readonly
Returns the value of attribute admin_pool.
-
#pool ⇒ Object
readonly
Returns the value of attribute pool.
Instance Method Summary collapse
-
#initialize ⇒ ClientSet
constructor
A new instance of ClientSet.
- #register_endpoints(endpoints, token: nil) ⇒ Object
Constructor Details
#initialize ⇒ ClientSet
Returns a new instance of ClientSet.
10 11 12 13 |
# File 'lib/yao/client.rb', line 10 def initialize @pool = {} @admin_pool = {} end |
Instance Attribute Details
#admin_pool ⇒ Object (readonly)
Returns the value of attribute admin_pool.
14 15 16 |
# File 'lib/yao/client.rb', line 14 def admin_pool @admin_pool end |
#pool ⇒ Object (readonly)
Returns the value of attribute pool.
14 15 16 |
# File 'lib/yao/client.rb', line 14 def pool @pool end |
Instance Method Details
#register_endpoints(endpoints, token: nil) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/yao/client.rb', line 26 def register_endpoints(endpoints, token: nil) 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 force_public_url = Yao.config.endpoints[type.to_sym][:public] rescue nil force_admin_url = Yao.config.endpoints[type.to_sym][:admin] rescue nil self.pool[type] = Yao::Client.gen_client(force_public_url || urls[:public_url], token: token) if force_public_url || urls[:public_url] self.admin_pool[type] = Yao::Client.gen_client(force_admin_url || urls[:admin_url], token: token) if force_admin_url || urls[:admin_url] end end |