Class: Comana::ClusterSetting
- Inherits:
-
Object
- Object
- Comana::ClusterSetting
- Defined in:
- lib/comana/clustersetting.rb
Overview
Series name is composed only of alphabets. Host name is started by the series name and followed by integers. E.g.,
"Fe", "Fe00", "Fe01" are of series "Fe" and not "F"
Defined Under Namespace
Classes: NoEntryError
Constant Summary collapse
- DEFAULT_DATA_FILE =
ENV["HOME"] + "/.clustersetting"
Instance Attribute Summary collapse
-
#data_file ⇒ Object
readonly
Returns the value of attribute data_file.
-
#groups ⇒ Object
readonly
Returns the value of attribute groups.
-
#pbs_server ⇒ Object
readonly
Returns the value of attribute pbs_server.
Class Method Summary collapse
Instance Method Summary collapse
-
#belonged_cluster(hostname) ⇒ Object
Return belonged cluster of the host.
-
#clusters ⇒ Object
Return an array of cluster names.
-
#initialize(settings, data_file = nil) ⇒ ClusterSetting
constructor
A new instance of ClusterSetting.
-
#settings_group(clustername) ⇒ Object
Return settings as a hash for a cluster.
-
#settings_host(hostname) ⇒ Object
Return settings as a hash for a host belonged to cluster.
-
#settings_queue(q_name) ⇒ Object
Return settings as a hash for a cluster, the ‘queue’ key has a value of q_name.
Constructor Details
#initialize(settings, data_file = nil) ⇒ ClusterSetting
Returns a new instance of ClusterSetting.
18 19 20 21 22 |
# File 'lib/comana/clustersetting.rb', line 18 def initialize(settings, data_file = nil) @pbs_server = settings["pbs_server"] @groups = settings["groups"] @data_file = data_file end |
Instance Attribute Details
#data_file ⇒ Object (readonly)
Returns the value of attribute data_file.
11 12 13 |
# File 'lib/comana/clustersetting.rb', line 11 def data_file @data_file end |
#groups ⇒ Object (readonly)
Returns the value of attribute groups.
11 12 13 |
# File 'lib/comana/clustersetting.rb', line 11 def groups @groups end |
#pbs_server ⇒ Object (readonly)
Returns the value of attribute pbs_server.
11 12 13 |
# File 'lib/comana/clustersetting.rb', line 11 def pbs_server @pbs_server end |
Class Method Details
.load_file(data_file = DEFAULT_DATA_FILE) ⇒ Object
24 25 26 27 |
# File 'lib/comana/clustersetting.rb', line 24 def self.load_file(data_file = DEFAULT_DATA_FILE) settings = YAML.load_file(data_file) self.new(settings, data_file) end |
Instance Method Details
#belonged_cluster(hostname) ⇒ Object
Return belonged cluster of the host. Raise NoEntryError if not match.
31 32 33 34 35 36 37 |
# File 'lib/comana/clustersetting.rb', line 31 def belonged_cluster(hostname) @groups.each do |group, settings| next unless settings["members"] return group if settings["members"].include? hostname end raise NoEntryError, "#{hostname} is not in `@groups': #{@groups.inspect}" end |
#clusters ⇒ Object
Return an array of cluster names.
60 61 62 |
# File 'lib/comana/clustersetting.rb', line 60 def clusters @groups.keys end |
#settings_group(clustername) ⇒ Object
Return settings as a hash for a cluster.
40 41 42 |
# File 'lib/comana/clustersetting.rb', line 40 def settings_group(clustername) @groups[clustername] end |
#settings_host(hostname) ⇒ Object
Return settings as a hash for a host belonged to cluster.
55 56 57 |
# File 'lib/comana/clustersetting.rb', line 55 def settings_host(hostname) settings_group(belonged_cluster(hostname)) end |
#settings_queue(q_name) ⇒ Object
Return settings as a hash for a cluster, the ‘queue’ key has a value of q_name.
45 46 47 48 49 50 51 52 |
# File 'lib/comana/clustersetting.rb', line 45 def settings_queue(q_name) result = nil #pp @groups @groups.each do |name, items| result = items if items['queue'] == q_name end result end |