Class: MachineManager
- Inherits:
-
Object
- Object
- MachineManager
- Defined in:
- lib/remote_execution/provider.rb
Instance Attribute Summary collapse
-
#cloud_providers ⇒ Object
Returns the value of attribute cloud_providers.
Instance Method Summary collapse
- #cloud(name, *args) ⇒ Object
- #destroy_machines ⇒ Object
-
#initialize(&block) ⇒ MachineManager
constructor
A new instance of MachineManager.
- #manual(name, ip, username, *args) ⇒ Object
- #wait_for_sshable ⇒ Object
Constructor Details
#initialize(&block) ⇒ MachineManager
Returns a new instance of MachineManager.
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/remote_execution/provider.rb', line 11 def initialize(&block) @virtual_machines = Hash.new @cloud_providers = Array.new instance_eval(&block) if block @cloud_providers.each do |provider| @virtual_machines = @virtual_machines.merge(provider.virtual_machines) end $virtual_machines = @virtual_machines puts $virtual_machines if @cloud_providers.length != 0 wait_for_sshable end end |
Instance Attribute Details
#cloud_providers ⇒ Object
Returns the value of attribute cloud_providers.
9 10 11 |
# File 'lib/remote_execution/provider.rb', line 9 def cloud_providers @cloud_providers end |
Instance Method Details
#cloud(name, *args) ⇒ Object
30 31 32 33 34 |
# File 'lib/remote_execution/provider.rb', line 30 def cloud(name, *args) cloud_provider = CloudProvider.new(name, *args) @cloud_providers.push(cloud_provider) cloud_provider end |
#destroy_machines ⇒ Object
44 45 46 47 48 |
# File 'lib/remote_execution/provider.rb', line 44 def destroy_machines cloud_providers.each do |provider| provider.destroy end end |
#manual(name, ip, username, *args) ⇒ Object
25 26 27 28 |
# File 'lib/remote_execution/provider.rb', line 25 def manual(name, ip, username, *args) vm = VirtualMachine.new(ip, username, *args) @virtual_machines.store(name, vm) end |
#wait_for_sshable ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/remote_execution/provider.rb', line 36 def wait_for_sshable cloud_providers.each do |provider| provider.instances.each do |server| server.wait_for { print '.'; sshable? } end end end |