puppet 3.1.0.rc1 → 3.1.0.rc2

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

Potentially problematic release.


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

Files changed (127) hide show
  1. data/COMMITTERS.md +185 -0
  2. data/ext/debian/changelog.erb +6 -0
  3. data/ext/debian/puppet-common.manpages +1 -0
  4. data/ext/debian/puppet.default +3 -1
  5. data/ext/debian/puppetmaster.default +6 -3
  6. data/ext/redhat/puppet.spec.erb +16 -5
  7. data/lib/puppet.rb +3 -5
  8. data/lib/puppet/defaults.rb +6 -5
  9. data/lib/puppet/dsl.rb +3 -7
  10. data/lib/puppet/dsl/resource_api.rb +120 -0
  11. data/lib/puppet/dsl/resource_type_api.rb +34 -0
  12. data/lib/puppet/module_tool.rb +23 -11
  13. data/lib/puppet/network/formats.rb +1 -1
  14. data/lib/puppet/node/environment.rb +1 -3
  15. data/lib/puppet/parser/ast/definition.rb +5 -2
  16. data/lib/puppet/parser/ast/hostclass.rb +3 -2
  17. data/lib/puppet/parser/ast/node.rb +5 -2
  18. data/lib/puppet/parser/ast/resourceparam.rb +1 -1
  19. data/lib/puppet/parser/compiler.rb +0 -10
  20. data/lib/puppet/parser/lexer.rb +50 -39
  21. data/lib/puppet/parser/parser_support.rb +29 -11
  22. data/lib/puppet/parser/scope.rb +2 -2
  23. data/lib/puppet/parser/type_loader.rb +7 -31
  24. data/lib/puppet/provider/package/openbsd.rb +16 -2
  25. data/lib/puppet/provider/package/pip.rb +11 -2
  26. data/lib/puppet/provider/package/portage.rb +29 -12
  27. data/lib/puppet/provider/service/launchd.rb +19 -14
  28. data/lib/puppet/provider/service/upstart.rb +1 -1
  29. data/lib/puppet/provider/user/hpux.rb +37 -2
  30. data/lib/puppet/resource.rb +25 -38
  31. data/lib/puppet/resource/type.rb +6 -14
  32. data/lib/puppet/settings.rb +1 -1
  33. data/lib/puppet/ssl/certificate_authority.rb +4 -1
  34. data/lib/puppet/ssl/certificate_request.rb +3 -1
  35. data/lib/puppet/ssl/certificate_signer.rb +22 -0
  36. data/lib/puppet/type.rb +4 -4
  37. data/lib/puppet/util/methodhelper.rb +0 -19
  38. data/lib/puppet/util/rubygems.rb +3 -1
  39. data/lib/puppet/util/selinux.rb +1 -6
  40. data/lib/puppet/version.rb +1 -1
  41. data/man/man5/puppet.conf.5 +81 -95
  42. data/man/man8/extlookup2hiera.8 +23 -0
  43. data/man/man8/puppet-agent.8 +3 -3
  44. data/man/man8/puppet-apply.8 +2 -6
  45. data/man/man8/puppet-ca.8 +6 -7
  46. data/man/man8/puppet-catalog.8 +6 -7
  47. data/man/man8/puppet-cert.8 +4 -4
  48. data/man/man8/puppet-certificate.8 +6 -7
  49. data/man/man8/puppet-certificate_request.8 +6 -7
  50. data/man/man8/puppet-certificate_revocation_list.8 +6 -7
  51. data/man/man8/puppet-config.8 +4 -8
  52. data/man/man8/puppet-describe.8 +1 -1
  53. data/man/man8/puppet-device.8 +1 -1
  54. data/man/man8/puppet-doc.8 +3 -3
  55. data/man/man8/puppet-facts.8 +4 -8
  56. data/man/man8/puppet-file.8 +6 -7
  57. data/man/man8/puppet-filebucket.8 +1 -1
  58. data/man/man8/puppet-help.8 +2 -6
  59. data/man/man8/puppet-inspect.8 +1 -1
  60. data/man/man8/puppet-instrumentation_data.8 +3 -7
  61. data/man/man8/puppet-instrumentation_listener.8 +3 -7
  62. data/man/man8/puppet-instrumentation_probe.8 +3 -7
  63. data/man/man8/puppet-key.8 +6 -7
  64. data/man/man8/puppet-kick.8 +5 -1
  65. data/man/man8/puppet-man.8 +2 -6
  66. data/man/man8/puppet-master.8 +2 -2
  67. data/man/man8/puppet-module.8 +11 -9
  68. data/man/man8/puppet-node.8 +38 -37
  69. data/man/man8/puppet-parser.8 +2 -6
  70. data/man/man8/puppet-plugin.8 +2 -6
  71. data/man/man8/puppet-queue.8 +1 -1
  72. data/man/man8/puppet-report.8 +3 -7
  73. data/man/man8/puppet-resource.8 +1 -1
  74. data/man/man8/puppet-resource_type.8 +3 -7
  75. data/man/man8/puppet-secret_agent.8 +2 -6
  76. data/man/man8/puppet-status.8 +3 -7
  77. data/man/man8/puppet.8 +1 -1
  78. data/spec/integration/parser/ruby_manifest_spec.rb +128 -0
  79. data/spec/lib/puppet_spec/compiler.rb +0 -11
  80. data/spec/spec_helper.rb +3 -4
  81. data/spec/unit/dsl/resource_api_spec.rb +180 -0
  82. data/spec/unit/dsl/resource_type_api_spec.rb +53 -0
  83. data/spec/unit/module_tool_spec.rb +79 -46
  84. data/spec/unit/network/formats_spec.rb +4 -0
  85. data/spec/unit/node/environment_spec.rb +0 -13
  86. data/spec/unit/parser/compiler_spec.rb +0 -26
  87. data/spec/unit/parser/parser_spec.rb +14 -0
  88. data/spec/unit/parser/type_loader_spec.rb +4 -15
  89. data/spec/unit/provider/package/openbsd_spec.rb +148 -35
  90. data/spec/unit/provider/package/pip_spec.rb +49 -25
  91. data/spec/unit/provider/package/portage_spec.rb +65 -0
  92. data/spec/unit/provider/service/launchd_spec.rb +6 -5
  93. data/spec/unit/provider/user/hpux_spec.rb +39 -11
  94. data/spec/unit/provider/user/useradd_spec.rb +14 -14
  95. data/spec/unit/resource/type_spec.rb +7 -49
  96. data/spec/unit/resource_spec.rb +0 -32
  97. data/spec/unit/ssl/certificate_request_spec.rb +18 -0
  98. data/spec/unit/util/rubygems_spec.rb +1 -1
  99. data/spec/unit/util/selinux_spec.rb +0 -2
  100. metadata +17 -50
  101. data/lib/puppet/dsl/actions.rb +0 -283
  102. data/lib/puppet/dsl/blank_slate.rb +0 -55
  103. data/lib/puppet/dsl/context.rb +0 -393
  104. data/lib/puppet/dsl/parser.rb +0 -57
  105. data/lib/puppet/dsl/resource_decorator.rb +0 -56
  106. data/lib/puppet/dsl/resource_reference.rb +0 -95
  107. data/lib/puppet/dsl/type_reference.rb +0 -102
  108. data/lib/puppet/util/manifest_filetype_helper.rb +0 -22
  109. data/spec/integration/dsl/classes_spec.rb +0 -191
  110. data/spec/integration/dsl/defaults_spec.rb +0 -38
  111. data/spec/integration/dsl/definitions_spec.rb +0 -73
  112. data/spec/integration/dsl/functions_spec.rb +0 -95
  113. data/spec/integration/dsl/nodes_spec.rb +0 -96
  114. data/spec/integration/dsl/params_spec.rb +0 -146
  115. data/spec/integration/dsl/relationships_spec.rb +0 -46
  116. data/spec/integration/dsl/resources_spec.rb +0 -202
  117. data/spec/integration/dsl/type_loading_spec.rb +0 -64
  118. data/spec/lib/matchers/catalog.rb +0 -50
  119. data/spec/lib/puppet_spec/dsl.rb +0 -29
  120. data/spec/unit/dsl/actions_spec.rb +0 -402
  121. data/spec/unit/dsl/blank_slate_spec.rb +0 -27
  122. data/spec/unit/dsl/context_spec.rb +0 -678
  123. data/spec/unit/dsl/parser_spec.rb +0 -56
  124. data/spec/unit/dsl/resource_decorator_spec.rb +0 -94
  125. data/spec/unit/dsl/resource_reference_spec.rb +0 -150
  126. data/spec/unit/dsl/type_reference_spec.rb +0 -164
  127. data/spec/unit/util/manifest_filetype_helper_spec.rb +0 -29
