Class: Shef::DoppelGangerSession

Inherits:
ClientSession show all
Defined in:
lib/chef/shef/shef_session.rb

Instance Attribute Summary

Attributes inherited from ShefSession

#client, #compile, #node, #node_attributes, #recipe, #run_context

Instance Method Summary collapse

Methods inherited from ClientSession

#rebuild_context

Methods inherited from SoloSession

#definitions, #rebuild_context

Methods inherited from ShefSession

#cookbook_loader, #definitions, #initialize, inspect, #node_built?, #rebuild_context, #reset!, #resource_collection, session_type

Constructor Details

This class inherits a constructor from Shef::ShefSession

Instance Method Details

#assume_identity(node_name) ⇒ Object



250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
# File 'lib/chef/shef/shef_session.rb', line 250

def assume_identity(node_name)
  Chef::Config[:doppelganger] = @node_name = node_name
  reset!
rescue Exception => e
  puts "#{e.class.name}: #{e.message}"
  puts Array(e.backtrace).join("\n")
  puts
  puts "* " * 40
  puts "failed to assume the identity of node '#{node_name}', resetting"
  puts "* " * 40
  puts
  Chef::Config[:doppelganger] = false
  @node_built = false
  Shef.session
end

#rebuild_nodeObject



266
267
268
269
270
271
272
273
274
275
# File 'lib/chef/shef/shef_session.rb', line 266

def rebuild_node
  # Make sure the client knows this is not chef solo
  Chef::Config[:solo] = false
  @client = DoppelGangerClient.new(@node_name)
  @client.run_ohai
  @client.register
  @client.build_node

  @client.sync_cookbooks
end

#save_nodeObject



246
247
248
# File 'lib/chef/shef/shef_session.rb', line 246

def save_node
  puts "A doppelganger should think twice before saving the node"
end