Class: Ironfan::Script

Inherits:
Chef::Knife show all
Includes:
KnifeCommon
Defined in:
lib/chef/knife/ironfan_script.rb

Instance Attribute Summary

Attributes included from KnifeCommon

#broker, #problems

Instance Method Summary collapse

Methods included from KnifeCommon

#all_computers, #bootstrapper, #configure_dry_run, #confirm_execution, #confirm_or_exit, #die, #discover_computers, #display, #exit_if_unhealthy!, #gemfile, #get_relevant_slice, #get_slice, #has_problem, #healthy?, included, load_deps, #load_ironfan, #pick_apart, #predicate_str, #progressbar_for_threads, #relevant?, #run, #run_bootstrap, #section, #sub_command, #wait_for_ssh

Instance Method Details

#_runObject



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/chef/knife/ironfan_script.rb', line 41

def _run
  load_ironfan

  die(banner) if @name_args.empty?
  configure_dry_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),
             " on #{target.joined_names}..."].join())
    unless config[:yes]
      ui.info("")
      confirm_execution(target)
    end
    #
    perform_execution(target)
  end

  if healthy? and aggregates? and (aggregates_on_noop? or not target.empty?)
    ui.info "Applying aggregations:"
    all_computers(*@name_args).aggregate
  end

  if target.empty?
    ui.warn("No computers to #{sub_command}")
  else
    ui.info("")
    ui.info "Finished! Current state:"
    display(target)
  end
  #
  exit_if_unhealthy!
end

#aggregates?Boolean

Returns:

  • (Boolean)


94
95
96
# File 'lib/chef/knife/ironfan_script.rb', line 94

def aggregates?
  true
end

#aggregates_on_noop?Boolean

Returns:

  • (Boolean)


98
99
100
# File 'lib/chef/knife/ironfan_script.rb', line 98

def aggregates_on_noop?
  false
end

#perform_execution(target) ⇒ Object



82
83
84
# File 'lib/chef/knife/ironfan_script.rb', line 82

def perform_execution(target)
  target.send(sub_command)
end

#prepares?Boolean

Returns:

  • (Boolean)


86
87
88
# File 'lib/chef/knife/ironfan_script.rb', line 86

def prepares?
  true
end

#prepares_on_noop?Boolean

Returns:

  • (Boolean)


90
91
92
# File 'lib/chef/knife/ironfan_script.rb', line 90

def prepares_on_noop?
  false
end