@@ -56,8 +56,22 @@ Puppet::Type.type(:package).provide :openbsd, :parent => Puppet::Provider::Packa
56
56
  should = @resource.should(:ensure)
57
57
 
58
58
  unless @resource[:source]
59
- raise Puppet::Error,
60
- "You must specify a package source for BSD packages"
59
+ if File.exist?("/etc/pkg.conf")
60
+ File.open("/etc/pkg.conf", "rb").readlines.each do |line|
61
+ if matchdata = line.match(/^installpath\s*=\s*(.+)\s*$/i)
62
+ @resource[:source] = matchdata[1]
63
+ break
64
+ end
65
+ end
66
+
67
+ unless @resource[:source]
68
+ raise Puppet::Error,
69
+ "No valid installpath found in /etc/pkg.conf and no source was set"
70
+ end
71
+ else
72
+ raise Puppet::Error,
73
+ "You must specify a package source or configure an installpath in /etc/pkg.conf"
74
+ end
61
75
  end
62
76
 
63
77
  if @resource[:source][-1,1] == ::File::SEPARATOR
@@ -25,7 +25,7 @@ Puppet::Type.type(:package).provide :pip,
25
25
  # that's managed by `pip` or an empty array if `pip` is not available.
26
26
  def self.instances
27
27
  packages = []
