Class: Puppet::Indirector::FileServer

Inherits:
Terminus show all
Includes:
FileServing::TerminusHelper
Defined in:
lib/vendor/puppet/indirector/file_server.rb

Overview

Look files up using the file server.

Constant Summary

Constants included from Util

Util::AbsolutePathPosix, Util::AbsolutePathWindows

Constants included from Util::Docs

Util::Docs::HEADER_LEVELS

Instance Attribute Summary

Attributes included from Util::Docs

#doc, #nodoc

Instance Method Summary collapse

Methods included from FileServing::TerminusHelper

#path2instances

Methods inherited from Terminus

abstract_terminus?, const2name, #indirection, indirection_name, inherited, #initialize, mark_as_abstract_terminus, #model, model, #name, name2const, register_terminus_class, terminus_class, terminus_classes, #terminus_type

Methods included from Util::InstanceLoader

#instance_docs, #instance_hash, #instance_load, #instance_loader, #instance_loading?, #loaded_instance, #loaded_instances

Methods included from Util

absolute_path?, activerecord_version, benchmark, binread, chuser, classproxy, #execfail, #execpipe, execute, execute_posix, execute_windows, logmethods, memory, path_to_uri, proxy, replace_file, safe_posix_fork, symbolize, symbolizehash, symbolizehash!, synchronize_on, thinmark, #threadlock, uri_to_path, wait_for_output, which, withumask

Methods included from Util::POSIX

#get_posix_field, #gid, #idfield, #methodbyid, #methodbyname, #search_posix_field, #uid

Methods included from Util::Docs

#desc, #dochook, #doctable, #markdown_definitionlist, #markdown_header, #nodoc?, #pad, scrub

Constructor Details

This class inherits a constructor from Puppet::Indirector::Terminus

Instance Method Details

#authorized?(request) ⇒ Boolean

Is the client authorized to perform this action?

Returns:

  • (Boolean)


11
12
13
14
15
16
17
18
19
# File 'lib/vendor/puppet/indirector/file_server.rb', line 11

def authorized?(request)
  return false unless [:find, :search].include?(request.method)

  mount, file_path = configuration.split_path(request)

  # If we're not serving this mount, then access is denied.
  return false unless mount
  mount.allowed?(request.node, request.ip)
end

#find(request) ⇒ Object

Find our key using the fileserver.



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/vendor/puppet/indirector/file_server.rb', line 22

def find(request)
  mount, relative_path = configuration.split_path(request)

  return nil unless mount

  # The mount checks to see if the file exists, and returns nil
  # if not.
  return nil unless path = mount.find(relative_path, request)
  result = model.new(path)
  result.links = request.options[:links] if request.options[:links]
  result.collect
  result
end

#search(request) ⇒ Object

Search for files. This returns an array rather than a single file.



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/vendor/puppet/indirector/file_server.rb', line 38

def search(request)
  mount, relative_path = configuration.split_path(request)

  unless mount and paths = mount.search(relative_path, request)
    Puppet.info "Could not find filesystem info for file '#{request.key}' in environment #{request.environment}"
    return nil
  end

  filesets = paths.collect do |path|
    # Filesets support indirector requests as an options collection
    Puppet::FileServing::Fileset.new(path, request)
  end

  Puppet::FileServing::Fileset.merge(*filesets).collect do |file, base_path|
    inst = model.new(base_path, :relative_path => file)
    inst.links = request.options[:links] if request.options[:links]
    inst.collect
    inst
  end
end