Class: Chef::Knife::ClusterDiff

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

Instance Attribute Summary

Attributes included from Ironfan::KnifeCommon

#broker, #problems

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Ironfan::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

Class Method Details

.mismatches?(target) ⇒ Boolean

Returns:

  • (Boolean)


53
54
55
56
57
58
59
60
# File 'lib/chef/knife/cluster_diff.rb', line 53

def self.mismatches?(target)
  target.map do |computer|
    local_manifest = computer.server.to_machine_manifest
    remote_manifest = Ironfan::Dsl::MachineManifest.from_computer(computer)
    display_diff(local_manifest, remote_manifest)
    local_manifest != remote_manifest
  end.to_a.any?
end

Instance Method Details

#_runObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/chef/knife/cluster_diff.rb', line 35

def _run
  load_ironfan
  die(banner) if @name_args.empty?
  configure_dry_run

  @test_chef_data = 
    if config.has_key? :cache_file
      Hash[open(config.fetch(:cache_file)).readlines.map{|line| datum = MultiJson.load(line); [datum['name'], datum]}]
    else
      {}
    end
  
  # Load the cluster/facet/slice/whatever
  target = get_slice(* @name_args)

  exit(1) if self.class.mismatches?(target)
end