components/puppet/files/solaris/lib/puppet/type/dns.rb
branchs11-update
changeset 2928 43b3da52b84a
parent 2771 8e4227dc2fc4
equal deleted inserted replaced
2925:d64f6e80d9b1 2928:43b3da52b84a
    18 #
    18 #
    19 # CDDL HEADER END
    19 # CDDL HEADER END
    20 #
    20 #
    21 
    21 
    22 #
    22 #
    23 # Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
    23 # Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
    24 #
    24 #
    25 
    25 
    26 require 'ipaddr'
    26 require 'ipaddr'
    27 require 'puppet/property/list'
    27 require 'puppet/property/list'
    28 
    28 
    42     newproperty(:nameserver, :parent => Puppet::Property::List) do
    42     newproperty(:nameserver, :parent => Puppet::Property::List) do
    43         desc "The IP address(es) the resolver is to query.  A maximum of
    43         desc "The IP address(es) the resolver is to query.  A maximum of
    44               3 IP addresses may be specified.  Specify multiple IP addresses
    44               3 IP addresses may be specified.  Specify multiple IP addresses
    45               as an array"
    45               as an array"
    46 
    46 
    47         # ensure should remains an array
    47         # ensure should remains an array as long as there's more than 1 entry
    48         def should
    48         def should
    49             @should
    49             if @should.length == 1
       
    50                 @should[0]
       
    51             else
       
    52                 @should
       
    53             end
    50         end
    54         end
    51 
    55 
    52         def insync?(is)
    56         def insync?(is)
    53             is = [] if is == :absent or is.nil?
    57             is = [] if is == :absent or is.nil?
    54             is.sort == self.should.sort
    58             if should.is_a? Array
       
    59                 is.sort == self.should.sort
       
    60             end
    55         end
    61         end
    56 
    62 
    57         # svcprop returns multivalue entries delimited with a space
    63         # svcprop returns multivalue entries delimited with a space
    58         def delimiter
    64         def delimiter
    59             " "
    65             " "
    76     newproperty(:search, :parent => Puppet::Property::List) do
    82     newproperty(:search, :parent => Puppet::Property::List) do
    77         desc "The search list for host name lookup.  A maximum of 6 search
    83         desc "The search list for host name lookup.  A maximum of 6 search
    78               entries may be specified.  Specify multiple search entries as an
    84               entries may be specified.  Specify multiple search entries as an
    79               array."
    85               array."
    80 
    86 
    81         # ensure should remains an array
    87         # ensure should remains an array as long as there's more than 1 entry
    82         def should
    88         def should
    83             @should
    89             if @should.length == 1
       
    90                 @should[0]
       
    91             else
       
    92                 @should
       
    93             end
    84         end
    94         end
    85 
    95 
    86         def insync?(is)
    96         def insync?(is)
    87             is = [] if is == :absent or is.nil?
    97             is = [] if is == :absent or is.nil?
    88             is.sort == self.should.sort
    98             if should.is_a? Array
       
    99                 is.sort == self.should.sort
       
   100             end
    89         end
   101         end
    90 
   102 
    91         # svcprop returns multivalue entries delimited with a space
   103         # svcprop returns multivalue entries delimited with a space
    92         def delimiter
   104         def delimiter
    93             " "
   105             " "
    97     newproperty(:sortlist, :parent => Puppet::Property::List) do
   109     newproperty(:sortlist, :parent => Puppet::Property::List) do
    98         desc "Addresses returned by gethostbyname() to be sorted.  Entries must
   110         desc "Addresses returned by gethostbyname() to be sorted.  Entries must
    99               be specified in IP 'slash notation'.  A maximum of 10 sortlist
   111               be specified in IP 'slash notation'.  A maximum of 10 sortlist
   100               entries may be specified.  Specify multiple entries as an array."
   112               entries may be specified.  Specify multiple entries as an array."
   101 
   113 
   102         # ensure should remains an array
   114         # ensure should remains an array as long as there's more than 1 entry
   103         def should
   115         def should
   104             @should
   116             if @should.length == 1
       
   117                 @should[0]
       
   118             else
       
   119                 @should
       
   120             end
   105         end
   121         end
   106 
   122 
   107         def insync?(is)
   123         def insync?(is)
   108             is = [] if is == :absent or is.nil?
   124             is = [] if is == :absent or is.nil?
   109             is.sort == self.should.sort
   125             if should.is_a? Array
       
   126                 is.sort == self.should.sort
       
   127             end
   110         end
   128         end
   111 
   129 
   112         # svcprop returns multivalue entries delimited with a space
   130         # svcprop returns multivalue entries delimited with a space
   113         def delimiter
   131         def delimiter
   114             " "
   132             " "
   127         desc "Set internal resolver variables.  Valid values are debug,
   145         desc "Set internal resolver variables.  Valid values are debug,
   128               ndots:n, timeout:n, retrans:n, attempts:n, retry:n, rotate,
   146               ndots:n, timeout:n, retrans:n, attempts:n, retry:n, rotate,
   129               no-check-names, inet6.  For values with 'n', specify 'n' as an
   147               no-check-names, inet6.  For values with 'n', specify 'n' as an
   130               integer.  Specify multiple options as an array."
   148               integer.  Specify multiple options as an array."
   131 
   149 
   132         # ensure should remains an array
   150         # ensure should remains an array as long as there's more than 1 entry
   133         def should
   151         def should
   134             @should
   152             if @should.length == 1
       
   153                 @should[0]
       
   154             else
       
   155                 @should
       
   156             end
   135         end
   157         end
   136 
   158 
   137         def insync?(is)
   159         def insync?(is)
   138             is = [] if is == :absent or is.nil?
   160             is = [] if is == :absent or is.nil?
   139             is.sort == self.should.sort
   161             if should.is_a? Array
       
   162                 is.sort == self.should.sort
       
   163             end
   140         end
   164         end
   141 
   165 
   142         # svcprop returns multivalue entries delimited with a space
   166         # svcprop returns multivalue entries delimited with a space
   143         def delimiter
   167         def delimiter
   144             " "
   168             " "
   148             data = value.split(":")
   172             data = value.split(":")
   149             if data.length == 1
   173             if data.length == 1
   150                 raise Puppet::Error, "option #{value} is invalid" \
   174                 raise Puppet::Error, "option #{value} is invalid" \
   151                     if not simple_opts.include? data[0]
   175                     if not simple_opts.include? data[0]
   152             elsif data.length == 2
   176             elsif data.length == 2
   153                 # XXX
       
   154                 raise Puppet::Error, "svccfg is bugged with prop:N options"
       
   155 
       
   156                 raise Puppet::Error, "option #{value} is invalid" \
   177                 raise Puppet::Error, "option #{value} is invalid" \
   157                     if not arg_opts.include? data[0]
   178                     if not arg_opts.include? data[0]
   158 
   179 
   159                 # attempt to cast the integer specified
   180                 # attempt to cast the integer specified
   160                 begin
   181                 begin