28
- pip_cmd = which('pip') or return []
28
+ pip_cmd = which(cmd) or return []
29
29
  execpipe "#{pip_cmd} freeze" do |process|
30
30
  process.collect do |line|
31
31
  next unless options = parse(line)
@@ -35,6 +35,15 @@ Puppet::Type.type(:package).provide :pip,
35
35
  packages
36
36
  end
37
37
 
38
+ def self.cmd
39
+ case Facter.value(:osfamily)
40
+ when "RedHat"
41
+ "pip-python"
42
+ else
43
+ "pip"
44
+ end
45
+ end
46
+
38
47
  # Return structured information about a particular package or `nil` if
39
48
  # it is not installed or `pip` itself is not available.
40
49
  def query
@@ -100,7 +109,7 @@ Puppet::Type.type(:package).provide :pip,
100
109
  def lazy_pip(*args)
101
110
  pip *args
102
111
  rescue NoMethodError => e
103
- if pathname = which('pip')
112
+ if pathname = which(self.class.cmd)
104
113
  self.class.commands :pip => pathname
105
114
  pip *args
106
115
  else
@@ -13,19 +13,17 @@ Puppet::Type.type(:package).provide :portage, :parent => Puppet::Provider::Packa
13
13
  defaultfor :operatingsystem => :gentoo
14
14
 
15
15
  def self.instances
16
- result_format = /^(\S+)\s+(\S+)\s+\[(\S+)\]\s+\[(\S+)\]\s+(\S+)\s+(.*)$/
17
- result_fields = [:category, :name, :ensure, :version_available, :vendor, :description]
18
-
19
- version_format = "{last}<version>{}"
20
- search_format = "<category> <name> [<installedversions:LASTVERSION>] [<bestversion:LASTVERSION>] <homepage> <description>\n"
16
+ result_format = self.eix_result_format
17
+ result_fields = self.eix_result_fields
21
18
 
19
+ version_format = self.eix_version_format
22
20
  begin
23
21
  eix_file = File.directory?("/var/cache/eix") ? "/var/cache/eix/portage.eix" : "/var/cache/eix"
24
22
  update_eix if !FileUtils.uptodate?(eix_file, %w{/usr/bin/eix /usr/portage/metadata/timestamp})
25
23
 
26
24
  search_output = nil
27
25
  Puppet::Util.withenv :LASTVERSION => version_format do
28
- search_output = eix "--nocolor", "--pure-packages", "--stable", "--installed", "--format", search_format
26
+ search_output = eix *(self.eix_search_arguments + ["--installed"])
29
27
  end
30
28
 
31
29
  packages = []
