components/ruby/puppet/files/solaris/lib/puppet/type/evs.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) 2015, Oracle and/or its affiliates. All rights reserved.
       
    24 #
       
    25 
       
    26 Puppet::Type.newtype(:evs) do
       
    27     @doc = "Manage the configuration of Oracle Solaris Elastic Virtual Switch
       
    28            (EVS)"
       
    29 
       
    30     ensurable
       
    31     newparam(:name) do
       
    32         desc "The full name for EVS (including the tenant name)"
       
    33         validate do |value|
       
    34             if value.split("/").length != 2
       
    35                 raise Puppet::Error, "Invalid EVS name\n"\
       
    36                     "Name convention must be <tenant>/<evs>"
       
    37             end
       
    38         end
       
    39     end
       
    40 
       
    41     ## read/write properties (always updatable) ##
       
    42     newproperty(:maxbw) do
       
    43         desc "The full duplex bandwidth for the virtual port"
       
    44     end
       
    45 
       
    46     newproperty(:priority) do
       
    47         desc "The relative priority for the virtual port"
       
    48         newvalues("high", "medium", "low", "")
       
    49     end
       
    50 
       
    51     newproperty(:protection) do
       
    52         desc "Enables one or more types of link protection"
       
    53         # verify protection value: comma(,) separatable
       
    54         validate do |value| 
       
    55             value.split(",").collect do |each_val|
       
    56                 if not ["mac-nospoof", "restricted", "ip-nospoof", 
       
    57                     "dhcp-nospoof", "none", ""].include? each_val
       
    58                     raise Puppet::Error, "Invalid value \"#{each_val}\". "\
       
    59                         "Valid values are mac-nospoof, restricted, "\
       
    60                         "ip-nospoof, dhcp-nospoof, none."
       
    61                 end
       
    62             end
       
    63         end
       
    64     end
       
    65 
       
    66     ## read-only properties (settable upon creation) ##
       
    67     newproperty(:l2_type) do
       
    68         desc "Define how an EVS will be implemented across machines"
       
    69         newvalues("vlan", "vxlan", "flat", "")
       
    70     end
       
    71     
       
    72     newproperty(:vlanid) do
       
    73         desc "VXLAN segment ID used to implement the EVS"
       
    74     end
       
    75     
       
    76     newproperty(:vni) do
       
    77         desc "VLAN ID used to implement the EVS"
       
    78     end
       
    79 
       
    80     newproperty(:uuid) do
       
    81         desc "UUID of the EVS instance"
       
    82     end
       
    83 end