components/puppet/files/solaris/lib/puppet/type/dns.rb
author Drew Fisher <drew.fisher@oracle.com>
Fri, 31 Jan 2014 14:12:10 -0700
branchs11-update
changeset 2928 43b3da52b84a
parent 2771 8e4227dc2fc4
permissions -rw-r--r--
PSARC 2013/426 Puppet 3.4.1 17783988 Add zone.rb to Facter 17798202 Several providers return errors due to Ruby 1.9 changes. 17945378 backport of 17257851 to 11.2 was never actually done 18010466 Update Puppet to 3.4.1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2771
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
     1
#
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
     2
# CDDL HEADER START
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
     3
#
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
     4
# The contents of this file are subject to the terms of the
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
     5
# Common Development and Distribution License (the "License").
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
     6
# You may not use this file except in compliance with the License.
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
     7
#
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
     8
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
     9
# or http://www.opensolaris.org/os/licensing.
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    10
# See the License for the specific language governing permissions
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    11
# and limitations under the License.
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    12
#
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    13
# When distributing Covered Code, include this CDDL HEADER in each
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    14
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    15
# If applicable, add the following below this CDDL HEADER, with the
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    16
# fields enclosed by brackets "[]" replaced with your own identifying
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    17
# information: Portions Copyright [yyyy] [name of copyright owner]
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    18
#
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    19
# CDDL HEADER END
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    20
#
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    21
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    22
#
2928
43b3da52b84a PSARC 2013/426 Puppet 3.4.1
Drew Fisher <drew.fisher@oracle.com>
parents: 2771
diff changeset
    23
# Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
2771
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    24
#
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    25
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    26
require 'ipaddr'
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    27
require 'puppet/property/list'
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    28
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    29
# DNS options
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    30
simple_opts = ["debug", "rotate", "no-check-names", "inet6"]
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    31
arg_opts =  ["ndots", "timeout", "retrans", "attempts", "retry"]
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    32
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    33
Puppet::Type.newtype(:dns) do
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    34
    @doc = "Manage the configuration of the DNS client for Oracle Solaris"
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    35
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    36
    newparam(:name) do
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    37
        desc "The symbolic name for the DNS client settings to use.  This name
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    38
              is used for human reference only."
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    39
        isnamevar
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    40
    end
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    41
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    42
    newproperty(:nameserver, :parent => Puppet::Property::List) do
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    43
        desc "The IP address(es) the resolver is to query.  A maximum of
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    44
              3 IP addresses may be specified.  Specify multiple IP addresses
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    45
              as an array"
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    46
2928
43b3da52b84a PSARC 2013/426 Puppet 3.4.1
Drew Fisher <drew.fisher@oracle.com>
parents: 2771
diff changeset
    47
        # ensure should remains an array as long as there's more than 1 entry
2771
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    48
        def should
2928
43b3da52b84a PSARC 2013/426 Puppet 3.4.1
Drew Fisher <drew.fisher@oracle.com>
parents: 2771
diff changeset
    49
            if @should.length == 1
43b3da52b84a PSARC 2013/426 Puppet 3.4.1
Drew Fisher <drew.fisher@oracle.com>
parents: 2771
diff changeset
    50
                @should[0]
43b3da52b84a PSARC 2013/426 Puppet 3.4.1
Drew Fisher <drew.fisher@oracle.com>
parents: 2771
diff changeset
    51
            else
43b3da52b84a PSARC 2013/426 Puppet 3.4.1
Drew Fisher <drew.fisher@oracle.com>
parents: 2771
diff changeset
    52
                @should
43b3da52b84a PSARC 2013/426 Puppet 3.4.1
Drew Fisher <drew.fisher@oracle.com>
parents: 2771
diff changeset
    53
            end
2771
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    54
        end
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    55
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    56
        def insync?(is)
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    57
            is = [] if is == :absent or is.nil?
2928
43b3da52b84a PSARC 2013/426 Puppet 3.4.1
Drew Fisher <drew.fisher@oracle.com>
parents: 2771
diff changeset
    58
            if should.is_a? Array
43b3da52b84a PSARC 2013/426 Puppet 3.4.1
Drew Fisher <drew.fisher@oracle.com>
parents: 2771
diff changeset
    59
                is.sort == self.should.sort
43b3da52b84a PSARC 2013/426 Puppet 3.4.1
Drew Fisher <drew.fisher@oracle.com>
parents: 2771
diff changeset
    60
            end