@@ -72,12 +70,10 @@ Puppet::Type.type(:package).provide :portage, :parent => Puppet::Provider::Packa
72
70
  end
73
71
 
74
72
  def query
75
- result_format = /^(\S+)\s+(\S+)\s+\[(\S*)\]\s+\[(\S+)\]\s+(\S+)\s+(.*)$/
76
- result_fields = [:category, :name, :ensure, :version_available, :vendor, :description]
77
-
78
- version_format = "{last}<version>{}"
79
- search_format = "<category> <name> [<installedversions:LASTVERSION>] [<bestversion:LASTVERSION>] <homepage> <description>\n"
73
+ result_format = self.class.eix_result_format
74
+ result_fields = self.class.eix_result_fields
80
75
 
76
+ version_format = self.class.eix_version_format
81
77
  search_field = package_name.count('/') > 0 ? "--category-name" : "--name"
82
78
  search_value = package_name
83
79
 
@@ -87,7 +83,7 @@ Puppet::Type.type(:package).provide :portage, :parent => Puppet::Provider::Packa
87
83
 
88
84
  search_output = nil
89
85
  Puppet::Util.withenv :LASTVERSION => version_format do
90
- search_output = eix "--nocolor", "--pure-packages", "--stable", "--format", search_format, "--exact", search_field, search_value
86
+ search_output = eix *(self.class.eix_search_arguments + ["--exact",search_field,search_value])
91
87
  end
92
88
 
93
89
  packages = []
@@ -121,4 +117,25 @@ Puppet::Type.type(:package).provide :portage, :parent => Puppet::Provider::Packa
121
117
  def latest
122
118
  self.query[:version_available]
123
119
  end
120
+
121
+ private
122
+ def self.eix_search_format
123
+ "'<category> <name> [<installedversions:LASTVERSION>] [<bestversion:LASTVERSION>] <homepage> <description>'"
124
+ end
125
+
126
+ def self.eix_result_format
127
+ /^(\S+)\s+(\S+)\s+\[(\S*)\]\s+\[(\S*)\]\s+(\S+)\s+(.*)$/
128
+ end
129
+
130
+ def self.eix_result_fields
131
+ [:category, :name, :ensure, :version_available, :vendor, :description]
132
+ end
133
+
134
+ def self.eix_version_format
135
+ "{last}<version>{}"
136
+ end
137
+
138
+ def self.eix_search_arguments
139
+ ["--nocolor", "--pure-packages", "--format",self.eix_search_format]
140
+ end
124
141
  end
@@ -49,11 +49,14 @@ Puppet::Type.type(:service).provide :launchd, :parent => :base do
49
49
  confine :operatingsystem => :darwin
50
50
 
51
51
  has_feature :enableable
52
+ has_feature :refreshable
52
53
  mk_resource_methods
53
54
 
54
55
  # These are the paths in OS X where a launchd service plist could
55
56
  # exist. This is a helper method, versus a constant, for easy testing
56
57
  # and mocking
58
+ #
59
+ # @api private
57
60
  def self.launchd_paths
58
61
  [
59
62
  "/Library/LaunchAgents",
@@ -62,14 +65,14 @@ Puppet::Type.type(:service).provide :launchd, :parent => :base do
62
65
  "/System/Library/LaunchDaemons"
63
66
  ]
64
67
  end
65
- private_class_method :launchd_paths
66
68
 
67
- # This is the path to the overrides plist file where service enabling
68
- # behavior is defined in 10.6 and greater
69
+ # Defines the path to the overrides plist file where service enabling
70
+ # behavior is defined in 10.6 and greater.
71
+ #
72
+ # @api private
69
73
  def self.launchd_overrides
70
74
  "/var/db/launchd.db/com.apple.launchd/overrides.plist"
71
75
  end
72
- private_class_method :launchd_overrides
73
76
 
74
77
  # Caching is enabled through the following three methods. Self.prefetch will
75
78
  # call self.instances to create an instance for each service. Self.flush will
@@ -108,7 +111,6 @@ Puppet::Type.type(:service).provide :launchd, :parent => :base do
108
111
  end
109
112
  array_of_files.compact
110
113
  end
111
- private_class_method :return_globbed_list_of_file_paths
112
114
 
