33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/vagabond/actions/cluster.rb', line 33
def _cluster
clr = vagabondfile[:clusters][name] if vagabondfile[:clusters]
if(clr)
ui.info "#{ui.color('Vagabond:', :bold)} Building cluster - #{ui.color(name, :green)}"
if(vagabondfile.local_chef_server?)
require 'vagabond/server'
srv = ::Vagabond::Server.new
srv.options = options.dup
srv.options[:auto_provision] = true
unless(srv.lxc.running?)
srv.up
configure
end
end
cluster_instances = clr.map do |n|
ui.info "Building #{n} for cluster!"
v_inst = Vagabond.new
v_inst.options = options.dup
v_inst.up(n, :ui => ui)
if(options[:delay].to_i > 0 && n != clr.last)
ui.warn "Delay requested between node processing. Sleeping for #{options[:delay].to_i} seconds."
sleep(options[:delay].to_i)
end
v_inst
end
if(options[:parallel])
ui.info "Waiting for parallel completes!"
cluster_instances.map do |inst|
inst.wait_for_completion
end
end
failed = cluster_instances.map{|i|i.send(:tasks)}.map(&:values).flatten.detect do |hash|
hash[:result] == false
end
result = failed ? ['FAILED', :red, :bold] : ['SUCCESS', :green, :bold]
ui.info "\nCluster build #{name}: #{ui.color(*result)}"
cluster_instances.each do |inst|
failed = inst.send(:tasks).values.flatten.detect do |hash|
hash[:result] == false
end
result = failed ? ['FAILED', :red, :bold] : ['SUCCESS', :green, :bold]
ui.info " -> #{inst.name}: #{ui.color(*result)}"
end
else
ui.error "Cluster name provided does not exist: #{name}"
end
end
|