bolt 0.21.1 → 0.21.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of bolt might be problematic. Click here for more details.

Files changed (105) hide show
  1. checksums.yaml +5 -5
  2. data/lib/bolt/applicator.rb +56 -0
  3. data/lib/bolt/error.rb +6 -0
  4. data/lib/bolt/pal.rb +8 -1
  5. data/lib/bolt/transport/winrm.rb +4 -1
  6. data/lib/bolt/version.rb +1 -1
  7. data/libexec/apply_catalog.rb +61 -0
  8. data/{exe → libexec}/bolt_catalog +0 -0
  9. data/vendored/puppet/lib/puppet/application.rb +8 -1
  10. data/vendored/puppet/lib/puppet/application/device.rb +24 -28
  11. data/vendored/puppet/lib/puppet/application/doc.rb +4 -2
  12. data/vendored/puppet/lib/puppet/configurer/plugin_handler.rb +1 -2
  13. data/vendored/puppet/lib/puppet/datatypes.rb +1 -1
  14. data/vendored/puppet/lib/puppet/defaults.rb +2 -6
  15. data/vendored/puppet/lib/puppet/environments.rb +4 -10
  16. data/vendored/puppet/lib/puppet/error.rb +1 -1
  17. data/vendored/puppet/lib/puppet/etc.rb +4 -5
  18. data/vendored/puppet/lib/puppet/face/config.rb +1 -1
  19. data/vendored/puppet/lib/puppet/face/module/build.rb +5 -55
  20. data/vendored/puppet/lib/puppet/face/module/generate.rb +5 -247
  21. data/vendored/puppet/lib/puppet/gettext/config.rb +28 -5
  22. data/vendored/puppet/lib/puppet/indirector/catalog/compiler.rb +5 -7
  23. data/vendored/puppet/lib/puppet/indirector/rest.rb +7 -56
  24. data/vendored/puppet/lib/puppet/indirector/terminus.rb +1 -1
  25. data/vendored/puppet/lib/puppet/interface.rb +1 -1
  26. data/vendored/puppet/lib/puppet/interface/face_collection.rb +3 -1
  27. data/vendored/puppet/lib/puppet/metatype/manager.rb +2 -2
  28. data/vendored/puppet/lib/puppet/module_tool/applications.rb +0 -1
  29. data/vendored/puppet/lib/puppet/module_tool/applications/application.rb +1 -1
  30. data/vendored/puppet/lib/puppet/network/http/connection.rb +2 -23
  31. data/vendored/puppet/lib/puppet/network/http/factory.rb +2 -6
  32. data/vendored/puppet/lib/puppet/node.rb +1 -2
  33. data/vendored/puppet/lib/puppet/node/environment.rb +5 -1
  34. data/vendored/puppet/lib/puppet/parser/functions.rb +35 -3
  35. data/vendored/puppet/lib/puppet/pops/evaluator/evaluator_impl.rb +12 -0
  36. data/vendored/puppet/lib/puppet/pops/loader/static_loader.rb +0 -5
  37. data/vendored/puppet/lib/puppet/pops/model/ast.rb +107 -0
  38. data/vendored/puppet/lib/puppet/pops/model/factory.rb +11 -0
  39. data/vendored/puppet/lib/puppet/pops/model/model_label_provider.rb +2 -0
  40. data/vendored/puppet/lib/puppet/pops/parser/eparser.rb +1519 -1485
  41. data/vendored/puppet/lib/puppet/pops/parser/lexer2.rb +1 -1
  42. data/vendored/puppet/lib/puppet/pops/puppet_stack.rb +1 -1
  43. data/vendored/puppet/lib/puppet/pops/serialization/to_data_converter.rb +1 -1
  44. data/vendored/puppet/lib/puppet/pops/types/p_binary_type.rb +1 -2
  45. data/vendored/puppet/lib/puppet/pops/types/types.rb +1 -24
  46. data/vendored/puppet/lib/puppet/pops/validation/checker4_0.rb +5 -0
  47. data/vendored/puppet/lib/puppet/pops/validation/tasks_checker.rb +31 -4
  48. data/vendored/puppet/lib/puppet/provider.rb +12 -1
  49. data/vendored/puppet/lib/puppet/provider/package/dnf.rb +2 -1
  50. data/vendored/puppet/lib/puppet/provider/selmodule/semodule.rb +1 -1
  51. data/vendored/puppet/lib/puppet/provider/service/base.rb +1 -1
  52. data/vendored/puppet/lib/puppet/provider/service/systemd.rb +3 -1
  53. data/vendored/puppet/lib/puppet/provider/service/upstart.rb +2 -0
  54. data/vendored/puppet/lib/puppet/reference/configuration.rb +6 -0
  55. data/vendored/puppet/lib/puppet/reports.rb +2 -2
  56. data/vendored/puppet/lib/puppet/resource/status.rb +2 -0
  57. data/vendored/puppet/lib/puppet/resource/type_collection.rb +1 -1
  58. data/vendored/puppet/lib/puppet/rest/client.rb +28 -24
  59. data/vendored/puppet/lib/puppet/rest/response.rb +5 -0
  60. data/vendored/puppet/lib/puppet/rest/route.rb +13 -31
  61. data/vendored/puppet/lib/puppet/rest/routes.rb +65 -5
  62. data/vendored/puppet/lib/puppet/rest/ssl_context.rb +13 -0
  63. data/vendored/puppet/lib/puppet/settings.rb +6 -0
  64. data/vendored/puppet/lib/puppet/settings/config_file.rb +1 -2
  65. data/vendored/puppet/lib/puppet/ssl/certificate_request.rb +5 -1
  66. data/vendored/puppet/lib/puppet/ssl/host.rb +148 -43
  67. data/vendored/puppet/lib/puppet/ssl/oids.rb +1 -1
  68. data/vendored/puppet/lib/puppet/test/test_helper.rb +3 -0
  69. data/vendored/puppet/lib/puppet/transaction/event_manager.rb +3 -1
  70. data/vendored/puppet/lib/puppet/transaction/report.rb +1 -1
  71. data/vendored/puppet/lib/puppet/type.rb +2 -2
  72. data/vendored/puppet/lib/puppet/type/file/content.rb +2 -3
  73. data/vendored/puppet/lib/puppet/type/schedule.rb +33 -84
  74. data/vendored/puppet/lib/puppet/type/user.rb +1 -1
  75. data/vendored/puppet/lib/puppet/util.rb +5 -0
  76. data/vendored/puppet/lib/puppet/util/autoload.rb +39 -31
  77. data/vendored/puppet/lib/puppet/util/character_encoding.rb +0 -22
  78. data/vendored/puppet/lib/puppet/util/command_line.rb +0 -1
  79. data/vendored/puppet/lib/puppet/util/connection.rb +74 -0
  80. data/vendored/puppet/lib/puppet/util/feature.rb +2 -2
  81. data/vendored/puppet/lib/puppet/util/instance_loader.rb +1 -19
  82. data/vendored/puppet/lib/puppet/util/json.rb +0 -8
  83. data/vendored/puppet/lib/puppet/util/log/destinations.rb +1 -1
  84. data/vendored/puppet/lib/puppet/util/network_device/base.rb +1 -1
  85. data/vendored/puppet/lib/puppet/util/platform.rb +3 -0
  86. data/vendored/puppet/lib/puppet/util/rdoc/parser/puppet_parser_core.rb +1 -1
  87. data/vendored/puppet/lib/puppet/util/reference.rb +2 -2
  88. data/vendored/puppet/lib/puppet/util/rubygems.rb +1 -13
  89. data/vendored/puppet/lib/puppet/util/ssl.rb +40 -1
  90. data/vendored/puppet/lib/puppet/util/windows.rb +1 -0
  91. data/vendored/puppet/lib/puppet/util/windows/file.rb +18 -0
  92. data/vendored/puppet/lib/puppet/util/windows/security.rb +26 -14
  93. metadata +8 -73
  94. data/vendored/puppet/lib/puppet/module_tool/applications/builder.rb +0 -152
  95. data/vendored/puppet/lib/puppet/module_tool/skeleton/templates/generator/spec/spec_helper.rb +0 -1
  96. data/vendored/puppet/lib/puppet/provider/mailalias/aliases.rb +0 -50
  97. data/vendored/puppet/lib/puppet/provider/maillist/mailman.rb +0 -108
  98. data/vendored/puppet/lib/puppet/provider/zfs/zfs.rb +0 -108
  99. data/vendored/puppet/lib/puppet/provider/zone/solaris.rb +0 -364
  100. data/vendored/puppet/lib/puppet/provider/zpool/zpool.rb +0 -125
  101. data/vendored/puppet/lib/puppet/type/mailalias.rb +0 -46
  102. data/vendored/puppet/lib/puppet/type/maillist.rb +0 -62
  103. data/vendored/puppet/lib/puppet/type/zfs.rb +0 -154
  104. data/vendored/puppet/lib/puppet/type/zone.rb +0 -382
  105. data/vendored/puppet/lib/puppet/type/zpool.rb +0 -91
