Class: Ironfan::Broker

Inherits:
Builder show all
Defined in:
lib/ironfan/broker.rb,
lib/ironfan/headers.rb,
lib/ironfan/broker/drive.rb,
lib/ironfan/broker/computer.rb

Defined Under Namespace

Classes: Computer, Computers, Drive

Instance Method Summary collapse

Methods inherited from Builder

ui, #ui

Instance Method Details

#discover!(clusters, with_cloud = true) ⇒ Object

Take in a Dsl::Cluster; return Computers populated with all discovered

resources that correlate; computers corresponding to partial or
unrecognizable resources are labeled as bogus.

14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/ironfan/broker.rb', line 14

def discover!(clusters, with_cloud = true)

  
  # Get fully resolved servers, and build Computers using them
  computers = Computers.new(clusters: Array(clusters))  #      

  if with_cloud
    providers = computers.map{|c| c.providers.values }.flatten.uniq

    providers.each do |p|
      p.forget!
    end

    Ironfan.parallel(providers) do |provider|
      clusters.each do |cluster|
        Ironfan.step cluster.name, "Loading #{provider.handle}", :cyan
        provider.load cluster
      end
    end    #

    clusters.each do |cluster|
      Ironfan.step cluster.name, "Reconciling DSL and provider information", :cyan
    end
    computers.correlate
    computers.validate
  end  #

  computers
end

#display(computers, style) ⇒ Object


44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/ironfan/broker.rb', line 44

def display(computers,style)
  defined_data = computers.map do |mach|
    hsh = mach.to_display(style)
    hsh.merge!(yield(mach)) if block_given?
    hsh
  end
  if defined_data.empty?
    ui.info "Nothing to report"
  else
    headings = defined_data.map{|hsh| hsh.keys }.flatten.uniq
    Formatador.display_compact_table(defined_data, headings.to_a)
  end
end