113
115
  # Sets a class instance variable with a hash of all launchd plist files that
114
116
  # are found on the system. The key of the hash is the job id and the value
@@ -271,13 +273,20 @@ Puppet::Type.type(:service).provide :launchd, :parent => :base do
271
273
  self.enable if did_disable_job and resource[:enable] == :true
272
274
  end
273
275
 
276
+ def restart
277
+ Puppet.debug("A restart has been triggered for the #{resource[:name]} service")
278
+ Puppet.debug("Stopping the #{resource[:name]} service")
279
+ self.stop
280
+ Puppet.debug("Starting the #{resource[:name]} service")
281
+ self.start
282
+ end
274
283
 
275
284
  # launchd jobs are enabled by default. They are only disabled if the key
276
285
  # "Disabled" is set to true, but it can also be set to false to enable it.
277
- # Starting in 10.6, the Disabled key in the job plist is consulted, but only
278
- # if there is no entry in the global overrides plist.
279
- # We need to draw a distinction between undefined, true and false for both
280
- # locations where the Disabled flag can be defined.
286
+ # Starting in 10.6, the Disabled key in the job plist is consulted, but only
287
+ # if there is no entry in the global overrides plist. We need to draw a
288
+ # distinction between undefined, true and false for both locations where the
289
+ # Disabled flag can be defined.
281
290
  def enabled?
282
291
  job_plist_disabled = nil
283
292
  overrides_disabled = nil
@@ -303,11 +312,10 @@ Puppet::Type.type(:service).provide :launchd, :parent => :base do
303
312
  :false
304
313
  end
305
314
 
306
-
307
315
  # enable and disable are a bit hacky. We write out the plist with the appropriate value
308
316
  # rather than dealing with launchctl as it is unable to change the Disabled flag
309
317
  # without actually loading/unloading the job.
310
- # Starting in 10.6 we need to write out a disabled key to the global
318
+ # Starting in 10.6 we need to write out a disabled key to the global
311
319
  # overrides plist, in earlier versions this is stored in the job plist itself.
312
320
  def enable
313
321
  if has_macosx_plist_overrides?
@@ -323,7 +331,6 @@ Puppet::Type.type(:service).provide :launchd, :parent => :base do
323
331
  end
324
332
  end
325
333
 
326
-
327
334
  def disable
328
335
  if has_macosx_plist_overrides?
329
336
  overrides = self.class.read_plist(self.class.launchd_overrides)
@@ -335,6 +342,4 @@ Puppet::Type.type(:service).provide :launchd, :parent => :base do
335
342
  Plist::Emit.save_plist(job_plist, job_path)
336
343
  end
337
344
  end
338
-
339
-
340
345
  end
@@ -64,7 +64,7 @@ Puppet::Type.type(:service).provide :upstart, :parent => :debian do
64
64
  end
65
65
 
66
66
  def upstart_version
67
- @@upstart_version ||= initctl("--version").match(/initctl \(upstart ([^\)]*)\)/)[1]
67
+ @upstart_version ||= initctl("--version").match(/initctl \(upstart ([^\)]*)\)/)[1]
68
68
  end
69
69
 
70
70
  # Where is our override script?
@@ -6,7 +6,7 @@ Puppet::Type.type(:user).provide :hpuxuseradd, :parent => :useradd do
6
6
  defaultfor :operatingsystem => "hp-ux"
7
7
  confine :operatingsystem => "hp-ux"
8
8
 
9
- commands :modify => "/usr/sam/lbin/usermod.sam", :delete => "/usr/sam/lbin/userdel.sam", :add => "/usr/sbin/useradd"
9
+ commands :modify => "/usr/sam/lbin/usermod.sam", :delete => "/usr/sam/lbin/userdel.sam", :add => "/usr/sam/lbin/useradd.sam"
10
10
  options :comment, :method => :gecos
11
11
  options :groups, :flag => "-G"
12
12
  options :home, :flag => "-d", :method => :dir
@@ -19,7 +19,7 @@ Puppet::Type.type(:user).provide :hpuxuseradd, :parent => :useradd do
19
19
  value !~ /\s/
20
20
  end
21
21
 
22
- has_features :manages_homedir, :allows_duplicates
22
+ has_features :manages_homedir, :allows_duplicates, :manages_passwords
23
23
 
