components/ruby/puppet/files/solaris/lib/puppet/type/pkg_publisher.rb
changeset 5438 c068f8c677e8
parent 5437 449f3459d285
child 5439 a006e5bb8577
equal deleted inserted replaced
5437:449f3459d285 5438:c068f8c677e8
     1 #
       
     2 # CDDL HEADER START
       
     3 #
       
     4 # The contents of this file are subject to the terms of the
       
     5 # Common Development and Distribution License (the "License").
       
     6 # You may not use this file except in compliance with the License.
       
     7 #
       
     8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
       
     9 # or http://www.opensolaris.org/os/licensing.
       
    10 # See the License for the specific language governing permissions
       
    11 # and limitations under the License.
       
    12 #
       
    13 # When distributing Covered Code, include this CDDL HEADER in each
       
    14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
       
    15 # If applicable, add the following below this CDDL HEADER, with the
       
    16 # fields enclosed by brackets "[]" replaced with your own identifying
       
    17 # information: Portions Copyright [yyyy] [name of copyright owner]
       
    18 #
       
    19 # CDDL HEADER END
       
    20 #
       
    21 
       
    22 #
       
    23 # Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
       
    24 #
       
    25 
       
    26 require 'puppet/property/list'
       
    27 Puppet::Type.newtype(:pkg_publisher) do
       
    28     @doc = "Manage Oracle Solaris package publishers"
       
    29 
       
    30     ensurable
       
    31 
       
    32     newparam(:name) do
       
    33         desc "The publisher name"
       
    34         isnamevar
       
    35     end
       
    36 
       
    37     newproperty(:origin, :parent => Puppet::Property::List) do
       
    38         desc "Which origin URI(s) to set.  For multiple origins, specify them
       
    39               as a list"
       
    40 
       
    41         # ensure should remains an array
       
    42         def should
       
    43             @should
       
    44         end
       
    45 
       
    46         def insync?(is)
       
    47             is = [] if is == :absent or is.nil?
       
    48             is.sort == self.should.sort
       
    49         end
       
    50 
       
    51         def retrieve
       
    52             provider.origin
       
    53         end
       
    54 
       
    55         # for origins with a file:// URI, strip any trailing / character
       
    56         munge do |value|
       
    57             if value.start_with? "file" and value.end_with? "/"
       
    58                 value = value.chomp("/")
       
    59             else
       
    60                 value
       
    61             end
       
    62         end
       
    63     end
       
    64     newproperty(:enable) do
       
    65         desc "Enable the publisher"
       
    66         newvalues(:true, :false)
       
    67     end
       
    68 
       
    69     newproperty(:sticky) do
       
    70         desc "Set the publisher 'sticky'"
       
    71         newvalues(:true, :false)
       
    72     end
       
    73 
       
    74     newproperty(:searchfirst) do
       
    75         desc "Set the publisher first in the search order"
       
    76         newvalues(:true)
       
    77     end
       
    78 
       
    79     newproperty(:searchafter) do
       
    80         desc "Set the publisher after the specified publisher in the search
       
    81               order"
       
    82     end
       
    83 
       
    84     newproperty(:searchbefore) do
       
    85         desc "Set the publisher before the specified publisher in the search
       
    86               order"
       
    87     end
       
    88 
       
    89     newproperty(:proxy) do
       
    90         desc "Use the specified web proxy URI to retrieve content for the
       
    91               specified origin or mirror"
       
    92     end
       
    93 
       
    94     newproperty(:sslkey) do
       
    95         desc "Specify the client SSL key"
       
    96     end
       
    97 
       
    98     newproperty(:sslcert) do
       
    99         desc "Specify the client SSL certificate"
       
   100     end
       
   101 
       
   102     newproperty(:mirror, :parent => Puppet::Property::List) do
       
   103         desc "Which mirror URI(s) to set.  For multiple mirrors, specify them
       
   104               as a list"
       
   105 	
       
   106         # ensure should remains an array
       
   107         def should
       
   108             @should
       
   109         end
       
   110 
       
   111         def insync?(is)
       
   112             is = [] if is == :absent or is.nil?
       
   113             is.sort == self.should.sort
       
   114         end
       
   115 
       
   116         def retrieve
       
   117             provider.mirror
       
   118         end
       
   119         
       
   120         munge do |value|
       
   121             if value.start_with? "file" and value.end_with? "/"
       
   122                 value = value.chomp("/")
       
   123             else
       
   124                 value
       
   125             end
       
   126         end
       
   127     end
       
   128 end