Class: Spurious::Server::State::Delete
- Defined in:
- lib/spurious/server/state/delete.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #execute! ⇒ Object
-
#initialize(connection, config) ⇒ Delete
constructor
A new instance of Delete.
- #operation_complete ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(connection, config) ⇒ Delete
Returns a new instance of Delete.
10 11 12 13 |
# File 'lib/spurious/server/state/delete.rb', line 10 def initialize(connection, config) super connection_timeouts 2, 600, 600 end |
Instance Method Details
#execute! ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/spurious/server/state/delete.rb', line 15 def execute! containers = spurious_containers.length - 1 spurious_containers.each_with_index do |container, index| container_name = container.json["Name"].gsub('/', '') container_config = config.for(container_name) = container.json remove_container = Proc.new do send "Removing #{container_name}", :debug container.delete(:force => true) unless container_config[:ignore] && container_config[:ignore][:delete] image = container_config[:image] Docker::Image.get(["Image"]).tap do |image| image.remove(:force => true) end end index_to_check = index + 1 containers == index_to_check end EM.defer(remove_container, operation_complete) end end |
#operation_complete ⇒ Object
44 45 46 47 48 |
# File 'lib/spurious/server/state/delete.rb', line 44 def operation_complete Proc.new do |complete| send("5 containers successfully removed", :info, true, :green) if complete end end |