2771
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    61
        end
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    62
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    63
        # svcprop returns multivalue entries delimited with a space
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    64
        def delimiter
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    65
            " "
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    66
        end
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    67
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    68
        validate do |value|
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    69
            begin
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    70
                ip = IPAddr.new(value)
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    71
            rescue ArgumentError
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    72
                raise Puppet::Error, "nameserver IP address:  #{value} is 
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    73
                    invalid"
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    74
            end
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    75
        end
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    76
    end
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    77
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    78
    newproperty(:domain) do
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    79
        desc "The local domain name"
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    80
    end
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    81
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    82
    newproperty(:search, :parent => Puppet::Property::List) do
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    83
        desc "The search list for host name lookup.  A maximum of 6 search
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    84
              entries may be specified.  Specify multiple search entries as an
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    85
              array."
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    86
2928
43b3da52b84a PSARC 2013/426 Puppet 3.4.1
Drew Fisher <drew.fisher@oracle.com>
parents: 2771
diff changeset
    87
        # ensure should remains an array as long as there's more than 1 entry
2771
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    88
        def should
2928
43b3da52b84a PSARC 2013/426 Puppet 3.4.1
Drew Fisher <drew.fisher@oracle.com>
parents: 2771
diff changeset
    89
            if @should.length == 1
43b3da52b84a PSARC 2013/426 Puppet 3.4.1
Drew Fisher <drew.fisher@oracle.com>
parents: 2771
diff changeset
    90
                @should[0]
43b3da52b84a PSARC 2013/426 Puppet 3.4.1
Drew Fisher <drew.fisher@oracle.com>
parents: 2771
diff changeset
    91
            else
43b3da52b84a PSARC 2013/426 Puppet 3.4.1
Drew Fisher <drew.fisher@oracle.com>
parents: 2771
diff changeset
    92
                @should
43b3da52b84a PSARC 2013/426 Puppet 3.4.1
Drew Fisher <drew.fisher@oracle.com>
parents: 2771
diff changeset
    93
            end
2771
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    94
        end
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    95
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    96
        def insync?(is)
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
    97
            is = [] if is == :absent or is.nil?
2928
43b3da52b84a PSARC 2013/426 Puppet 3.4.1
Drew Fisher <drew.fisher@oracle.com>
parents: 2771
diff changeset
    98
            if should.is_a? Array
43b3da52b84a PSARC 2013/426 Puppet 3.4.1
Drew Fisher <drew.fisher@oracle.com>
parents: 2771
diff changeset
    99
                is.sort == self.should.sort
43b3da52b84a PSARC 2013/426 Puppet 3.4.1
Drew Fisher <drew.fisher@oracle.com>
parents: 2771
diff changeset
   100
            end
2771
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   101
        end
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   102
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   103
        # svcprop returns multivalue entries delimited with a space
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   104
        def delimiter
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   105
            " "
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   106
        end
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   107
    end
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   108
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   109
    newproperty(:sortlist, :parent => Puppet::Property::List) do
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   110
        desc "Addresses returned by gethostbyname() to be sorted.  Entries must
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   111
              be specified in IP 'slash notation'.  A maximum of 10 sortlist
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   112
              entries may be specified.  Specify multiple entries as an array."
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   113
2928
43b3da52b84a PSARC 2013/426 Puppet 3.4.1
Drew Fisher <drew.fisher@oracle.com>
parents: 2771
diff changeset
   114
        # ensure should remains an array as long as there's more than 1 entry
2771
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   115
        def should
2928
43b3da52b84a PSARC 2013/426 Puppet 3.4.1
Drew Fisher <drew.fisher@oracle.com>
parents: 2771
diff changeset
   116
            if @should.length == 1
43b3da52b84a PSARC 2013/426 Puppet 3.4.1
Drew Fisher <drew.fisher@oracle.com>
parents: 2771
diff changeset
   117
                @should[0]
43b3da52b84a PSARC 2013/426 Puppet 3.4.1
Drew Fisher <drew.fisher@oracle.com>
parents: 2771
diff changeset
   118
            else
43b3da52b84a PSARC 2013/426 Puppet 3.4.1
Drew Fisher <drew.fisher@oracle.com>
parents: 2771
diff changeset
   119
                @should
43b3da52b84a PSARC 2013/426 Puppet 3.4.1
Drew Fisher <drew.fisher@oracle.com>
parents: 2771
diff changeset
   120
            end
