chef-server-api/app/controllers/nodes.rb
# Return a hash, cookbook_name => cookbook manifest, of the cookbooks
# appropriate for this node, using its run_list and environment.
Return a hash, cookbook_name => cookbook manifest, of the cookbooks
appropriate for this node, using its run_list and environment.
Return a hash cookbook_name = > cookbook manifest of the cookbooks appropriate for this node using its run_list and environment .
def cookbooks
    begin
      @node = Chef::Node.cdb_load(params[:id])
    rescue Chef::Exceptions::CouchDBNotFound => e
      raise NotFound, "Cannot load node #{params[:id]}"
    end
    begin
      included_cookbooks = Chef::CookbookVersionSelector.expand_to_cookbook_versions(@node.run_list, @node.chef_environment)
    rescue Chef::Exceptions::CookbookVersionSelection::InvalidRunListItems => e
      raise PreconditionFailed, e.to_json
    rescue Chef::Exceptions::CookbookVersionSelection::UnsatisfiableRunListItem => e
      raise PreconditionFailed, e.to_json
    end
    display(included_cookbooks.inject({}) do |acc, (cookbook_name, cookbook_version)|
              acc[cookbook_name.to_s] = cookbook_version.generate_manifest_with_urls{|opts| absolute_url(:cookbook_file, opts) }
              acc
            end)
  end
def cookbooks begin @node = Chef :: Node . cdb_load ( params [ :id ] ) rescue Chef :: Exceptions :: CouchDBNotFound => e raise NotFound , "Cannot load node #{params[:id]}" end begin included_cookbooks = Chef :: CookbookVersionSelector . expand_to_cookbook_versions ( @node . run_list , @node . chef_environment ) rescue Chef :: Exceptions :: CookbookVersionSelection :: InvalidRunListItems => e raise PreconditionFailed , e . to_json rescue Chef :: Exceptions :: CookbookVersionSelection :: UnsatisfiableRunListItem => e raise PreconditionFailed , e . to_json end display ( included_cookbooks . inject ( { } ) do | acc , ( cookbook_name , cookbook_version ) | acc [ cookbook_name . to_s ] = cookbook_version . generate_manifest_with_urls { | opts | absolute_url ( :cookbook_file , opts ) } acc end ) end
Return a hash, cookbook_name => cookbook manifest, of the cookbooks
appropriate for this node, using its run_list and environment.
Return a hash cookbook_name = > cookbook manifest of the cookbooks appropriate for this node using its run_list and environment .
# Get the mapping of cookbook_name => CookbookVersion applicable to # this node's run_list and its environment. # Convert from #  name => CookbookVersion # to #  name => cookbook manifest # and display.