Class: Zool::ServerPool
- Inherits:
-
Array
- Object
- Array
- Zool::ServerPool
- Defined in:
- lib/zool/server_pool.rb
Constant Summary collapse
- IP_FORMAT =
/^(?:25[0-5]|(?:2[0-4]|1\d|[1-9])?\d)(?:\.(?:25[0-5]|(?:2[0-4]|1\d|[1-9])?\d)){3}$|^(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+(?:[a-z]{2}|com|org|net|gov|mil|biz|info|mobi|name|aero|jobs|museum)$/
Class Method Summary collapse
Instance Method Summary collapse
- #<<(object) ⇒ Object (also: #add)
- #dump_keyfiles ⇒ Object
- #fetch_keys ⇒ Object
- #inspect ⇒ Object
- #keys ⇒ Object
- #upload_keys ⇒ Object
Class Method Details
.from_hostfile(hostsfile, options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/zool/server_pool.rb', line 5 def self.from_hostfile(hostsfile, = {}) hosts = hostsfile.to_a.map { |host| host.split[0] } hosts.uniq! invalid_hosts = %w(127.0.0.1 255.255.255.255) hosts.reject! { |host| host !~ IP_FORMAT } hosts.reject! { |host| invalid_hosts.include?(host) } pool = self.new hosts.each do |host| # puts host server = Server.new(host, ) # puts server.hostname pool << server end pool end |
Instance Method Details
#<<(object) ⇒ Object Also known as: add
37 38 39 40 |
# File 'lib/zool/server_pool.rb', line 37 def <<(object) raise TypeError.new 'Invalid Argument' unless object.instance_of?(Server) super end |
#dump_keyfiles ⇒ Object
43 44 45 46 47 48 |
# File 'lib/zool/server_pool.rb', line 43 def dump_keyfiles writer = KeyfileWriter.new keys.each do |key| writer.write(key) end end |
#fetch_keys ⇒ Object
28 29 30 31 |
# File 'lib/zool/server_pool.rb', line 28 def fetch_keys call_for_pool(:fetch_keys) @keys_proxy = nil end |
#inspect ⇒ Object
50 51 52 |
# File 'lib/zool/server_pool.rb', line 50 def inspect "#<Zool::ServerPool @servers=[#{servers.join(', ')}]>" end |
#keys ⇒ Object
24 25 26 |
# File 'lib/zool/server_pool.rb', line 24 def keys @keys_proxy ||= KeysProxy.new(self) end |
#upload_keys ⇒ Object
33 34 35 |
# File 'lib/zool/server_pool.rb', line 33 def upload_keys call_for_pool(:upload_keys) end |