Class: Ironfan::Script

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

Direct Known Subclasses

Chef::Knife::ClusterBootstrap, Chef::Knife::ClusterKill, Chef::Knife::ClusterProxy, Chef::Knife::ClusterStart, Chef::Knife::ClusterStop, Chef::Knife::ClusterSync

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, #display, #exit_if_unhealthy!, #get_relevant_slice, #get_slice, #has_problem, #healthy?, included, load_deps, #load_ironfan, #pick_apart, #predicate_str, #progressbar_for_threads, #relevant?, #run_bootstrap, #section, #sub_command

Instance Method Details

- (Boolean) aggregates?

Returns:

  • (Boolean)


92
93
94
# File 'lib/chef/knife/ironfan_script.rb', line 92

def aggregates?
  true
end

- (Boolean) aggregates_on_noop?

Returns:

  • (Boolean)


96
97
98
# File 'lib/chef/knife/ironfan_script.rb', line 96

def aggregates_on_noop?
  false
end

- (Object) perform_execution(target)



80
81
82
# File 'lib/chef/knife/ironfan_script.rb', line 80

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

- (Boolean) prepares?

Returns:

  • (Boolean)


84
85
86
# File 'lib/chef/knife/ironfan_script.rb', line 84

def prepares?
  true
end

- (Boolean) prepares_on_noop?

Returns:

  • (Boolean)


88
89
90
# File 'lib/chef/knife/ironfan_script.rb', line 88

def prepares_on_noop?
  false
end

- (Object) run



39
40
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
# File 'lib/chef/knife/ironfan_script.rb', line 39

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