class Shell::ShellSession
Attributes
client[R]
compile[RW]
json_configuration[RW]
node[RW]
node_attributes[R]
recipe[RW]
run_context[W]
Public Class Methods
new()
click to toggle source
# File lib/chef/shell/shell_session.rb, line 45 def initialize @node_built = false formatter = Chef::Formatters.new(Chef::Config.formatter, STDOUT, STDERR) @events = Chef::EventDispatch::Dispatcher.new(formatter) end
session_type(type = nil)
click to toggle source
# File lib/chef/shell/shell_session.rb, line 37 def self.session_type(type = nil) @session_type = type if type @session_type end
Public Instance Methods
cookbook_loader()
click to toggle source
# File lib/chef/shell/shell_session.rb, line 88 def cookbook_loader nil end
definitions()
click to toggle source
# File lib/chef/shell/shell_session.rb, line 84 def definitions nil end
node_attributes=(attrs)
click to toggle source
# File lib/chef/shell/shell_session.rb, line 69 def node_attributes=(attrs) @node_attributes = attrs @node.consume_attributes(@node_attributes) end
node_built?()
click to toggle source
# File lib/chef/shell/shell_session.rb, line 51 def node_built? !!@node_built end
rebuild_context()
click to toggle source
# File lib/chef/shell/shell_session.rb, line 96 def rebuild_context raise "Not Implemented! :rebuild_collection should be implemented by subclasses" end
reset!()
click to toggle source
# File lib/chef/shell/shell_session.rb, line 55 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()
click to toggle source
# File lib/chef/shell/shell_session.rb, line 74 def resource_collection run_context.resource_collection end
run_context()
click to toggle source
# File lib/chef/shell/shell_session.rb, line 80 def run_context @run_context ||= rebuild_context end
save_node()
click to toggle source
# File lib/chef/shell/shell_session.rb, line 92 def save_node raise "Not Supported! #{self.class.name} doesn't support #save_node, maybe you need to run #{ChefUtils::Dist::Infra::SHELL} in client mode?" end
Private Instance Methods
loading() { || ... }
click to toggle source
# File lib/chef/shell/shell_session.rb, line 102 def loading show_loading_progress begin yield rescue => e loading_complete(false) raise e else loading_complete(true) end end
loading_complete(success)
click to toggle source
# File lib/chef/shell/shell_session.rb, line 125 def loading_complete(success) @loading = false @dot_printer.join msg = success ? "done.\n\n" : "epic fail!\n\n" print msg end
rebuild_node()
click to toggle source
# File lib/chef/shell/shell_session.rb, line 138 def rebuild_node raise "Not Implemented! :rebuild_node should be implemented by subclasses" end
shorten_node_inspect()
click to toggle source
# File lib/chef/shell/shell_session.rb, line 132 def shorten_node_inspect def @node.inspect # rubocop:disable Lint/NestedMethodDefinition "<Chef::Node:0x#{object_id.to_s(16)} @name=\"#{name}\">" end end
show_loading_progress()
click to toggle source
# File lib/chef/shell/shell_session.rb, line 114 def show_loading_progress print "Loading" @loading = true @dot_printer = Thread.new do while @loading print "." sleep 0.5 end end end