8: def self.create_nagios_type(name)
9: name = name.to_sym
10: full_name = ("nagios_" + name.to_s).to_sym
11:
12: raise(Puppet::DevError, "No nagios type for %s" % name) unless nagtype = Nagios::Base.type(name)
13:
14: type = Puppet::Type.newtype(full_name) {}
15:
16: type.ensurable
17:
18: type.newparam(nagtype.namevar, :namevar => true) do
19: desc "The name parameter for Nagios type %s" % nagtype.name
20: end
21:
22:
23: nagtype.parameters.uniq.each do |param|
24: next if param == nagtype.namevar
25:
26:
27:
28: next if param.to_s =~ /^[0-9]/
29:
30: type.newproperty(param) do
31: desc "Nagios configuration file parameter."
32: end
33: end
34:
35: type.newproperty(:target) do
36: desc 'target'
37:
38: defaultto do
39: resource.class.defaultprovider.default_target
40: end
41: end
42:
43: target = "/etc/nagios/#{full_name.to_s}.cfg"
44: provider = type.provide(:naginator, :parent => Puppet::Provider::Naginator, :default_target => target) {}
45: provider.nagios_type
46:
47: type.desc "The Nagios type #{name.to_s}. This resource type is autogenerated using the
48: model developed in Naginator_, and all of the Nagios types are generated using the
49: same code and the same library.
50:
51: This type generates Nagios configuration statements in Nagios-parseable configuration
52: files. By default, the statements will be added to ``#{target}``, but
53: you can send them to a different file by setting their ``target`` attribute.
54:
55: You can purge Nagios resources using the ``resources`` type, but *only*
56: in the default file locations. This is an architectural limitation.
57:
58: .. _naginator: http://projects.reductivelabs.com/projects/naginator
59: "
60: end