class Comana::HostSelector
Public Class Methods
load_file(file = Comana::ClusterSetting::DEFAULT_DATA_FILE)
click to toggle source
# File lib/comana/hostselector.rb, line 18 def self.load_file(file = Comana::ClusterSetting::DEFAULT_DATA_FILE) yaml = YAML.load_file(file) groups_hosts = {} yaml["groups"].each do |key, val| groups_hosts[key] = val["members"] end self.new(groups_hosts) end
new(groups_hosts)
click to toggle source
Argument 'groups_hosts' should be a hash; the keys are group name, and the value is the hostnames of the member.
# File lib/comana/hostselector.rb, line 14 def initialize(groups_hosts) @groups_hosts = groups_hosts end
Public Instance Methods
groups()
click to toggle source
Return all groups with sorted order.
# File lib/comana/hostselector.rb, line 39 def groups @groups_hosts.keys.sort end
select_all()
click to toggle source
Return all hosts included with sorted order.
# File lib/comana/hostselector.rb, line 28 def select_all @groups_hosts.values.flatten.delete_if{|v| v == nil}.sort end
select_group(group)
click to toggle source
Return member hosts in indicated group.
# File lib/comana/hostselector.rb, line 33 def select_group(group) raise NoEntryError unless @groups_hosts.keys.include? group @groups_hosts[group] end