@@ -187,7 +187,7 @@ module Puppet::SSL::Oids
187
187
  else
188
188
  second_oid.index(first_oid) == 0
189
189
  end
190
- rescue OpenSSL::ASN1::ASN1Error
190
+ rescue OpenSSL::ASN1::ASN1Error, TypeError
191
191
  false
192
192
  end
193
193
  end
@@ -143,6 +143,9 @@ module Puppet::Test
143
143
  Puppet::Application.clear!
144
144
  Puppet::Util::Profiler.clear
145
145
 
146
+ Puppet::SSL::Host.reset
147
+ Puppet::SSL::Host.ca_location = :none
148
+
146
149
  Puppet.clear_deprecation_warnings
147
150
  end
148
151
 
@@ -151,9 +151,11 @@ class Puppet::Transaction::EventManager
151
151
  end
152
152
  return true
153
153
  rescue => detail
154
- resource.err _("Failed to call %{callback}: %{detail}") % { callback: callback, detail: detail }
154
+ resource_error_message = _("Failed to call %{callback}: %{detail}") % { callback: callback, detail: detail }
155
+ resource.err resource_error_message
155
156
 
156
157
  transaction.resource_status(resource).failed_to_restart = true
158
+ transaction.resource_status(resource).fail_with_event(resource_error_message)
157
159
  resource.log_exception(detail)
