class Rummager::ContainerExecTask
Attributes
exec_list[RW]
ident_hash[RW]
needed_test[RW]
Public Class Methods
new(task_name, app)
click to toggle source
Calls superclass method
# File lib/rummager/containers.rb, line 415 def initialize(task_name, app) super(task_name,app) @actions << Proc.new { @exec_list.each do |e| hide_output = e.delete(:hide_output) cmd = e.delete(:cmd) restart_after = e.delete(:restart_after) if hide_output == true docker_obj.exec(cmd) else docker_obj.exec(cmd) { |stream,chunk| puts "#{chunk}" } end if restart_after==true puts "exec item requires container restart" if Rake.verbose == true docker_obj.restart() end end # @exec_list.each if ! @ident_hash.nil? puts "marking #{task_name} completed: #{ident_filename}" if Rake.verbose == true docker_obj.exec(["/usr/bin/sudo","/usr/bin/touch","#{ident_filename}"]) end } end
Public Instance Methods
ident_filename()
click to toggle source
# File lib/rummager/containers.rb, line 385 def ident_filename "/.once-#{@ident_hash}" end
needed?()
click to toggle source
# File lib/rummager/containers.rb, line 389 def needed? if ! @needed_test.nil? puts "running needed_test '#{needed_test}' in '#{@container_name}'" if Rake.verbose == true begin return_arry = docker_obj.exec(@needed_test) puts "test '#{needed_test}' => '#{return_arry[0]}':#{return_arry[2]}" if Rake.verbose == true return (0 == return_arry[2]) rescue => ex puts "test '#{needed_test}' failed in '#{@container_name}':#{ex.message}" return false end elsif ! @ident_hash.nil? puts "checking for #{ident_filename} in container" if Rake.verbose == true begin docker_obj.copy("#{ident_filename}") return false rescue puts "#{ident_filename} not found" if Rake.verbose == true end else puts "neither @needed_test nor @ident_hash defined for #{@task_name}" if Rake.verbose == true end # no ident hash, or not found true end