Class: Puppet::Network::Handler::FileBucket
- Defined in:
- lib/vendor/puppet/network/handler/filebucket.rb
Overview
Accept files and store them by md5 sum, returning the md5 sum back to the client. Alternatively, accept an md5 sum and return the associated content.
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#addfile(contents, path, client = nil, clientip = nil) ⇒ Object
Accept a file from a client and store it by md5 sum, returning the sum.
-
#getfile(md5, client = nil, clientip = nil) ⇒ Object
Return the contents associated with a given md5 sum.
-
#initialize(hash) ⇒ FileBucket
constructor
A new instance of FileBucket.
- #to_s ⇒ Object
Constructor Details
#initialize(hash) ⇒ FileBucket
Returns a new instance of FileBucket.
23 24 25 26 |
# File 'lib/vendor/puppet/network/handler/filebucket.rb', line 23 def initialize(hash) @path = hash[:Path] || Puppet[:bucketdir] @name = "Filebucket[#{@path}]" end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
21 22 23 |
# File 'lib/vendor/puppet/network/handler/filebucket.rb', line 21 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
21 22 23 |
# File 'lib/vendor/puppet/network/handler/filebucket.rb', line 21 def path @path end |
Instance Method Details
#addfile(contents, path, client = nil, clientip = nil) ⇒ Object
Accept a file from a client and store it by md5 sum, returning the sum.
30 31 32 33 34 |
# File 'lib/vendor/puppet/network/handler/filebucket.rb', line 30 def addfile(contents, path, client = nil, clientip = nil) contents = Base64.decode64(contents) if client bucket = Puppet::FileBucket::File.new(contents) Puppet::FileBucket::File.indirection.save(bucket) end |
#getfile(md5, client = nil, clientip = nil) ⇒ Object
Return the contents associated with a given md5 sum.
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/vendor/puppet/network/handler/filebucket.rb', line 37 def getfile(md5, client = nil, clientip = nil) bucket = Puppet::FileBucket::File.indirection.find("md5:#{md5}") contents = bucket.contents if client return Base64.encode64(contents) else return contents end end |
#to_s ⇒ Object
48 49 50 |
# File 'lib/vendor/puppet/network/handler/filebucket.rb', line 48 def to_s self.name end |