Module: Ironfan::Dsl::Discovery

Extended by:
Gorillib::Concern
Includes:
Gorillib::Builder
Defined in:
lib/ironfan/dsl/component.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#set_discovery(compute, keys) ⇒ Object


97
98
99
100
101
102
103
104
105
106
107
# File 'lib/ironfan/dsl/component.rb', line 97

def set_discovery(compute, keys)
  if server_cluster
    wire_to(compute, keys)
  else
    # I'm defanging automatic discovery for now.
    raise StandardError.new("must explicitly specify a server_cluster for discovery")    # discover(announce_name) do |cluster_name, facet_name|
    #   wire_to(compute, [cluster_name, facet_name].join('-'), keys)
    # end

  end
end

#wire_to(compute, keys) ⇒ Object


109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/ironfan/dsl/component.rb', line 109

def wire_to(compute, keys)
  discovery = {discovers: keys.reverse.inject(compute.realm_name){|hsh,key| {key => hsh}}}
  (compute.facet_role || compute.cluster_role).override_attributes(discovery)

  client_group_v = compute.full_name
  server_group_v = "#{realm_name}-#{server_cluster}"

  group_edge(compute, client_group_v, :authorized_by_group, server_group_v)
  Chef::Log.debug("#{client_group_v} authorized by #{server_group_v}")
  if bidirectional
    group_edge(compute, client_group_v, :authorize_group,     server_group_v) 
    Chef::Log.debug("#{client_group_v} authorizes #{server_group_v}")
  end

  Chef::Log.debug("discovered #{announce_name} for #{cluster_name}: #{discovery}")
end