Class: Shell::ShellSession
- Inherits:
-
Object
- Object
- Shell::ShellSession
- Includes:
- Singleton
- Defined in:
- lib/chef/shell/shell_session.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#compile ⇒ Object
Returns the value of attribute compile.
-
#json_configuration ⇒ Object
Returns the value of attribute json_configuration.
-
#node ⇒ Object
Returns the value of attribute node.
-
#node_attributes ⇒ Object
Returns the value of attribute node_attributes.
-
#recipe ⇒ Object
Returns the value of attribute recipe.
- #run_context ⇒ Object
Class Method Summary collapse
-
.inspect ⇒ Object
rubocop:disable Lint/NestedMethodDefinition.
- .session_type(type = nil) ⇒ Object
Instance Method Summary collapse
- #cookbook_loader ⇒ Object
- #definitions ⇒ Object
-
#initialize ⇒ ShellSession
constructor
A new instance of ShellSession.
- #node_built? ⇒ Boolean
- #rebuild_context ⇒ Object
- #reset! ⇒ Object
- #resource_collection ⇒ Object
- #save_node ⇒ Object
Constructor Details
#initialize ⇒ ShellSession
Returns a new instance of ShellSession.
44 45 46 47 48 |
# File 'lib/chef/shell/shell_session.rb', line 44 def initialize @node_built = false formatter = Chef::Formatters.new(Chef::Config.formatter, STDOUT, STDERR) @events = Chef::EventDispatch::Dispatcher.new(formatter) end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
43 44 45 |
# File 'lib/chef/shell/shell_session.rb', line 43 def client @client end |
#compile ⇒ Object
Returns the value of attribute compile.
42 43 44 |
# File 'lib/chef/shell/shell_session.rb', line 42 def compile @compile end |
#json_configuration ⇒ Object
Returns the value of attribute json_configuration.
42 43 44 |
# File 'lib/chef/shell/shell_session.rb', line 42 def json_configuration @json_configuration end |
#node ⇒ Object
Returns the value of attribute node.
42 43 44 |
# File 'lib/chef/shell/shell_session.rb', line 42 def node @node end |
#node_attributes ⇒ Object
Returns the value of attribute node_attributes.
43 44 45 |
# File 'lib/chef/shell/shell_session.rb', line 43 def node_attributes @node_attributes end |
#recipe ⇒ Object
Returns the value of attribute recipe.
42 43 44 |
# File 'lib/chef/shell/shell_session.rb', line 42 def recipe @recipe end |
#run_context ⇒ Object
78 79 80 |
# File 'lib/chef/shell/shell_session.rb', line 78 def run_context @run_context ||= rebuild_context end |
Class Method Details
.inspect ⇒ Object
rubocop:disable Lint/NestedMethodDefinition
131 132 133 |
# File 'lib/chef/shell/shell_session.rb', line 131 def @node.inspect # rubocop:disable Lint/NestedMethodDefinition "<Chef::Node:0x#{object_id.to_s(16)} @name=\"#{name}\">" end |
.session_type(type = nil) ⇒ Object
37 38 39 40 |
# File 'lib/chef/shell/shell_session.rb', line 37 def self.session_type(type = nil) @session_type = type if type @session_type end |
Instance Method Details
#cookbook_loader ⇒ Object
86 87 88 |
# File 'lib/chef/shell/shell_session.rb', line 86 def cookbook_loader nil end |
#definitions ⇒ Object
82 83 84 |
# File 'lib/chef/shell/shell_session.rb', line 82 def definitions nil end |
#node_built? ⇒ Boolean
50 51 52 |
# File 'lib/chef/shell/shell_session.rb', line 50 def node_built? !!@node_built end |
#rebuild_context ⇒ Object
94 95 96 |
# File 'lib/chef/shell/shell_session.rb', line 94 def rebuild_context raise "Not Implemented! :rebuild_collection should be implemented by subclasses" end |
#reset! ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/chef/shell/shell_session.rb', line 54 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_collection ⇒ Object
73 74 75 |
# File 'lib/chef/shell/shell_session.rb', line 73 def resource_collection run_context.resource_collection end |