Class: Cloudspeq::Providers::Base
- Inherits:
-
Object
- Object
- Cloudspeq::Providers::Base
- Defined in:
- lib/cloudspeq/providers/base.rb,
lib/cloudspeq/providers/base.rb
Direct Known Subclasses
Defined Under Namespace
Classes: Machine
Class Method Summary collapse
Instance Method Summary collapse
-
#destroy(machs) ⇒ Object
destroys machines and removes.
- #exec(command, machs = machines) ⇒ Object
- #exec!(command, machs = machines) ⇒ Object
-
#initialize(settings) ⇒ Base
constructor
A new instance of Base.
- #machines ⇒ Object
- #refresh ⇒ Object
- #root_exec(command, machs = machines) ⇒ Object
- #sync ⇒ Object
Constructor Details
#initialize(settings) ⇒ Base
Returns a new instance of Base.
5 6 7 |
# File 'lib/cloudspeq/providers/base.rb', line 5 def initialize(settings) @settings = settings end |
Class Method Details
.find(hostname: '', ip_address: '') ⇒ Object
65 66 67 68 69 70 |
# File 'lib/cloudspeq/providers/base.rb', line 65 def self.find(hostname: '', ip_address: '') return false if hostname.empty? && ip_address.empty? if !ip_address.empty? else end end |
Instance Method Details
#destroy(machs) ⇒ Object
destroys machines and removes
35 36 37 38 39 40 |
# File 'lib/cloudspeq/providers/base.rb', line 35 def destroy(machs) machs.each do |m| machines.delete m m.destroy end end |
#exec(command, machs = machines) ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/cloudspeq/providers/base.rb', line 42 def exec(command,machs=machines) threads = [] output = {} machs.each do |m| threads << Thread.new{ output[m.name] = m.exec(command,@settings) } end threads.each(&:join) output end |
#exec!(command, machs = machines) ⇒ Object
52 53 54 55 56 |
# File 'lib/cloudspeq/providers/base.rb', line 52 def exec!(command,machs=machines) threads = [] machs.collect{|m| threads << Thread.new{m.exec! command, @settings}} threads.each(&:join) end |
#machines ⇒ Object
14 15 |
# File 'lib/cloudspeq/providers/base.rb', line 14 def machines end |
#refresh ⇒ Object
9 10 11 12 |
# File 'lib/cloudspeq/providers/base.rb', line 9 def refresh @machines= remote_machines write_machines @machines end |
#root_exec(command, machs = machines) ⇒ Object
58 59 60 61 62 |
# File 'lib/cloudspeq/providers/base.rb', line 58 def root_exec(command,machs=machines) threads = [] machs.collect{|m| threads << Thread.new{m.root_exec command}} threads.each(&:join) end |
#sync ⇒ Object
18 19 20 21 22 |
# File 'lib/cloudspeq/providers/base.rb', line 18 def sync machines.each do |machine| machine.sync(@settings) end end |