Skip to content

Commit

Permalink
Merge pull request #3 from odivlad/fix-validator
Browse files Browse the repository at this point in the history
Fix validators for allow_untagged, arp_nd_suppress, learning
  • Loading branch information
odivlad authored Sep 3, 2020
2 parents ccd1beb + ebd39da commit d22b86f
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 30 deletions.
27 changes: 13 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@ Feel free to send patches to http://github.com/c2devel/cumulus-cl-interfaces-pup

#### Table of Contents

- [cumulus_interface](#cumulusinterface)
- [cumulus_interface](#cumulus_interface)
- [Table of Contents](#table-of-contents)
- [Overview](#overview)
- [Module Description](#module-description)
- [cumulus_interface](#cumulusinterface-1)
- [cumulus_bond](#cumulusbond)
- [cumulus_bridge](#cumulusbridge)
- [cumulus_interface](#cumulus_interface-1)
- [cumulus_bond](#cumulus_bond)
- [cumulus_bridge](#cumulus_bridge)
- [Setup](#setup)
- [What cumulus_interface affects](#what-cumulusinterface-affects)
- [What cumulus_interface affects](#what-cumulus_interface-affects)
- [Usage](#usage)
- [Reference](#reference)
- [Types](#types)
- [`cumulus_interface`](#cumulusinterface-2)
- [`cumulus_interface`](#cumulus_interface-2)
- [Parameters](#parameters)
- [`cumulus_bond`](#cumulusbond-1)
- [`cumulus_bond`](#cumulus_bond-1)
- [Parameters](#parameters-1)
- [`cumulus_bridge`](#cumulusbridge-1)
- [`cumulus_bridge`](#cumulus_bridge-1)
- [Parameters:](#parameters-2)
- [`cumulus_vxlan`](#cumulusvxlan)
- [`cumulus_vxlan`](#cumulus_vxlan)
- [Parameters:](#parameters-3)
- [Limitations](#limitations)
- [Development](#development)
Expand Down Expand Up @@ -179,7 +179,7 @@ cumulus_bridge { 'bridge':
* `virtual_ip` - VRR virtual IP address.
* `virtual_mac` - VRR virtual MAC address.
* `access` - For bridging, a type of port that is non-trunking. For dot1x an IP source address or network that will be serviced (an integer from 1 to 4094).
* `allow_untagged` - A bridge port interface may allow untagged packets. Valid value: `no`.
* `allow_untagged` - A bridge port interface may allow untagged packets. Valid value: `false`.
* `vids` - Array of VLANs to be configured for a VLAN-aware trunk interface.
* `pvid` - Native VLAN for a VLAN-aware trunk interface.
* `location` - Location of the configuration snippets directory. Default is `/etc/network/interfaces.d/`.
Expand Down Expand Up @@ -219,7 +219,7 @@ The following CLAG-related attributes are also available. If CLAG is enabled, yo
* `virtual_ip` - VRR virtual IP address.
* `virtual_mac` - VRR virtual MAC address.
* `access` - For bridging, a type of port that is non-trunking. For dot1x an IP source address or network that will be serviced (an integer from 1 to 4094).
* `allow_untagged` - A bridge port interface may allow untagged packets. Valid value: `no`.
* `allow_untagged` - A bridge port interface may allow untagged packets. Valid value: `false`.
* `vids` - Array of VLANs to be configured for a VLAN-aware trunk interface.
* `pvid` - Native VLAN for a VLAN-aware trunk interface.
* `location` - Location of the configuration snippets directory. Default is `/etc/network/interfaces.d/`.
Expand Down Expand Up @@ -266,9 +266,8 @@ The following CLAG-related attributes are also available. If CLAG is enabled, yo
* `mstpctl_bpduguard` - Enable BPDU guard on a VLAN-aware trunk.
* `location` - Location of the configuration snippets directory. Default is `/etc/network/interfaces.d/`.
* `access` - For bridging, a type of port that is non-trunking. For dot1x an IP source address or network that will be serviced (an integer from 1 to 4094).
* `allow_untagged` - A bridge port interface may allow untagged packets. Valid value: `no`.
* `arp_nd_suppress` - ARP ND suppression. Valid values: `'on'` or `'off'`.
* `learning` - The bridge port learning flag. Valid values: `'on'` or `'off'`.
* `arp_nd_suppress` - ARP ND suppression. Valid value: `'on'`.
* `learning` - The bridge port learning flag. Valid value: `'off'`.
* `mstpctl_portbpdufilter` - BPDU filter on a port. Valid values: `true` or `false`.
* `mstpctl_bpduguard` - Bridge Protocol Data Unit guard. Valid values: `true` or `false`.
* `vxlan_id` - VXLAN Identifier (An integer from 1 to 16777214)
Expand Down
14 changes: 4 additions & 10 deletions lib/cumulus/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,11 @@ def munge_array(value)
return_value
end

def validate_on_off(value)
ok_values = ['on', 'off']
if not ok_values.include? value
raise("value must be one of #{ok_values}")
end
end

def validate_no(value)
if value != 'no'
raise("value must be 'no'")
def validate_value(value, allowed_value)
if value != allowed_value
raise("value must be `#{allowed_value}`")
end
value
end
end
end
2 changes: 1 addition & 1 deletion lib/puppet/type/cumulus_bond.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def retrieve
newparam(:allow_untagged) do
desc 'A bridge port interface may allow untagged packets'
munge do |value|
@resource.validate_no(value)
@resource.validate_value(value, false)
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/type/cumulus_interface.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def retrieve
newparam(:allow_untagged) do
desc 'A bridge port interface may allow untagged packets'
munge do |value|
@resource.validate_no(value)
@resource.validate_value(value, false)
end
end

Expand Down
6 changes: 3 additions & 3 deletions lib/puppet/type/cumulus_vxlan.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,17 @@ def retrieve
end
end

newparam(:arp_nd_suppress,) do
newparam(:arp_nd_suppress) do
desc 'ARP ND suppression'
munge do |value|
@resource.validate_on_off(value)
@resource.validate_value(value, 'on')
end
end

newparam(:learning) do
desc 'The bridge port learning flag'
munge do |value|
@resource.validate_on_off(value)
@resource.validate_value(value, 'off')
end
end

Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "c2devel-cumulus_interfaces",
"version": "1.2.6",
"version": "1.2.7",
"author": "Cumulus Networks",
"summary": "Configures Cumulus Linux interfaces",
"license": "GPLv2",
Expand Down

0 comments on commit d22b86f

Please sign in to comment.