Class: BarkingIguana::Compound::HostManager

Inherits:
Object
  • Object
show all
Includes:
Benchmark, Logging::Helper
Defined in:
lib/barking_iguana/compound/host_manager.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hosts = [], implementation_options = {}) ⇒ HostManager

Returns a new instance of HostManager.



13
14
15
16
17
# File 'lib/barking_iguana/compound/host_manager.rb', line 13

def initialize hosts = [], implementation_options = {}
  self.hosts = hosts
  self.implementation = Vagrant.new self, implementation_options
  implementation.prepare
end

Instance Attribute Details

#hostsObject

Returns the value of attribute hosts.



4
5
6
# File 'lib/barking_iguana/compound/host_manager.rb', line 4

def hosts
  @hosts
end

Instance Method Details

#activeObject



23
24
25
# File 'lib/barking_iguana/compound/host_manager.rb', line 23

def active
  all.select { |h| h.state == 'running' }
end

#allObject



27
28
29
30
# File 'lib/barking_iguana/compound/host_manager.rb', line 27

def all
  refresh_status
  hosts
end

#destroy_allObject



19
20
21
# File 'lib/barking_iguana/compound/host_manager.rb', line 19

def destroy_all
  destroy *hosts.map { |h| h.name }
end

#find_by_name(name) ⇒ Object



55
56
57
58
59
60
# File 'lib/barking_iguana/compound/host_manager.rb', line 55

def find_by_name name
  logger.debug { "Finding host with name #{name}" }
  all.detect { |h| h.inventory_name == name }.tap do |h|
    logger.debug { "Result: #{h.inspect}" }
  end
end

#refresh_statusObject



32
33
34
35
36
# File 'lib/barking_iguana/compound/host_manager.rb', line 32

def refresh_status
  benchmark "refreshing host status" do
    implementation.refresh_status
  end
end