Class: Ironfan::Dsl::Cluster

Inherits:
Compute show all
Includes:
Plugin::Base
Defined in:
lib/ironfan/headers.rb,
lib/ironfan/dsl/cluster.rb

Instance Attribute Summary

Attributes included from Gorillib::Resolution

#underlay

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Plugin::Base

#to_node

Methods inherited from Compute

_project, #cloud, cluster_role_name, #ec2, facet_role_name, #openstack, #raid_group, #rds, #recipe, #role, #run_list, #selected_cloud, #static, #vsphere

Methods inherited from Ironfan::Dsl

#_skip_fields, #skip_fields, #to_manifest

Methods included from Gorillib::Resolution

#deep_resolve, #merge_resolve, #merge_values, #read_resolved_attribute, #read_set_attribute, #read_set_or_underlay_attribute, #read_underlay_attribute, #resolve, #resolve!, #resolve_value

Methods included from CookbookRequirements

#_cookbook_reqs, #cookbook_req, #cookbook_reqs, #join_req

Methods inherited from Builder

ui, #ui

Constructor Details

#initialize(attrs = {}, &blk) ⇒ Cluster

Returns a new instance of Cluster.


23
24
25
26
27
28
# File 'lib/ironfan/dsl/cluster.rb', line 23

def initialize(attrs = {}, &blk)
  super
  self.realm_name    attrs[:owner].name          unless attrs[:owner].nil?
  self.cluster_names attrs[:owner].cluster_names unless attrs[:owner].nil?
  self.cluster_role  Ironfan::Dsl::Role.new(name: Compute.cluster_role_name(realm_name, cluster_name))
end

Class Method Details

.define(attrs = {}, &blk) ⇒ Object


17
18
19
20
21
# File 'lib/ironfan/dsl/cluster.rb', line 17

def self.define(attrs = {}, &blk)
  cl = new(attrs)
  cl.receive!({}, &blk) # the ordering of the initialize method is super fragile
  definitions[attrs[:name].to_sym] = cl
end

.definitionsObject


13
14
15
# File 'lib/ironfan/dsl/cluster.rb', line 13

def self.definitions
  @clusters ||= {}
end

.plugin_hook(owner, attrs, plugin_name, full_name, &blk) ⇒ Object


8
9
10
11
# File 'lib/ironfan/dsl/cluster.rb', line 8

def self.plugin_hook(owner, attrs, plugin_name, full_name, &blk)
  owner.cluster(plugin_name, new(attrs.merge(name: full_name, owner: owner)))
  _project(cluster, &blk)
end

Instance Method Details

#childrenObject


37
38
39
# File 'lib/ironfan/dsl/cluster.rb', line 37

def children
  facets.to_a + components.to_a
end

#cluster_nameObject


41
42
43
# File 'lib/ironfan/dsl/cluster.rb', line 41

def cluster_name
  name
end

#full_nameObject


45
46
47
# File 'lib/ironfan/dsl/cluster.rb', line 45

def full_name
  "#{realm_name}-#{name}"
end

#serversObject

Utility method to reference all servers from constituent facets


31
32
33
34
35
# File 'lib/ironfan/dsl/cluster.rb', line 31

def servers
  result = Gorillib::ModelCollection.new(item_type: Ironfan::Dsl::Server, key_method: :full_name)
  facets.each{ |f| f.servers.each{ |s| result << s } }
  result
end