Skip to content
Browse files

permanent attribute works

  • Loading branch information...
1 parent 66dadc9 commit f15120d728cf8de722fd60c4b3f8b6064aaf929f Philip (flip) Kromer committed Apr 15, 2012
Showing with 22 additions and 3 deletions.
  1. +1 −1 TODO.md
  2. +1 −0 lib/chef/knife/cluster_kill.rb
  3. +1 −0 lib/ironfan/chef_layer.rb
  4. +13 −2 lib/ironfan/fog_layer.rb
  5. +6 −0 lib/ironfan/server.rb
View
2 TODO.md
@@ -1,4 +1,4 @@
-
+* We should use the `Fog::Compute::AWS::FLAVORS` constant that [fog defines](http://rubydoc.info/github/fog/fog/master/Fog/Compute/AWS) in the cloud code (instead of the one we put there)
* All over the place there is the following construct (absolutely necessary, absolutely horrid):
View
1 lib/chef/knife/cluster_kill.rb
@@ -58,6 +58,7 @@ def perform_execution(target)
def display(target, *args, &block)
super
+ ui.info Formatador.display_line("[red]Permanent servers ignored[reset]: [blue]#{target.select{|svr| svr.permanent }.map(&:fullname).inspect}[reset]") unless target.select{|svr| svr.permanent }.empty?
ui.info Formatador.display_line("[red]Bogus servers detected[reset]: [blue]#{target.bogus_servers.map(&:fullname).inspect}[reset]") unless target.bogus_servers.empty?
end
View
1 lib/ironfan/chef_layer.rb
@@ -203,6 +203,7 @@ def set_chef_node_attributes
step(" setting node runlist and essential attributes")
@chef_node.run_list = Chef::RunList.new(*@settings[:run_list])
@chef_node.normal[:organization] = organization if organization
+ @chef_node.normal[:permanent] = cloud.permanent if cloud.permanent
@chef_node.override[:cluster_name] = cluster_name
@chef_node.override[:facet_name] = facet_name
@chef_node.override[:facet_index] = facet_index
View
15 lib/ironfan/fog_layer.rb
@@ -38,8 +38,7 @@ def fog_launch_description
:block_device_mapping => block_device_mapping,
:availability_zone => self.default_availability_zone,
:monitoring => cloud.monitoring,
- # :disable_api_termination => cloud.permanent,
- # :instance_initiated_shutdown_behavior => instance_initiated_shutdown_behavior,
+ # permanence is applied during sync
}
end
@@ -130,6 +129,18 @@ def check_server_id_pairing thing, desc
end
end
+ def set_instance_attributes
+ return unless self.in_cloud? && (not self.cloud.permanent.nil?)
+ desc = "termination flag #{permanent?} for #{self.fullname}"
+ # the EC2 API does not surface disable_api_termination as a value, so we
+ # have to set it every time.
+ safely do
+ step(" setting #{desc}", :blue)
+ Ironfan.fog_connection.modify_instance_attribute(self.fog_server.id, {
+ 'DisableApiTermination.Value' => permanent?, })
+ end
+ end
+
end
class ServerSlice
View
6 lib/ironfan/server.rb
@@ -84,7 +84,12 @@ def sshable?
in_chef?
end
+ def permanent?
+ !! self.cloud.permanent
+ end
+
def killable?
+ return false if permanent?
in_chef? || created?
end
@@ -235,6 +240,7 @@ def sync_to_cloud
attach_volumes
create_tags
associate_public_ip
+ set_instance_attributes
end
def sync_to_chef

0 comments on commit f15120d

Please sign in to comment.
Something went wrong with that request. Please try again.