2771
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   121
        end
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   122
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   123
        def insync?(is)
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   124
            is = [] if is == :absent or is.nil?
2928
43b3da52b84a PSARC 2013/426 Puppet 3.4.1
Drew Fisher <drew.fisher@oracle.com>
parents: 2771
diff changeset
   125
            if should.is_a? Array
43b3da52b84a PSARC 2013/426 Puppet 3.4.1
Drew Fisher <drew.fisher@oracle.com>
parents: 2771
diff changeset
   126
                is.sort == self.should.sort
43b3da52b84a PSARC 2013/426 Puppet 3.4.1
Drew Fisher <drew.fisher@oracle.com>
parents: 2771
diff changeset
   127
            end
2771
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   128
        end
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   129
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   130
        # svcprop returns multivalue entries delimited with a space
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   131
        def delimiter
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   132
            " "
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   133
        end
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   134
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   135
        validate do |value|
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   136
            begin
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   137
                ip = IPAddr.new(value)
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   138
            rescue ArgumentError
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   139
                raise Puppet::Error, "sortlist IP address: #{value} is invalid"
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   140
            end
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   141
        end
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   142
    end
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   143
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   144
    newproperty(:options, :parent => Puppet::Property::List) do
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   145
        desc "Set internal resolver variables.  Valid values are debug,
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   146
              ndots:n, timeout:n, retrans:n, attempts:n, retry:n, rotate,
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   147
              no-check-names, inet6.  For values with 'n', specify 'n' as an
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   148
              integer.  Specify multiple options as an array."
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   149
2928
43b3da52b84a PSARC 2013/426 Puppet 3.4.1
Drew Fisher <drew.fisher@oracle.com>
parents: 2771
diff changeset
   150
        # ensure should remains an array as long as there's more than 1 entry
2771
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   151
        def should
2928
43b3da52b84a PSARC 2013/426 Puppet 3.4.1
Drew Fisher <drew.fisher@oracle.com>
parents: 2771
diff changeset
   152
            if @should.length == 1
43b3da52b84a PSARC 2013/426 Puppet 3.4.1
Drew Fisher <drew.fisher@oracle.com>
parents: 2771
diff changeset
   153
                @should[0]
43b3da52b84a PSARC 2013/426 Puppet 3.4.1
Drew Fisher <drew.fisher@oracle.com>
parents: 2771
diff changeset
   154
            else
43b3da52b84a PSARC 2013/426 Puppet 3.4.1
Drew Fisher <drew.fisher@oracle.com>
parents: 2771
diff changeset
   155
                @should
43b3da52b84a PSARC 2013/426 Puppet 3.4.1
Drew Fisher <drew.fisher@oracle.com>
parents: 2771
diff changeset
   156
            end
2771
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   157
        end
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   158
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   159
        def insync?(is)
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   160
            is = [] if is == :absent or is.nil?
2928
43b3da52b84a PSARC 2013/426 Puppet 3.4.1
Drew Fisher <drew.fisher@oracle.com>
parents: 2771
diff changeset
   161
            if should.is_a? Array
43b3da52b84a PSARC 2013/426 Puppet 3.4.1
Drew Fisher <drew.fisher@oracle.com>
parents: 2771
diff changeset
   162
                is.sort == self.should.sort
43b3da52b84a PSARC 2013/426 Puppet 3.4.1
Drew Fisher <drew.fisher@oracle.com>
parents: 2771
diff changeset
   163
            end
2771
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   164
        end
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   165
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   166
        # svcprop returns multivalue entries delimited with a space
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   167
        def delimiter
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   168
            " "
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   169
        end
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   170
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   171
        validate do |value|
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   172
            data = value.split(":")
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   173
            if data.length == 1
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   174
                raise Puppet::Error, "option #{value} is invalid" \
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   175
                    if not simple_opts.include? data[0]
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   176
            elsif data.length == 2
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   177
                raise Puppet::Error, "option #{value} is invalid" \
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   178
                    if not arg_opts.include? data[0]
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   179
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   180
                # attempt to cast the integer specified
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   181
                begin
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   182
                    check = Integer(data[1])
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   183
                rescue ArgumentError
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   184
                    raise Puppet::Error, "option #{value} is invalid"
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   185
                end 
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   186
            else
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   187
                raise Puppet::Error, "option #{value} is invalid"
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   188
            end
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   189
        end
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   190
    end
8e4227dc2fc4 16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff changeset
   191
end