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.



25
26
27
# File 'lib/chef/shef/shef_session.rb', line 25

def initialize
  @node_built = false
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



23
24
25
# File 'lib/chef/shef/shef_session.rb', line 23

def client
  @client
end

#compileObject

Returns the value of attribute compile.



22
23
24
# File 'lib/chef/shef/shef_session.rb', line 22

def compile
  @compile
end

#nodeObject

Returns the value of attribute node.



22
23
24
# File 'lib/chef/shef/shef_session.rb', line 22

def node
  @node
end

#node_attributesObject

Returns the value of attribute node_attributes.



23
24
25
# File 'lib/chef/shef/shef_session.rb', line 23

def node_attributes
  @node_attributes
end

#recipeObject

Returns the value of attribute recipe.



22
23
24
# File 'lib/chef/shef/shef_session.rb', line 22

def recipe
  @recipe
end

Class Method Details

.inspectObject



102
103
104
# File 'lib/chef/shef/shef_session.rb', line 102

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

Instance Method Details

#collectionObject



49
50
51
# File 'lib/chef/shef/shef_session.rb', line 49

def collection
  @collection || rebuild_collection
end

#cookbook_loaderObject



57
58
59
# File 'lib/chef/shef/shef_session.rb', line 57

def cookbook_loader
  nil
end

#definitionsObject



53
54
55
# File 'lib/chef/shef/shef_session.rb', line 53

def definitions
  nil
end

#node_built?Boolean

Returns:

  • (Boolean)


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

def node_built?
  !!@node_built
end

#rebuild_collectionObject



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

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

#reset!Object



33
34
35
36
37
38
39
40
41
42
# File 'lib/chef/shef/shef_session.rb', line 33

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

#save_nodeObject



61
62
63
# File 'lib/chef/shef/shef_session.rb', line 61

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