24
24
  def deletecmd
25
25
  super.insert(1,"-F")
@@ -28,4 +28,39 @@ Puppet::Type.type(:user).provide :hpuxuseradd, :parent => :useradd do
28
28
  def modifycmd(param,value)
29
29
  super.insert(1,"-F")
30
30
  end
31
+
32
+ def password
33
+ # Password management routine for trusted and non-trusted systems
34
+ #temp=""
35
+ while ent = Etc.getpwent() do
36
+ if ent.name == resource.name
37
+ temp=ent.name
38
+ break
39
+ end
40
+ end
41
+ Etc.endpwent()
42
+ if !temp
43
+ return nil
44
+ end
45
+
46
+ ent = Etc.getpwnam(resource.name)
47
+ if ent.passwd == "*"
48
+ # Either no password or trusted password, check trusted
49
+ file_name="/tcb/files/auth/#{resource.name.chars.first}/#{resource.name}"
50
+ if File.file?(file_name)
51
+ # Found the tcb user for the specific user, now get passwd
52
+ File.open(file_name).each do |line|
53
+ if ( line =~ /u_pwd/ )
54
+ temp_passwd=line.split(":")[1].split("=")[1]
55
+ ent.passwd = temp_passwd
56
+ return ent.passwd
57
+ end
58
+ end
59
+ else
60
+ debug "No trusted computing user file #{file_name} found."
61
+ end
62
+ else
63
+ return ent.passwd
64
+ end
65
+ end
31
66
  end
@@ -90,34 +90,6 @@ class Puppet::Resource
90
90
  end
91
91
  end
92
92
 
93
- def self.canonicalize_type(type)
94
- type, _ = get_type_and_title type, ""
95
- type
96
- end
97
-
98
- def self.get_type_and_title(type, title)
99
- type, title = extract_type_and_title(type, title)
100
- [munge_type_name(type), title]
101
- end
102
-
103
- def self.extract_type_and_title(argtype, argtitle)
104
- if (argtitle || argtype) =~ /^([^\[\]]+)\[(.+)\]$/m then [ $1, $2 ]
105
- elsif argtitle then [ argtype, argtitle ]
106
- elsif argtype.is_a?(Puppet::Type) then [ argtype.class.name, argtype.title ]
107
- elsif argtype.is_a?(Hash) then
108
- raise ArgumentError, "Puppet::Resource.new does not take a hash as the first argument. "+
109
- "Did you mean (#{(argtype[:type] || argtype["type"]).inspect}, #{(argtype[:title] || argtype["title"]).inspect }) ?"
110
- else raise ArgumentError, "No title provided and #{argtype.inspect} is not a valid resource reference"
111
- end
112
- end
113
-
114
- def self.munge_type_name(value)
115
- return :main if value == :main
116
- return "Class" if value == "" or value.nil? or value.to_s.downcase == "component"
117
-
118
- value.to_s.split("::").collect { |s| s.capitalize }.join("::")
119
- end
120
-
121
93
  def yaml_property_munge(x)
122
94
  case x
123
95
  when Hash
@@ -222,12 +194,13 @@ class Puppet::Resource
222
194
  send(attr.to_s + "=", value)
223
195
  end
224
196
 
225
- @type, @title = self.class.get_type_and_title(type, title)
197
+ @type, @title = extract_type_and_title(type, title)
226
198
 
199
+ @type = munge_type_name(@type)
227
200
 
228
201
  if self.class?
229
202
  @title = :main if @title == ""
230
- @title = self.class.munge_type_name(@title)
203
+ @title = munge_type_name(@title)
231
204
  end
232
205
 
233
206
  if params = attributes[:parameters]
@@ -366,14 +339,10 @@ class Puppet::Resource
366
339
  missing_arguments.collect do |param, default|
367
340
  external_value = lookup_external_default_for(param, scope)
368
341
 
369
- if external_value.nil?
370
- next if default.nil?
371
-
372
- value = if default.respond_to? :safeevaluate
373
- default.safeevaluate(scope)
374
- else
375
- default
376
- end
342
+ if external_value.nil? && default.nil?
343
+ next
344
+ elsif external_value.nil?
345
+ value = default.safeevaluate(scope)
377
346
  else
378
347
  value = external_value
379
348
  end