158
160
  return false
159
161
  end
@@ -224,7 +224,7 @@ class Puppet::Transaction::Report
224
224
  @external_times ||= {}
225
225
  @host = Puppet[:node_name_value]
226
226
  @time = Time.now
227
- @report_format = 9
227
+ @report_format = 10
228
228
  @puppet_version = Puppet.version
229
229
  @configuration_version = configuration_version
230
230
  @transaction_uuid = transaction_uuid
@@ -1799,7 +1799,7 @@ end
1799
1799
  name = name.intern
1800
1800
 
1801
1801
  # If we don't have it yet, try loading it.
1802
- @providerloader.load(name) unless provider_hash.has_key?(name)
1802
+ @providerloader.load(name, Puppet.lookup(:current_environment)) unless provider_hash.has_key?(name)
1803
1803
  provider_hash[name]
1804
1804
  end
1805
1805
 
@@ -1966,7 +1966,7 @@ end
1966
1966
  # @return [Array<Puppet::Provider>] Returns an array of all suitable providers.
1967
1967
  #
1968
1968
  def self.suitableprovider
1969
- providerloader.loadall if provider_hash.empty?
1969
+ providerloader.loadall(Puppet.lookup(:current_environment)) if provider_hash.empty?
1970
1970
  provider_hash.find_all { |name, provider|
1971
1971
  provider.suitable?
1972
1972
  }.collect { |name, provider|
@@ -122,9 +122,8 @@ module Puppet
122
122
 
123
123
  # Make sure we're also managing the checksum property.
124
124
  def should=(value)
125
- # treat the value as a bytestring, in Ruby versions that support it, regardless of the encoding
126
- # in which it has been supplied
127
- value = value.dup.force_encoding(Encoding::ASCII_8BIT) if value.respond_to?(:force_encoding)
125
+ # treat the value as a bytestring
126
+ value = value.b if value.is_a?(String)
128
127
  @resource.newattr(:checksum) unless @resource.parameter(:checksum)
129
128
  super
130
129
  end
@@ -112,6 +112,11 @@ module Puppet
112
112
 
113
113
  self.fail _("Invalid range %{value}") % { value: value } if range.length != 2
114
114
 
115
+ # Fill out 0s for unspecified minutes and seconds
116
+ range.each do |time_array|
117
+ (3 - time_array.length).times { |_| time_array << 0 }
118
+ end
119
+
115
120
  # Make sure the hours are valid
116
121
  [range[0][0], range[1][0]].each do |n|
117
122
  raise ArgumentError, _("Invalid hour '%{n}'") % { n: n } if n < 0 or n > 23
@@ -127,100 +132,44 @@ module Puppet
127
132
  ret
128
133
  end
129
134
 
135
+ def weekday_match?(day)
136
+ if @resource[:weekday]
137
+ @resource[:weekday].has_key?(day)
138
+ else
139
+ true
140
+ end
141
+ end
142
+
130
143
  def match?(previous, now)
131
144
  # The lowest-level array is of the hour, minute, second triad
132
145
  # then it's an array of two of those, to present the limits
133
146
  # then it's an array of those ranges
134
147
  @value = [@value] unless @value[0][0].is_a?(Array)
148
+ @value.any? do |range|
149
+ limit_start = Time.local(now.year, now.month, now.day, *range[0])
150
+ limit_end = Time.local(now.year, now.month, now.day, *range[1])
135
151
 
136
- @value.each do |value|
137
- limits = value.collect do |range|
138
- ary = [now.year, now.month, now.day, range[0]]
139
- if range[1]
140
- ary << range[1]
141
- else
142
- ary << 0
143
- end
144
-
145
- if range[2]
146
- ary << range[2]
152
+ if limit_start < limit_end
153
+ # The whole range is in one day, simple case
154
+ now.between?(limit_start, limit_end) && weekday_match?(now.wday)
155
+ else
156
+ # The range spans days. We have to test against a range starting
157
+ # today, and a range that started yesterday.
158
+ today = Date.new(now.year, now.month, now.day)
159
+ tomorrow = today.next_day
160
+ yesterday = today.prev_day
161
+
162
+ # First check a range starting today
163
+ if now.between?(limit_start, Time.local(tomorrow.year, tomorrow.month, tomorrow.day, *range[1]))
164
+ weekday_match?(today.wday)
147
165
  else
148
- ary << 0
149
- end
150
-
151
- time = Time.local(*ary)
152
-
153
- unless time.hour == range[0]
154
- self.devfail(
155
- _("Incorrectly converted time: %{time}: %{hour} vs %{value}") % { time: time, hour: time.hour, value: range[0] }
156
- )
166
+ # Then check a range starting yesterday
167
+ now.between?(Time.local(yesterday.year, yesterday.month, yesterday.day, *range[0]),
168
+ limit_end) &&
169
+ weekday_match?(yesterday.wday)
157
170
  end
158
-
159
- time
160
- end
161
-
162
- unless limits[0] < limits[1]
163
- self.info(
164
- _("Assuming upper limit should be that time the next day")
165
- )
166
-
167
- # Find midnight between the two days. Adding one second
168
- # to the end of the day is easier than dealing with dates.
169
- ary = limits[0].to_a
170
- ary[0] = 59
171
- ary[1] = 59
172
- ary[2] = 23
173
- midnight = Time.local(*ary)+1
174
-
175
- # If it is currently between the range start and midnight
176
- # we consider that a successful match.
177
- if now.between?(limits[0], midnight)
178
- # We have to check the weekday match here as it is special-cased
179
- # to support day-spanning ranges.
180
- if @resource[:weekday]
181
- return false unless @resource[:weekday].has_key?(now.wday)
182
- end
183
- return true
184
- end
185
-
186
- # If we didn't match between the starting time and midnight
187
- # we must now move our midnight back 24 hours and try
188
- # between the new midnight (24 hours prior) and the
189
- # ending time.
190
- midnight -= 86400
191
-
192
- # Now we compare the current time between midnight and the
193
- # end time.
194
- if now.between?(midnight, limits[1])
195
- # This case is the reason weekday matching is special cased
196
- # in the range parameter. If we match a range that has spanned
197
- # past midnight we want to match against the weekday when the range
198
- # started, not when it currently is.
199
- if @resource[:weekday]
200
- return false unless @resource[:weekday].has_key?((now - 86400).wday)
201
- end
202
- return true
203
- end
204
-
205
- # If neither of the above matched then we don't match the
206
- # range schedule.
207
- return false
208
- end
209
-
210
- # Check to see if a weekday parameter was specified and, if so,
211
- # do we match it or not. If we fail we can stop here.
212
- # This is required because spanning ranges forces us to check
213
- # weekday within the range parameter.
214
- if @resource[:weekday]
215
- return false unless @resource[:weekday].has_key?(now.wday)
216
171
  end
217
-
218
- return true if now.between?(*limits)
219
172
  end
220
-
221
- # Else, return false, since our current time isn't between
222
- # any valid times
223
- false
224
173
  end
225
174
  end
226
175
 
@@ -184,7 +184,7 @@ module Puppet
184
184
  # encoding to support concatenation for display.
185
185
  # overrides Puppet::Property#change_to_s
186
186
  def change_to_s(currentvalue, newvalue)
187
- if newvalue.respond_to?(:force_encoding) && !Encoding.compatible?(currentvalue, newvalue)
187
+ if newvalue.is_a?(String) && !Encoding.compatible?(currentvalue, newvalue)
188
188
  return super(currentvalue, newvalue.dup.force_encoding(currentvalue.encoding))
189
189
  end
190
190
  super(currentvalue, newvalue)
@@ -631,6 +631,11 @@ module Util
631
631
  Puppet::Util::Windows::File.replace_file(FileSystem.path_string(file), tempfile.path)
632
632
 
633
633
  else
634
+ # MRI Ruby checks for this and raises an error, while JRuby removes the directory
635
+ # and replaces it with a file. This makes the our version of replace_file() consistent
636
+ if Puppet::FileSystem.exist?(file) && Puppet::FileSystem.directory?(file)
637
+ raise Errno::EISDIR, _("Is a directory: %{directory}") % { directory: file }
638
+ end
634
639
  File.rename(tempfile.path, Puppet::FileSystem.path_string(file))
635
640
  end
636
641
  ensure
@@ -35,19 +35,20 @@ class Puppet::Util::Autoload
35
35
  # Save the fact that a given path has been loaded. This is so
36
36
  # we can load downloaded plugins if they've already been loaded
37
37
  # into memory.
38
+ # @api private
38
39
  def mark_loaded(name, file)
39
40
  name = cleanpath(name).chomp('.rb')
40
- ruby_file = name + ".rb"
41
- $LOADED_FEATURES << ruby_file unless $LOADED_FEATURES.include?(ruby_file)
41
+ file = File.expand_path(file)
42
+ $LOADED_FEATURES << file unless $LOADED_FEATURES.include?(file)
42
43
  loaded[name] = [file, File.mtime(file)]
43
44
  end
44
45
 
45
- def changed?(name)
46
+ # @api private
47
+ def changed?(name, env)
46
48
  name = cleanpath(name).chomp('.rb')
47
49
  return true unless loaded.include?(name)
48
50
  file, old_mtime = loaded[name]
49
- environment = Puppet.lookup(:current_environment)
50
- return true unless file == get_file(name, environment)
51
+ return true unless file == get_file(name, env)
51
52
  begin
52
53
  old_mtime.to_i != File.mtime(file).to_i
53
54
  rescue Errno::ENOENT
@@ -73,7 +74,7 @@ class Puppet::Util::Autoload
73
74
  end
74
75
  end
75
76
 
76
- def loadall(path, env = nil)
77
+ def loadall(path, env)
77
78
  # Load every instance of everything we can find.
78
79
  files_to_load(path, env).each do |file|
79
80
  name = file.chomp(".rb")
@@ -81,22 +82,28 @@ class Puppet::Util::Autoload
81
82
  end
82
83
  end
83
84
 
84
- def reload_changed
85
- loaded.keys.each { |file| load_file(file, nil) if changed?(file) }
85
+ def reload_changed(env)
86
+ loaded.keys.each do |file|
87
+ if changed?(file, env)
88
+ load_file(file, env)
89
+ end
90
+ end
86
91
  end
87
92
 
88
93
  # Get the correct file to load for a given path
89
94
  # returns nil if no file is found
95
+ # @api private
90
96
  def get_file(name, env)
91
97
  name = name + '.rb' unless name =~ /\.rb$/
92
98
  path = search_directories(env).find { |dir| Puppet::FileSystem.exist?(File.join(dir, name)) }
93
99
  path and File.join(path, name)
94
100
  end
95
101
 
96
- def files_to_load(path, env = nil)
102
+ def files_to_load(path, env)
97
103
  search_directories(env).map {|dir| files_in_dir(dir, path) }.flatten.uniq
98
104
  end
99
105
 
106
+ # @api private
100
107
  def files_in_dir(dir, path)
101
108
  dir = Pathname.new(File.expand_path(dir))
102
109
  Dir.glob(File.join(dir, path, "*.rb")).collect do |file|
@@ -104,7 +111,10 @@ class Puppet::Util::Autoload
104
111
  end
105
112
  end
106
113
 
114
+ # @api private
107
115
  def module_directories(env)
116
+ raise ArgumentError, "Autoloader requires an environment" unless env
117
+
108
118
  # This is a little bit of a hack. Basically, the autoloader is being
109
119
  # called indirectly during application bootstrapping when we do things
110
120
  # such as check "features". However, during bootstrapping, we haven't
@@ -125,27 +135,22 @@ class Puppet::Util::Autoload
125
135
  # "app_defaults_initialized?" method on the main puppet Settings object.
126
136
  # --cprice 2012-03-16
127
137
  if Puppet.settings.app_defaults_initialized?
128
- env ||= Puppet.lookup(:environments).get(Puppet[:environment])
129
-
130
- if env
131
- # if the app defaults have been initialized then it should be safe to access the module path setting.
132
- Puppet::Util::ModuleDirectoriesAdapter.adapt(env) do |a|
133
- a.directories ||= env.modulepath.collect do |dir|
134
- Dir.entries(dir).reject { |f| f =~ /^\./ }.collect { |f| File.join(dir, f, "lib") }
135
- end.flatten.find_all do |d|
136
- FileTest.directory?(d)
137
- end
138
- end.directories
139
- else
140
- []
141
- end
138
+ # if the app defaults have been initialized then it should be safe to access the module path setting.
139
+ Puppet::Util::ModuleDirectoriesAdapter.adapt(env) do |a|
140
+ a.directories ||= env.modulepath.collect do |dir|
141
+ Dir.entries(dir).reject { |f| f =~ /^\./ }.collect { |f| File.join(dir, f, "lib") }
142
+ end.flatten.find_all do |d|
143
+ FileTest.directory?(d)
144
+ end
145
+ end.directories
142
146
  else
143
147
  # if we get here, the app defaults have not been initialized, so we basically use an empty module path.
144
148
  []
145
149
  end
146
150
  end
147
151
 
148
- def libdirs()
152
+ # @api private
153
+ def libdirs
149
154
  # See the comments in #module_directories above. Basically, we need to be careful not to try to access the
150
155
  # libdir before we know for sure that all of the settings have been initialized (e.g., during bootstrapping).
151
156
  if (Puppet.settings.app_defaults_initialized?)
@@ -155,12 +160,14 @@ class Puppet::Util::Autoload
155
160
  end
156
161
  end
157
162
 
163
+ # @api private
158
164
  def gem_directories
159
165
  gem_source.directories
160
166
  end
161
167
 
168
+ # @api private
162
169
  def search_directories(env)
163
- [gem_directories, module_directories(env), libdirs(), $LOAD_PATH].flatten
170
+ [gem_directories, module_directories(env), libdirs, $LOAD_PATH].flatten
164
171
  end
165
172
 
166
173
  # Normalize a path. This converts ALT_SEPARATOR to SEPARATOR on Windows
@@ -185,7 +192,7 @@ class Puppet::Util::Autoload
185
192
  @object = obj
186
193
  end
187
194
 
188
- def load(name, env = nil)
195
+ def load(name, env)
189
196
  self.class.load_file(expand(name), env)
190
197
  end
191
198
 
@@ -199,7 +206,7 @@ class Puppet::Util::Autoload
199
206
  #
200
207
  # This uses require, rather than load, so that already-loaded files don't get
201
208
  # reloaded unnecessarily.
202
- def loadall(env = nil)
209
+ def loadall(env)
203
210
  self.class.loadall(@path, env)
204
211
  end
205
212
 
@@ -207,12 +214,13 @@ class Puppet::Util::Autoload
207
214
  self.class.loaded?(expand(name))
208
215
  end
209
216
 
210
- def changed?(name)
211
- self.class.changed?(expand(name))
217
+ # @api private
218
+ def changed?(name, env)
219
+ self.class.changed?(expand(name), env)
212
220
  end
213
221
 
214
- def files_to_load
215
- self.class.files_to_load(@path)
222
+ def files_to_load(env)
223
+ self.class.files_to_load(@path, env)
216
224
  end
217
225
 
218
226
  def expand(name)
@@ -72,27 +72,5 @@ module Puppet::Util::CharacterEncoding
72
72
  return string_copy.force_encoding(original_encoding)
73
73
  end
74
74
  end
75
-
76
- REPLACEMENT_CHAR_MAP = {
77
- Encoding::UTF_8 => "\uFFFD",
78
- Encoding::UTF_16LE => "\xFD\xFF".force_encoding(Encoding::UTF_16LE),
79
- }
80
-
81
- # Given a string, return a copy of that string with any invalid byte
82
- # sequences in its current encoding replaced with the replacement character
83
- # "\uFFFD" (UTF-8) if the string is UTF-8 or UTF-16LE, or "?" otherwise.
84
- # @param string a string to remove invalid byte sequences from
85
- # @return a copy of string invalid byte sequences replaced by the unicode
86
- # replacement character or "?" character
87
- # @note does not modify encoding, but new string will have different bytes
88
- # from original. Only needed for ruby 1.9.3 support.
89
- def scrub(string)
90
- if string.respond_to?(:scrub)
91
- string.scrub
92
- else
93
- replacement_character = REPLACEMENT_CHAR_MAP[string.encoding] || '?'
94
- string.chars.map { |c| c.valid_encoding? ? c : replacement_character }.join
95
- end
96
- end
97
75
  end
98
76
  end
@@ -123,7 +123,6 @@ module Puppet
123
123
  $LOAD_PATH << dir unless $LOAD_PATH.include?(dir)
124
124
  end
125
125
 
126
- Puppet::GettextConfig.reset_text_domain('cli')
127
126
  Puppet::ModuleTranslations.load_from_modulepath(configured_environment.modules)
128
127
  Puppet::ModuleTranslations.load_from_vardir(Puppet[:vardir])
129
128
 
@@ -0,0 +1,74 @@
1
+ require 'puppet'
2
+
3
+ module Puppet::Util
4
+ module Connection
5
+ # The logic for server and port is kind of gross. In summary:
6
+ # IF an endpoint-specific setting is requested AND that setting has been set by the user
7
+ # Use that setting.
8
+ # The defaults for these settings are the "normal" server/masterport settings, so
9
+ # when they are unset we instead want to "fall back" to the failover-selected
10
+ # host/port pair.
11
+ # ELSE IF we have a failover-selected host/port
12
+ # Use what the failover logic came up with
13
+ # ELSE IF the server_list setting is in use
14
+ # Use the first entry - failover hasn't happened yet, but that
15
+ # setting is still authoritative
16
+ # ELSE
17
+ # Go for the legacy server/masterport settings, and hope for the best
18
+
19
+ # Determines which server to use based on the specified setting, taking into
20
+ # account HA fallback from server_list.
21
+ # @param [Symbol] setting The preferred server setting to use
22
+ # @return [String] the name of the server for use in the request
23
+ def self.determine_server(setting)
24
+ if setting && setting != :server && Puppet.settings.set_by_config?(setting)
25
+ Puppet[setting]
26
+ else
27
+ server = Puppet.lookup(:server) do
28
+ if primary_server = Puppet.settings[:server_list][0]
29
+ Puppet.debug "Dynamically-bound server lookup failed; using first entry"
30
+ primary_server[0]
31
+ else
32
+ setting ||= :server
33
+ Puppet.debug "Dynamically-bound server lookup failed, falling back to #{setting} setting"
34
+ Puppet.settings[setting]
35
+ end
36
+ end
37
+ server
38
+ end
39
+ end
40
+
41
+ # Determines which port to use based on the specified setting, taking into
42
+ # account HA fallback from server_list.
43
+ # For port there's a little bit of an extra snag: setting a specific
44
+ # server setting and relying on the default port for that server is
45
+ # common, so we also want to check if the assocaited SERVER setting
46
+ # has been set by the user. If either of those are set we ignore the
47
+ # failover-selected port.
48
+ # @param [Symbol] port_setting The preferred port setting to use
49
+ # @param [Symbol] server_setting The server setting assoicated with this route.
50
+ # @return [String] the port to use for use in the request
51
+ def self.determine_port(port_setting, server_setting)
52
+ if (port_setting && port_setting != :masterport && Puppet.settings.set_by_config?(port_setting)) ||
53
+ (server_setting && server_setting != :server && Puppet.settings.set_by_config?(server_setting))
54
+ Puppet.settings[port_setting].to_i
55
+ else
56
+ port = Puppet.lookup(:serverport) do
57
+ if primary_server = Puppet.settings[:server_list][0]
58
+ Puppet.debug "Dynamically-bound port lookup failed; using first entry"
59
+
60
+ # Port might not be set, so we want to fallback in that
61
+ # case. We know we don't need to use `setting` here, since
62
+ # the default value of every port setting is `masterport`
63
+ (primary_server[1] || Puppet.settings[:masterport])
64
+ else
65
+ port_setting ||= :masterport
66
+ Puppet.debug "Dynamically-bound port lookup failed; falling back to #{port_setting} setting"
67
+ Puppet.settings[port_setting]
68
+ end
69
+ end
70
+ port.to_i
71
+ end
72
+ end
73
+ end
74
+ end