class Shell::DoppelGangerClient

Attributes

node_name[R]

Public Class Methods

new(node_name) click to toggle source
# File lib/chef/shell/shell_session.rb, line 244
def initialize(node_name)
  @node_name = node_name
  @ohai = Ohai::System.new
end

Public Instance Methods

build_node() click to toggle source

DoppelGanger implementation of build_node. preserves as many of the node’s attributes, and does not save updates to the server

# File lib/chef/shell/shell_session.rb, line 257
def build_node
  Chef::Log.trace("Building node object for #{@node_name}")
  @node = Chef::Node.find_or_create(node_name)
  ohai_data = @ohai.data.merge(@node.automatic_attrs)
  @node.consume_external_attrs(ohai_data, nil)
  @run_list_expansion = @node.expand!("server")
  @expanded_run_list_with_versions = @run_list_expansion.recipes.with_version_constraints_strings
  Chef::Log.info("Run List is [#{@node.run_list}]")
  Chef::Log.info("Run List expands to [#{@expanded_run_list_with_versions.join(", ")}]")
  @node
end
register() click to toggle source
# File lib/chef/shell/shell_session.rb, line 269
def register
  @rest = Chef::ServerAPI.new(Chef::Config[:chef_server_url], client_name: Chef::Config[:node_name],
                                                              signing_key_filename: Chef::Config[:client_key])
end
run_ohai() click to toggle source

Run the very smallest amount of ohai we can get away with and still hope to have things work. Otherwise we’re not very good doppelgangers

# File lib/chef/shell/shell_session.rb, line 251
def run_ohai
  @ohai.require_plugin("os")
end