@@ -452,6 +421,24 @@ class Puppet::Resource
452
421
  end
453
422
  end
454
423
 
424
+ def extract_type_and_title(argtype, argtitle)
425
+ if (argtitle || argtype) =~ /^([^\[\]]+)\[(.+)\]$/m then [ $1, $2 ]
426
+ elsif argtitle then [ argtype, argtitle ]
427
+ elsif argtype.is_a?(Puppet::Type) then [ argtype.class.name, argtype.title ]
428
+ elsif argtype.is_a?(Hash) then
429
+ raise ArgumentError, "Puppet::Resource.new does not take a hash as the first argument. "+
430
+ "Did you mean (#{(argtype[:type] || argtype["type"]).inspect}, #{(argtype[:title] || argtype["title"]).inspect }) ?"
431
+ else raise ArgumentError, "No title provided and #{argtype.inspect} is not a valid resource reference"
432
+ end
433
+ end
434
+
435
+ def munge_type_name(value)
436
+ return :main if value == :main
437
+ return "Class" if value == "" or value.nil? or value.to_s.downcase == "component"
438
+
439
+ value.to_s.split("::").collect { |s| s.capitalize }.join("::")
440
+ end
441
+
455
442
  def parse_title
456
443
  h = {}
457
444
  type = resource_type
@@ -27,7 +27,7 @@ class Puppet::Resource::Type
27
27
  }
28
28
  RESOURCE_EXTERNAL_NAMES_TO_KINDS = RESOURCE_KINDS_TO_EXTERNAL_NAMES.invert
29
29
 
30
- attr_accessor :file, :line, :doc, :code, :parent, :resource_type_collection
30
+ attr_accessor :file, :line, :doc, :code, :ruby_code, :parent, :resource_type_collection
31
31
  attr_reader :namespace, :arguments, :behaves_like, :module_name
32
32
 
33
33
  # This should probably be renamed to 'kind' eventually, in accordance with the changes
@@ -135,11 +135,7 @@ class Puppet::Resource::Type
135
135
 
136
136
  code.safeevaluate(scope) if code
137
137
 
138
- evaluate_ruby_code(scope) unless ruby_code.empty?
139
- end
140
-
141
- def ruby_code
142
- @ruby_code ||= []
138
+ evaluate_ruby_code(resource, scope) if ruby_code
143
139
  end
144
140
 
145
141
  def initialize(type, name, options = {})
@@ -186,10 +182,6 @@ class Puppet::Resource::Type
186
182
  self.doc += other.doc
187
183
  end
188
184
 
189
- other.ruby_code.each do |c|
190
- self.ruby_code << c
191
- end
192
-
193
185
  # This might just be an empty, stub class.
194
186
  return unless other.code
195
187
 
@@ -268,10 +260,10 @@ class Puppet::Resource::Type
268
260
 
269
261
  # MQR TODO:
270
262
  #
271
- # The change(s) introduced by the fix for #4270 are mostly silly & should be
263
+ # The change(s) introduced by the fix for #4270 are mostly silly & should be
272
264
  # removed, though we didn't realize it at the time. If it can be established/
273
265
  # ensured that nodes never call parent_type and that resource_types are always
274
- # (as they should be) members of exactly one resource_type_collection the
266
+ # (as they should be) members of exactly one resource_type_collection the
275
267
  # following method could / should be replaced with:
276
268
  #
277
269
  # def parent_type
@@ -369,8 +361,8 @@ class Puppet::Resource::Type
369
361
  parent_scope(resource.scope, klass)
370
362
  end
371
363
 
372
- def evaluate_ruby_code(scope)
373
- ruby_code.each { |c| c.evaluate(scope, scope.known_resource_types) }
364
+ def evaluate_ruby_code(resource, scope)
365
+ Puppet::DSL::ResourceAPI.new(resource, scope, ruby_code).evaluate
374
366
  end
375
367
 
376
368
  # Split an fq name into a namespace and name
@@ -48,7 +48,7 @@ class Puppet::Settings
48
48
  else
49
49
  fqdn = hostname
50
50
  end
51
- fqdn.gsub(/\.$/, '')
51
+ fqdn.to_s.gsub(/\.$/, '')
52
52
  end
53
53
 
54
54
  def self.hostname_fact()