Class: Shef::ShefSession

Inherits:
Object
  • 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.



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

def initialize
  @node_built = false
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



36
37
38
# File 'lib/chef/shef/shef_session.rb', line 36

def client
  @client
end

#compileObject

Returns the value of attribute compile.



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

def compile
  @compile
end

#nodeObject

Returns the value of attribute node.



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

def node
  @node
end

#node_attributesObject

Returns the value of attribute node_attributes.



36
37
38
# File 'lib/chef/shef/shef_session.rb', line 36

def node_attributes
  @node_attributes
end

#recipeObject

Returns the value of attribute recipe.



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

def recipe
  @recipe
end

#run_contextObject

Returns the value of attribute run_context.



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

def run_context
  @run_context
end

Class Method Details

.inspectObject



121
122
123
# File 'lib/chef/shef/shef_session.rb', line 121

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

.session_type(type = nil) ⇒ Object



30
31
32
33
# File 'lib/chef/shef/shef_session.rb', line 30

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

Instance Method Details

#cookbook_loaderObject



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

def cookbook_loader
  nil
end

#definitionsObject



72
73
74
# File 'lib/chef/shef/shef_session.rb', line 72

def definitions
  nil
end

#node_built?Boolean

Returns:

  • (Boolean)


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

def node_built?
  !!@node_built
end

#rebuild_contextObject



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

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

#reset!Object



45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/chef/shef/shef_session.rb', line 45

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



64
65
66
# File 'lib/chef/shef/shef_session.rb', line 64

def resource_collection
  run_context.resource_collection
end

#save_nodeObject



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

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