Permalink
Browse files

Added support for "prepare" phase, prior to any machine-specific actions

  • Loading branch information...
1 parent d3aca11 commit c9db847fb9f736c51643eed33171b2f1eb9c07bb @nickmarden nickmarden committed Dec 14, 2012
@@ -75,6 +75,10 @@ def confirm_execution(target)
confirm_or_exit("Are you absolutely certain that you want to delete #{delete_message}? (Type 'Yes' to confirm) ", 'Yes')
end
+ def prepares?
+ false
+ end
+
end
end
end
@@ -82,6 +82,11 @@ def run
section("Syncing to chef")
target.save :providers => :chef
+ unless target.empty?
+ ui.info "Preparing shared resources:"
+ all_computers(*@name_args).prepare
+ end
+
# Launch computers
ui.info("")
section("Launching computers", :green)
@@ -119,6 +119,10 @@ def proxy_pac_contents
}\n}
end
+ def prepares?
+ false
+ end
+
def aggregates?
false
end
@@ -62,6 +62,10 @@ def perform_execution(target)
else Chef::Log.debug("Skipping sync to cloud") ; end
end
+ def prepares_on_noop?
+ true
+ end
+
def aggregates_on_noop?
true
end
@@ -44,6 +44,11 @@ def run
target = get_relevant_slice(* @name_args)
+ if prepares? and (prepares_on_noop? or not target.empty?)
+ ui.info "Preparing shared resources:"
+ all_computers(*@name_args).prepare
+ end
+
unless target.empty?
ui.info(["\n",
ui.color("Running #{sub_command}", :cyan),
@@ -76,6 +81,14 @@ def perform_execution(target)
target.send(sub_command)
end
+ def prepares?
+ true
+ end
+
+ def prepares_on_noop?
+ false
+ end
+
def aggregates?
true
end
@@ -298,11 +298,19 @@ def validate
values.map {|c| c.providers.values}.flatten.uniq.each {|p| p.validate computers }
end
- def aggregate
+ def group_action(verb)
computers = self
- provider_keys = values.map {|c| c.chosen_providers({ :providers => :iaas})}.flatten.uniq
+ provider_keys = values.map {|c| c.chosen_providers({ :providers => :iaas })}.flatten.uniq
providers = provider_keys.map { |pk| values.map { |c| c.providers[pk] } }.flatten.compact.uniq
- providers.each { |p| p.aggregate! computers }
+ providers.each { |p| p.send(verb, computers) }
+ end
+
+ def prepare
+ group_action(:prepare!)
+ end
+
+ def aggregate
+ group_action(:aggregate!)
end
#
@@ -42,6 +42,12 @@ def self.validate(computers)
resources.each {|r| r.validate_resources! computers }
end
+ def self.prepare!(computers)
+ resources.each do |r|
+ r.prepare!(computers) if r.shared?
+ end
+ end
+
def self.aggregate!(computers)
resources.each do |r|
r.aggregate!(computers) if r.shared?
@@ -87,14 +93,15 @@ def on_correlate(*p) Ironfan.noop(self,__method__,*p); end
#
def self.create!(*p) Ironfan.noop(self,__method__,*p); end
def self.save!(*p) Ironfan.noop(self,__method__,*p); end
+ def self.prepare!(*p) Ironfan.noop(self,__method__,*p); end
def self.aggregate!(*p) Ironfan.noop(self,__method__,*p); end
def self.destroy!(*p) Ironfan.noop(self,__method__,*p); end
#
# Utilities
#
- [:shared?, :multiple?, :load!,:validate_computer!,
- :validate_resources!,:create!,:save!,:aggregate!,:destroy!].each do |method_name|
+ [:shared?, :multiple?, :load!,:validate_computer!, :validate_resources!,
+ :create!, :save!, :prepare!, :aggregate!, :destroy!].each do |method_name|
define_method(method_name) {|*p| self.class.send(method_name,*p) }
end

0 comments on commit c9db847

Please sign in to comment.