Class: Chef::ChefFS::FileSystem::NodesDir
- Inherits:
-
RestListDir
- Object
- BaseFSObject
- BaseFSDir
- RestListDir
- Chef::ChefFS::FileSystem::NodesDir
- Defined in:
- lib/chef/chef_fs/file_system/nodes_dir.rb
Instance Attribute Summary
Attributes inherited from RestListDir
Attributes inherited from BaseFSObject
Instance Method Summary collapse
-
#children ⇒ Object
Identical to RestListDir.children, except supports environments.
- #env_api_path ⇒ Object
-
#initialize(parent) ⇒ NodesDir
constructor
A new instance of NodesDir.
Methods inherited from RestListDir
#_make_child_entry, #can_have_child?, #child, #create_child, #environment, #org, #rest
Methods inherited from BaseFSDir
#can_have_child?, #child, #dir?
Methods inherited from BaseFSObject
#can_have_child?, #chef_object, #child, #compare_to, #create_child, #delete, #dir?, #exists?, #path_for_printing, #read, #root, #write
Constructor Details
#initialize(parent) ⇒ NodesDir
Returns a new instance of NodesDir.
28 29 30 |
# File 'lib/chef/chef_fs/file_system/nodes_dir.rb', line 28 def initialize(parent) super("nodes", parent, nil, Chef::ChefFS::DataHandler::NodeDataHandler.new) end |
Instance Method Details
#children ⇒ Object
Identical to RestListDir.children, except supports environments
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/chef/chef_fs/file_system/nodes_dir.rb', line 33 def children begin @children ||= root.get_json(env_api_path).keys.sort.map do |key| _make_child_entry("#{key}.json", 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 end |
#env_api_path ⇒ Object
49 50 51 |
# File 'lib/chef/chef_fs/file_system/nodes_dir.rb', line 49 def env_api_path environment ? "environments/#{environment}/#{api_path}" : api_path end |