Class: Shell::ShellSession

Inherits:
Object show all
Includes:
Singleton
Defined in:
lib/chef/shell/shell_session.rb

Direct Known Subclasses

SoloSession, StandAloneSession

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeShellSession

Returns a new instance of ShellSession.



43
44
45
46
47
# File 'lib/chef/shell/shell_session.rb', line 43

def initialize
  @node_built = false
  formatter = Chef::Formatters.new(Chef::Config.formatter, STDOUT, STDERR)
  @events = Chef::EventDispatch::Dispatcher.new(formatter)
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



42
43
44
# File 'lib/chef/shell/shell_session.rb', line 42

def client
  @client
end

#compileObject

Returns the value of attribute compile.



41
42
43
# File 'lib/chef/shell/shell_session.rb', line 41

def compile
  @compile
end

#nodeObject

Returns the value of attribute node.



41
42
43
# File 'lib/chef/shell/shell_session.rb', line 41

def node
  @node
end

#node_attributesObject

Returns the value of attribute node_attributes.



42
43
44
# File 'lib/chef/shell/shell_session.rb', line 42

def node_attributes
  @node_attributes
end

#recipeObject

Returns the value of attribute recipe.



41
42
43
# File 'lib/chef/shell/shell_session.rb', line 41

def recipe
  @recipe
end

#run_contextObject

Returns the value of attribute run_context.



41
42
43
# File 'lib/chef/shell/shell_session.rb', line 41

def run_context
  @run_context
end

Class Method Details

.inspectObject



129
130
131
# File 'lib/chef/shell/shell_session.rb', line 129

def @node.inspect
  "<Chef::Node:0x#{self.object_id.to_s(16)} @name=\"#{self.name}\">"
end

.session_type(type = nil) ⇒ Object



36
37
38
39
# File 'lib/chef/shell/shell_session.rb', line 36

def self.session_type(type=nil)
  @session_type = type if type
  @session_type
end

Instance Method Details

#cookbook_loaderObject



84
85
86
# File 'lib/chef/shell/shell_session.rb', line 84

def cookbook_loader
  nil
end

#definitionsObject



80
81
82
# File 'lib/chef/shell/shell_session.rb', line 80

def definitions
  nil
end

#node_built?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/chef/shell/shell_session.rb', line 49

def node_built?
  !!@node_built
end

#rebuild_contextObject



92
93
94
# File 'lib/chef/shell/shell_session.rb', line 92

def rebuild_context
  raise "Not Implemented! :rebuild_collection should be implemented by subclasses"
end

#reset!Object



53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/chef/shell/shell_session.rb', line 53

def reset!
  loading do
    rebuild_node
    @node = client.node
    shorten_node_inspect
    Shell::Extensions.extend_context_node(@node)
    rebuild_context
    node.consume_attributes(node_attributes) if node_attributes
    @recipe = Chef::Recipe.new(nil, nil, run_context)
    Shell::Extensions.extend_context_recipe(@recipe)
    @node_built = true
  end
end

#resource_collectionObject



72
73
74
# File 'lib/chef/shell/shell_session.rb', line 72

def resource_collection
  run_context.resource_collection
end

#save_nodeObject



88
89
90
# File 'lib/chef/shell/shell_session.rb', line 88

def save_node
  raise "Not Supported! #{self.class.name} doesn't support #save_node, maybe you need to run chef-shell in client mode?"
end