Class: Puppet::Configurer::Downloader
- Defined in:
- lib/vendor/puppet/configurer/downloader.rb
Instance Attribute Summary collapse
-
#ignore ⇒ Object
readonly
Returns the value of attribute ignore.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Class Method Summary collapse
-
.timeout ⇒ Object
Determine the timeout value to use.
Instance Method Summary collapse
- #catalog ⇒ Object
-
#evaluate ⇒ Object
Evaluate our download, returning the list of changed values.
- #file ⇒ Object
-
#initialize(name, path, source, ignore = nil) ⇒ Downloader
constructor
A new instance of Downloader.
Constructor Details
#initialize(name, path, source, ignore = nil) ⇒ Downloader
Returns a new instance of Downloader.
47 48 49 |
# File 'lib/vendor/puppet/configurer/downloader.rb', line 47 def initialize(name, path, source, ignore = nil) @name, @path, @source, @ignore = name, path, source, ignore end |
Instance Attribute Details
#ignore ⇒ Object (readonly)
Returns the value of attribute ignore.
5 6 7 |
# File 'lib/vendor/puppet/configurer/downloader.rb', line 5 def ignore @ignore end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/vendor/puppet/configurer/downloader.rb', line 5 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
5 6 7 |
# File 'lib/vendor/puppet/configurer/downloader.rb', line 5 def path @path end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
5 6 7 |
# File 'lib/vendor/puppet/configurer/downloader.rb', line 5 def source @source end |
Class Method Details
.timeout ⇒ Object
Determine the timeout value to use.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/vendor/puppet/configurer/downloader.rb', line 8 def self.timeout timeout = Puppet[:configtimeout] case timeout when String if timeout =~ /^\d+$/ timeout = Integer(timeout) else raise ArgumentError, "Configuration timeout must be an integer" end when Integer # nothing else raise ArgumentError, "Configuration timeout must be an integer" end timeout end |
Instance Method Details
#catalog ⇒ Object
51 52 53 54 55 56 |
# File 'lib/vendor/puppet/configurer/downloader.rb', line 51 def catalog catalog = Puppet::Resource::Catalog.new catalog.host_config = false catalog.add_resource(file) catalog end |
#evaluate ⇒ Object
Evaluate our download, returning the list of changed values.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/vendor/puppet/configurer/downloader.rb', line 26 def evaluate Puppet.info "Retrieving #{name}" files = [] begin Timeout.timeout(self.class.timeout) do catalog.apply do |trans| trans.changed?.find_all do |resource| yield resource if block_given? files << resource[:path] end end end rescue Puppet::Error, Timeout::Error => detail puts detail.backtrace if Puppet[:debug] Puppet.err "Could not retrieve #{name}: #{detail}" end files end |