Class: Shef::ShefSession

Inherits:
Object show all
Includes:
Singleton
Defined in:
lib/chef/shef/shef_session.rb

Direct Known Subclasses

SoloSession, StandAloneSession

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeShefSession

Returns a new instance of ShefSession.



40
41
42
# File 'lib/chef/shef/shef_session.rb', line 40

def initialize
  @node_built = false
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



39
40
41
# File 'lib/chef/shef/shef_session.rb', line 39

def client
  @client
end

#compileObject

Returns the value of attribute compile.



38
39
40
# File 'lib/chef/shef/shef_session.rb', line 38

def compile
  @compile
end

#nodeObject

Returns the value of attribute node.



38
39
40
# File 'lib/chef/shef/shef_session.rb', line 38

def node
  @node
end

#node_attributesObject

Returns the value of attribute node_attributes.



39
40
41
# File 'lib/chef/shef/shef_session.rb', line 39

def node_attributes
  @node_attributes
end

#recipeObject

Returns the value of attribute recipe.



38
39
40
# File 'lib/chef/shef/shef_session.rb', line 38

def recipe
  @recipe
end

#run_contextObject

Returns the value of attribute run_context.



38
39
40
# File 'lib/chef/shef/shef_session.rb', line 38

def run_context
  @run_context
end

Class Method Details

.inspectObject



124
125
126
# File 'lib/chef/shef/shef_session.rb', line 124

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

.session_type(type = nil) ⇒ Object



33
34
35
36
# File 'lib/chef/shef/shef_session.rb', line 33

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

Instance Method Details

#cookbook_loaderObject



79
80
81
# File 'lib/chef/shef/shef_session.rb', line 79

def cookbook_loader
  nil
end

#definitionsObject



75
76
77
# File 'lib/chef/shef/shef_session.rb', line 75

def definitions
  nil
end

#node_built?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/chef/shef/shef_session.rb', line 44

def node_built?
  !!@node_built
end

#rebuild_contextObject



87
88
89
# File 'lib/chef/shef/shef_session.rb', line 87

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

#reset!Object



48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/chef/shef/shef_session.rb', line 48

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

#resource_collectionObject



67
68
69
# File 'lib/chef/shef/shef_session.rb', line 67

def resource_collection
  run_context.resource_collection
end

#save_nodeObject



83
84
85
# File 'lib/chef/shef/shef_session.rb', line 83

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