Class: BarkingIguana::Compound::HostManager
- Inherits:
-
Object
- Object
- BarkingIguana::Compound::HostManager
- Includes:
- Benchmark, Logging::Helper
- Defined in:
- lib/barking_iguana/compound/host_manager.rb
Instance Attribute Summary collapse
-
#hosts ⇒ Object
readonly
Returns the value of attribute hosts.
Instance Method Summary collapse
- #active ⇒ Object
- #all ⇒ Object
- #destroy_all ⇒ Object
- #find_by_name(name) ⇒ Object
-
#initialize(hosts = [], implementation_options = {}) ⇒ HostManager
constructor
A new instance of HostManager.
- #refresh_status ⇒ Object
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 = [], = {} self.hosts = hosts self.implementation = Vagrant.new self, implementation.prepare end |
Instance Attribute Details
#hosts ⇒ Object
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
#active ⇒ Object
23 24 25 |
# File 'lib/barking_iguana/compound/host_manager.rb', line 23 def active all.select { |h| h.state == 'running' } end |
#all ⇒ Object
27 28 29 30 |
# File 'lib/barking_iguana/compound/host_manager.rb', line 27 def all refresh_status hosts end |
#destroy_all ⇒ Object
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_status ⇒ Object
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 |