summaryrefslogtreecommitdiffstats
path: root/lib/puppet/type/port.rb
blob: 6b9ace239c7ce22d42cdd2f00a3f370b4783631a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#module Puppet
#    newtype(:port) do
#        @doc = "Installs and manages port entries.  For most systems, these
#            entries will just be in /etc/services, but some systems (notably OS X)
#            will have different solutions."
#
#        ensurable
#
#        newproperty(:protocols) do
#            desc "The protocols the port uses.  Valid values are *udp* and *tcp*.
#                Most services have both protocols, but not all.  If you want
#                both protocols, you must specify that; Puppet replaces the
#                current values, it does not merge with them.  If you specify
#                multiple protocols they must be as an array."
#
#            def is=(value)
#                case value
#                when String
#                    @is = value.split(/\s+/)
#                else
#                    @is = value
#                end
#            end
#
#            def is
#                @is
#            end
#
#            # We actually want to return the whole array here, not just the first
#            # value.
#            def should
#                if defined?(@should)
#                    if @should[0] == :absent
#                        return :absent
#                    else
#                        return @should
#                    end
#                else
#                    return nil
#                end
#            end
#
#            validate do |value|
#                valids = ["udp", "tcp", "ddp", :absent]
#                unless valids.include? value
#                    raise Puppet::Error,
#                        "Protocols can be either 'udp' or 'tcp', not %s" % value
#                end
#            end
#        end
#
#        newproperty(:number) do
#            desc "The port number."
#        end
#
#        newproperty(:description) do
#            desc "The port description."
#        end
#
#        newproperty(:port_aliases) do
#            desc 'Any aliases the port might have.  Multiple values must be
#                specified as an array.  Note that this property is not the same as
#                the "alias" metaparam; use this property to add aliases to a port
#                in the services file, and "alias" to aliases for use in your Puppet
#                scripts.'
#
#            # We actually want to return the whole array here, not just the first
#            # value.
#            def should
#                if defined?(@should)
#                    if @should[0] == :absent
#                        return :absent
#                    else
#                        return @should
#                    end
#                else
#                    return nil
#                end
#            end
#
#            validate do |value|
#                if value.is_a? String and value =~ /\s/
#                    raise Puppet::Error,
#                        "Aliases cannot have whitespace in them: %s" %
#                        value.inspect
#                end
#            end
#
#            munge do |value|
#                unless value == "absent" or value == :absent
#                    # Add the :alias metaparam in addition to the property
#                    @resource.newmetaparam(
#                        @resource.class.metaparamclass(:alias), value
#                    )
#                end
#                value
#            end
#        end
#
#        newproperty(:target) do
#            desc "The file in which to store service information.  Only used by
#                those providers that write to disk."
#
#            defaultto { if @resource.class.defaultprovider.ancestors.include?(Puppet::Provider::ParsedFile)
#                    @resource.class.defaultprovider.default_target
#                else
#                    nil
#                end
#            }
#        end
#
#        newparam(:name) do
#            desc "The port name."
#
#            isnamevar
#        end
#    end
#end