Class: Pec::Director
- Inherits:
-
Object
show all
- Defined in:
- lib/pec/director.rb,
lib/pec/director/helper.rb,
lib/pec/director/make_director.rb,
lib/pec/director/destroy_director.rb,
lib/pec/director/vm_status_director.rb
Defined Under Namespace
Classes: DestroyDirector, Helper, MakeDirector, VmStatusDirector
Class Method Summary
collapse
Class Method Details
.assign_director(action, options) ⇒ Object
.config_load_err_message ⇒ Object
44
45
46
|
# File 'lib/pec/director.rb', line 44
def config_load_err_message
puts "can't load configfile".magenta
end
|
.err_message(e) ⇒ Object
40
41
42
|
# File 'lib/pec/director.rb', line 40
def err_message(e)
puts e.to_s.magenta
end
|
.excon_err_message(e) ⇒ Object
48
49
50
|
# File 'lib/pec/director.rb', line 48
def excon_err_message(e)
JSON.parse(e.response[:body]).each { |e,m| puts "#{e}:#{m["message"]}".magenta }
end
|
.execute(action, host_name, options = nil) ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/pec/director.rb', line 5
def execute(action, host_name, options=nil)
config = Pec::Configure.new("Pec.yaml")
director = assign_director(action, options)
config.filter_by_host(host_name).each do |host|
begin
director.execute!(host) if director.do_it?(host)
rescue Pec::Errors::Error => e
director.err_message(e, host)
rescue Excon::Errors::Error => e
excon_err_message(e)
end
end if config
rescue Pec::Errors::Configure => e
config_load_err_message
rescue Pec::Errors::Error => e
err_message(e)
rescue Errno::ENOENT => e
err_messag(e)
end
|