components/ruby/puppet/files/solaris/lib/puppet/type/evs_properties.rb
changeset 4794 be62c55aa235
equal deleted inserted replaced
4793:24053a14d972 4794:be62c55aa235
       
     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_properties) do
       
    27     @doc = "Manage global properties of EVS(Elastic Virtual Switch) for both 
       
    28             client and controller. There are two instances associated with 
       
    29             contoller and client properties respectively"
       
    30     
       
    31     ## This is a property setter, thus not ensurable ##
       
    32     newparam(:name) do
       
    33         desc "Type of properties\n"\
       
    34             "Names are preset to 'controller_property' and 'client_property'"
       
    35         # Validate the name:
       
    36         # Names are preset to "controller_property" and "client_property"
       
    37         validate do |value|
       
    38             if value != "controller_property" && value != "client_property"
       
    39                 raise Puppet::Error, "Invalid property type name\n" \
       
    40                     "Name must be either 'controller_property' or " \
       
    41                     "'client_property'"
       
    42             end
       
    43         end
       
    44     end
       
    45     
       
    46     ## Properties associated with "controller_property" ##
       
    47     ## All the properties are read/write
       
    48     newproperty(:l2_type) do
       
    49         desc "Define how an EVS will be implemented across machines "\
       
    50             "(controller_property)"
       
    51         newvalues("vlan", "vxlan", "flat", "")
       
    52     end
       
    53     
       
    54     newproperty(:uplink_port) do
       
    55         desc "Specifies the datalink to be used for VLANs or VXLANs "\
       
    56             "(controller_property)\n"\
       
    57             "uplink_port value must be in the format of either\n"\
       
    58             "uplink_port=<uplink>  or \n"\
       
    59             "uplink_port='<uplink>;[<vlan-range>];[<vxlan-range>];"\
       
    60             "[<host>];[<flat>]'"
       
    61         # Use munge to support single value input
       
    62         munge do |value|
       
    63             uplink_list = value.strip().split(";", -1)
       
    64             if uplink_list.length == 0
       
    65                 value = ";;;;"
       
    66             elsif uplink_list.length == 1
       
    67                 value = "#{value};;;;"
       
    68             elsif uplink_list.length == 5
       
    69                 value
       
    70             else
       
    71                 raise Puppet::Error, "Invalid uplink_port format: \n" \
       
    72                     "The format must be uplink_port=<uplink> or " \
       
    73                     "uplink_port='<uplink>;[<vlan-range>];[<vxlan-range>];" \
       
    74                     "[<host>];[<flat>]'"
       
    75             end
       
    76         end
       
    77     end
       
    78     
       
    79     newproperty(:uri_template) do
       
    80         desc "URI for per-EVS Node RAD Connection (controller_property)\n"\
       
    81             "The syntax of the uri_template value will be of the form:\n"\
       
    82             "uri_template='ssh://[username@][;<host>]' or \n"\
       
    83             "uri_template='unix://[username@][;<host>]'"
       
    84         # Use munge to support single value input
       
    85         munge do |value|
       
    86             uri_list = value.strip().split(";", -1)
       
    87             if uri_list.length == 0
       
    88                 value = ";"
       
    89             elsif uri_list.length == 1
       
    90                 value = "#{value};"
       
    91             elsif uri_list.length == 2
       
    92                 value
       
    93             else
       
    94                 raise Puppet::Error, "Invalid uri_template format: \n"\
       
    95                     "The format of the uri_template value must be\n"\
       
    96                     "uri_template='ssh://[username@][;<host>]' or \n"\
       
    97                     "uri_template='unix://[username@][;<host>]'"
       
    98             end
       
    99         end
       
   100     end
       
   101     
       
   102 
       
   103     newproperty(:vlan_range) do
       
   104         desc "List of VLAN ID ranges that will be used for creating EVS "\
       
   105             "(controller_property)\n"\
       
   106             "The maximum valid range is 1-4094"
       
   107     end
       
   108 
       
   109     newproperty(:vxlan_addr) do
       
   110         desc "IP address on top of which VXLAN datalink should be created "\
       
   111             "(controller_property)\n"\
       
   112             "The syntax of the vxlan_addr value will be of the form:\n"\
       
   113             "vxlan_addr=<vxlan_IP_addr> or"\
       
   114             "vxlan_addr='<vxlan_IP_addr>;[<vxlan-range>];[<host>]'"
       
   115         # Use munge to support single value input
       
   116         munge do |value|
       
   117             vxlan_list = value.strip().split(";", -1)
       
   118             if vxlan_list.length == 0
       
   119                 value = ";;"
       
   120             elsif vxlan_list.length == 1
       
   121                 value = "#{value};;"
       
   122             elsif vxlan_list.length == 3
       
   123                 value
       
   124             else
       
   125                 raise Puppet::Error, "Invalid vxlan_addr format: \n" \
       
   126                     "The format of the vxlan_addr value must be\n"\
       
   127                     "vxlan_addr=<vxlan_IP_addr> or"\
       
   128                     "vxlan_addr='<vxlan_IP_addr>;[<vxlan-range>];[<host>]'"
       
   129             end
       
   130         end
       
   131     end
       
   132 
       
   133     newproperty(:vxlan_ipvers) do
       
   134         desc "IP version of the address for VXLAN datalinks "\
       
   135             "(controller_property)"
       
   136     end
       
   137 
       
   138     newproperty(:vxlan_mgroup) do
       
   139         desc "Multicast address that needs to be used while creating VXLAN" \
       
   140             " links (controller_property)"
       
   141     end
       
   142 
       
   143     newproperty(:vxlan_range) do
       
   144         desc "List of VXLAN ID ranges that will be used for creating EVS "\
       
   145             "(controller_property)\n"\
       
   146             "The maximum valid range is 0-16777215"
       
   147     end
       
   148     
       
   149     
       
   150     ### The read/write property associated with "client_property" ###
       
   151     newproperty(:controller) do
       
   152         desc "SSH address of EVS controller server (client_property)"
       
   153     end
       
   154 end