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, Oracle and/or its affiliates. All rights reserved. |
|
24 # |
|
25 |
|
26 require 'puppet/property/list' |
|
27 |
|
28 Puppet::Type.newtype(:ipmp_interface) do |
|
29 @doc = "Manage the configuration of Oracle Solaris IPMP interfaces" |
|
30 |
|
31 ensurable |
|
32 |
|
33 newparam(:name) do |
|
34 desc "The name of the IP interface" |
|
35 isnamevar |
|
36 end |
|
37 |
|
38 newparam(:temporary) do |
|
39 desc "Optional parameter that specifies that the IP interface is |
|
40 temporary. Temporary interfaces last until the next reboot." |
|
41 newvalues(:true, :false) |
|
42 end |
|
43 |
|
44 newproperty(:interfaces, :parent => Puppet::Property::List) do |
|
45 desc "An array of interface names to use for the IPMP interface" |
|
46 |
|
47 # ensure should remains an array |
|
48 def should |
|
49 @should |
|
50 end |
|
51 |
|
52 def insync?(is) |
|
53 is = [] if is == :absent or is.nil? |
|
54 is.sort == self.should.sort |
|
55 end |
|
56 |
|
57 # ipadm returns multivalue entries delimited with a space |
|
58 def delimiter |
|
59 " " |
|
60 end |
|
61 |
|
62 validate do |name| |
|
63 cmd = Array["/usr/sbin/ipadm", "show-if", "-p", "-o", "IFNAME"] |
|
64 output = Puppet::Util::Execution.execute(cmd).split("\n") |
|
65 if name.class == Array |
|
66 check = output - name |
|
67 raise Puppet::Error, "Invalid interface(s) specified: " |
|
68 "#{check.inspect}" if not check.empty? |
|
69 else |
|
70 raise Puppet::Error, "Invalid interface specified: #{name}" \ |
|
71 if not output.include?(name) |
|
72 end |
|
73 end |
|
74 end |
|
75 end |
|