Class: Spiceweasel::Clusters

Inherits:
Object
  • Object
show all
Defined in:
lib/spiceweasel/clusters.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(clusters, cookbooks, environments, roles) ⇒ Clusters

Returns a new instance of Clusters.



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/spiceweasel/clusters.rb', line 24

def initialize(clusters, cookbooks, environments, roles)
  @create = Array.new
  @delete = Array.new
  if clusters
    Spiceweasel::Log.debug("clusters: #{clusters}")
    clusters.each do |cluster|
      cluster_name = cluster.keys.first
      Spiceweasel::Log.debug("cluster: '#{cluster_name}' '#{cluster[cluster_name]}'")
      # add a tag to the Nodes
      cluster[cluster_name].each do |node|
        node_name = node.keys.first
        run_list = node[node_name]['run_list'] || ''
        options = node[node_name]['options'] || ''
        # cluster tag is the cluster name + runlist once tags are working for every plugin
        # until then, we're going to override the Environment
        if options =~ /-E/ #delete any Environment
          env = options.split('-E')[1].split[0]
          edel = "-E#{env}"
          options[edel] = "" if options.include?(edel)
          edel = "-E #{env}"
          options[edel] = "" if options.include?(edel)
          Spiceweasel::Log.warn("deleting specified Environment '#{env}' from cluster: '#{cluster_name}'")
        end
        #push the Environment back on the options
        node[node_name]['options'] = options + " -E #{cluster_name}"
      end
      # let's reuse the Nodes logic
      nodes = Spiceweasel::Nodes.new(cluster[cluster_name], cookbooks, environments, roles)
      @create.concat(nodes.create)
      @delete.concat(nodes.delete)
    end
  end
end

Instance Attribute Details

#createObject (readonly)

Returns the value of attribute create.



22
23
24
# File 'lib/spiceweasel/clusters.rb', line 22

def create
  @create
end

#deleteObject (readonly)

Returns the value of attribute delete.



22
23
24
# File 'lib/spiceweasel/clusters.rb', line 22

def delete
  @delete
end