Skip to content

Commit

Permalink
replace validate_integer with datatype
Browse files Browse the repository at this point in the history
  • Loading branch information
bastelfreak committed Mar 23, 2017
1 parent c52ccd1 commit ea2d58c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 22 deletions.
41 changes: 21 additions & 20 deletions manifests/bond/debian.pp
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,24 @@
# * Debian Network Bonding http://wiki.debian.org/Bonding
define network::bond::debian(
$slaves,
$ensure = present,
$ipaddress = undef,
$netmask = undef,
$method = undef,
$family = undef,
$onboot = undef,
$hotplug = undef,
$mtu = undef,
$options = undef,
$slave_options = undef,

$mode = undef,
$miimon = undef,
$downdelay = undef,
$updelay = undef,
$lacp_rate = undef,
$primary = undef,
$primary_reselect = undef,
$xmit_hash_policy = undef,
$ensure = present,
$ipaddress = undef,
$netmask = undef,
$method = undef,
$family = undef,
$onboot = undef,
$hotplug = undef,
Optional[Variant[Integer[42, 65536],String]] $mtu = undef,
$options = undef,
$slave_options = undef,
$mode = undef,
$miimon = undef,
$downdelay = undef,
$updelay = undef,
$lacp_rate = undef,
$primary = undef,
$primary_reselect = undef,
$xmit_hash_policy = undef,
) {

$raw = {
Expand All @@ -40,9 +39,11 @@
'bond-xmit-hash-policy' => $xmit_hash_policy,
}

if $mtu =~ String {
warning('$mtu should be an integer and will change in future releases')
}
if $mtu {
# https://bugs.launchpad.net/ubuntu/+source/ifupdown/+bug/1224007
validate_integer([$mtu], 65536, 42)
$raw_post_up = { 'post-up' => "ip link set dev ${name} mtu ${mtu}", }
} else {
$raw_post_up = {}
Expand Down
2 changes: 1 addition & 1 deletion spec/defines/bond/debian_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
'ipaddress' => '10.20.2.1',
'netmask' => '255.255.255.192',
'slaves' => %w(eth0 eth1 eth2),
'mtu' => '1550',
'mtu' => 1550,
'options' => { 'bond-future-option' => 'yes' },
'slave_options' => { 'slave-future-option' => 'no' },
'hotplug' => 'false',
Expand Down
2 changes: 1 addition & 1 deletion spec/defines/bond_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
'ipaddress' => '172.18.1.2',
'netmask' => '255.255.128.0',
'slaves' => %w(eth0 eth1),
'mtu' => '1550',
'mtu' => 1550,
'options' => { 'NM_CONTROLLED' => 'yes' },
'slave_options' => { 'NM_CONTROLLED' => 'no' },

Expand Down

0 comments on commit ea2d58c

Please sign in to comment.