class Skalera::Services::Controllers
Public Class Methods
add(controller_uuid, host, port)
click to toggle source
# File lib/skalera/services/controllers.rb, line 24 def self.add(controller_uuid, host, port) Diplomat::Kv.put("controllers/#{controller_uuid}/address", host) Diplomat::Kv.put("controllers/#{controller_uuid}/port", port) end
extract(controllers, field)
click to toggle source
# File lib/skalera/services/controllers.rb, line 15 def self.extract(controllers, field) result = {} controllers.select { |c| c[:key].match(%r{/#{field}}) }.each do |hash| host = hash[:key].sub(%r{controllers/}, '').split('/')[1] result[host] = hash[:value] end result end
for(controller_uuid)
click to toggle source
# File lib/skalera/services/controllers.rb, line 6 def self.for(controller_uuid) controllers = Diplomat::Kv.get("controllers/#{controller_uuid}", recurse: true) host = extract(controllers, 'address') port = extract(controllers, 'port') [host['address'], port['port']] rescue Diplomat::KeyNotFound STDERR.puts "ERROR: key not found: controllers/#{controller_uuid}" end