Class: Chef::ChefFS::FileSystem::ChefServer::NodesDir

Inherits:
RestListDir show all
Defined in:
lib/chef/chef_fs/file_system/chef_server/nodes_dir.rb

Instance Attribute Summary

Attributes inherited from RestListDir

#api_path, #data_handler

Attributes inherited from BaseFSObject

#name, #parent, #path

Instance Method Summary collapse

Methods inherited from RestListDir

#can_have_child?, #create_child, #environment, #initialize, #make_child_entry, #org, #rest

Methods inherited from BaseFSDir

#can_have_child?, #dir?, #empty?, #initialize

Methods inherited from BaseFSObject

#can_have_child?, #chef_object, #child, #compare_to, #create_child, #delete, #dir?, #exists?, #initialize, #path_for_printing, #read, #root, #write

Constructor Details

This class inherits a constructor from Chef::ChefFS::FileSystem::ChefServer::RestListDir

Instance Method Details

#childrenObject

Identical to RestListDir.children, except supports environments


30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/chef/chef_fs/file_system/chef_server/nodes_dir.rb', line 30

def children
  @children ||= root.get_json(env_api_path).keys.sort.map do |key|
    make_child_entry(key, true)
  end
rescue Timeout::Error => e
  raise Chef::ChefFS::FileSystem::OperationFailedError.new(:children, self, e, "Timeout retrieving children: #{e}")
rescue Net::HTTPServerException => e
  if $!.response.code == "404"
    raise Chef::ChefFS::FileSystem::NotFoundError.new(self, $!)
  else
    raise Chef::ChefFS::FileSystem::OperationFailedError.new(:children, self, e, "HTTP error retrieving children: #{e}")
  end
end

#env_api_pathObject


44
45
46
# File 'lib/chef/chef_fs/file_system/chef_server/nodes_dir.rb', line 44

def env_api_path
  environment ? "environments/#{environment}/#{api_path}" : api_path
end