Skip to content

Commit

Permalink
Merge branch 'esalberg-check_link' into develop
Browse files Browse the repository at this point in the history
Conflicts:
	manifests/init.pp
	templates/ifcfg-eth.erb
  • Loading branch information
razorsedge committed Oct 7, 2015
2 parents b9034a7 + 5ebf7ca commit 2cd3ca2
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 75 deletions.
58 changes: 33 additions & 25 deletions manifests/if/dynamic.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@
#
# === Parameters:
#
# $ensure - required - up|down
# $macaddress - optional - defaults to macaddress_$title
# $bootproto - optional - defaults to "dhcp"
# $userctl - optional - defaults to false
# $mtu - optional
# $dhcp_hostname - optional
# $ethtool_opts - optional
# $ensure - required - up|down
# $macaddress - optional - defaults to macaddress_$title
# $bootproto - optional - defaults to "dhcp"
# $userctl - optional - defaults to false
# $mtu - optional
# $dhcp_hostname - optional
# $ethtool_opts - optional
# $peerdns - optional
# $linkdelay - optional
# $check_link_down - optional
#
# === Actions:
#
Expand Down Expand Up @@ -39,13 +42,15 @@
#
define network::if::dynamic (
$ensure,
$macaddress = undef,
$bootproto = 'dhcp',
$userctl = false,
$mtu = undef,
$dhcp_hostname = undef,
$ethtool_opts = undef,
$linkdelay = undef
$macaddress = undef,
$bootproto = 'dhcp',
$userctl = false,
$mtu = undef,
$dhcp_hostname = undef,
$ethtool_opts = undef,
$peerdns = false,
$linkdelay = undef,
$check_link_down = false
) {
# Validate our regular expressions
$states = [ '^up$', '^down$' ]
Expand All @@ -60,18 +65,21 @@
}
# Validate booleans
validate_bool($userctl)
validate_bool($peerdns)

network_if_base { $title:
ensure => $ensure,
ipaddress => '',
netmask => '',
gateway => '',
macaddress => $macaddy,
bootproto => $bootproto,
userctl => $userctl,
mtu => $mtu,
dhcp_hostname => $dhcp_hostname,
ethtool_opts => $ethtool_opts,
linkdelay => $linkdelay,
ensure => $ensure,
ipaddress => '',
netmask => '',
gateway => '',
macaddress => $macaddy,
bootproto => $bootproto,
userctl => $userctl,
mtu => $mtu,
dhcp_hostname => $dhcp_hostname,
ethtool_opts => $ethtool_opts,
peerdns => $peerdns,
linkdelay => $linkdelay,
check_link_down => $check_link_down,
}
} # define network::if::dynamic
81 changes: 43 additions & 38 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -49,24 +49,26 @@
#
# === Parameters:
#
# $ensure - required - up|down
# $ipaddress - required
# $netmask - required
# $macaddress - required
# $gateway - optional
# $bootproto - optional
# $userctl - optional - defaults to false
# $mtu - optional
# $dhcp_hostname - optional
# $ethtool_opts - optional
# $bonding_opts - optional
# $isalias - optional
# $peerdns - optional
# $dns1 - optional
# $dns2 - optional
# $domain - optional
# $bridge - optional
# $scope - optional
# $ensure - required - up|down
# $ipaddress - required
# $netmask - required
# $macaddress - required
# $gateway - optional
# $bootproto - optional
# $userctl - optional - defaults to false
# $mtu - optional
# $dhcp_hostname - optional
# $ethtool_opts - optional
# $bonding_opts - optional
# $isalias - optional
# $peerdns - optional
# $dns1 - optional
# $dns2 - optional
# $domain - optional
# $bridge - optional
# $scope - optional
# $linkdelay - optional
# $check_link_down - optional
#
# === Actions:
#
Expand Down Expand Up @@ -97,26 +99,28 @@
$ipaddress,
$netmask,
$macaddress,
$gateway = undef,
$ipv6address = undef,
$ipv6gateway = undef,
$ipv6init = false,
$ipv6autoconf = false,
$bootproto = 'none',
$userctl = false,
$mtu = undef,
$dhcp_hostname = undef,
$ethtool_opts = undef,
$bonding_opts = undef,
$isalias = false,
$peerdns = false,
$ipv6peerdns = false,
$dns1 = undef,
$dns2 = undef,
$domain = undef,
$bridge = undef,
$linkdelay = undef,
$scope = undef
$gateway = undef,
$ipv6address = undef,
$ipv6gateway = undef,
$ipv6init = false,
$ipv6autoconf = false,
$bootproto = 'none',
$userctl = false,
$mtu = undef,
$dhcp_hostname = undef,
$ethtool_opts = undef,
$bonding_opts = undef,
$isalias = false,
$peerdns = false,
$ipv6peerdns = false,
$dns1 = undef,
$dns2 = undef,
$domain = undef,
$bridge = undef,
$linkdelay = undef,
$scope = undef,
$linkdelay = undef,
$check_link_down = false
) {
# Validate our booleans
validate_bool($userctl)
Expand All @@ -125,6 +129,7 @@
validate_bool($ipv6init)
validate_bool($ipv6autoconf)
validate_bool($ipv6peerdns)
validate_bool($check_link_down)
# Validate our regular expressions
$states = [ '^up$', '^down$' ]
validate_re($ensure, $states, '$ensure must be either "up" or "down".')
Expand Down
18 changes: 10 additions & 8 deletions spec/defines/network_if_dynamic_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,16 @@
context 'optional parameters' do
let(:title) { 'eth99' }
let :params do {
:ensure => 'down',
:macaddress => 'ef:ef:ef:ef:ef:ef',
:bootproto => 'bootp',
:userctl => true,
:mtu => '1500',
:ethtool_opts => 'speed 100 duplex full autoneg off',
:dhcp_hostname => 'hostname',
:linkdelay => '5',
:ensure => 'down',
:macaddress => 'ef:ef:ef:ef:ef:ef',
:bootproto => 'bootp',
:userctl => true,
:mtu => '1500',
:dhcp_hostname => 'hostname',
:ethtool_opts => 'speed 100 duplex full autoneg off',
:peerdns => true,
:linkdelay => '5',
:check_link_down => true,
}
end
let :facts do {
Expand Down
12 changes: 8 additions & 4 deletions templates/ifcfg-eth.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
###
DEVICE=<%= @interface %>
BOOTPROTO=<%= @bootproto %>
<% if @macaddress %>HWADDR=<%= @macaddress %>
<% if @macaddress and @macaddress != '' %>HWADDR=<%= @macaddress %>
<% end -%>
ONBOOT=<%= @onboot %>
HOTPLUG=<%= @onboot %>
TYPE=Ethernet
<% if @ipaddress %>IPADDR=<%= @ipaddress %>
<% if @ipaddress and @ipaddress != '' %>IPADDR=<%= @ipaddress %>
<% end -%>
<% if @netmask %>NETMASK=<%= @netmask %>
<% if @netmask and @netmask != '' %>NETMASK=<%= @netmask %>
<% end -%>
<% if @gateway %>GATEWAY=<%= @gateway %>
<% if @gateway and @gateway != '' %>GATEWAY=<%= @gateway %>
<% end -%>
<% if @mtu %>MTU=<%= @mtu %>
<% end -%>
Expand Down Expand Up @@ -51,5 +51,9 @@ IPV6INIT=yes
<% if @linkdelay %>LINKDELAY=<%= @linkdelay %>
<% end -%>
<% if @scope %>SCOPE="<%= @scope %>"
<% if @check_link_down %>
check_link_down() {
return 1;
}
<% end -%>
NM_CONTROLLED=no

0 comments on commit 2cd3ca2

Please sign in to comment.