Browse Source

Add fail_mode parameter to OVS Ports

According to info in https://bugs.launchpad.net/tripleo/+bug/1640812
when setting a OVS bridge with physical interface we need to
define fail_mode in OVS_EXTRA parameter of ifcfg to make
sure it's set at the desired mode after reboot.

This patch adds new parameter fail_mode to vs_port (as ifcfg is created
as part of vs_port, not vs_bridge) and defaults it to required value "standalone".

Similar patch was implemented to os-net-config in
e479535b50

Change-Id: I5f7448e3504c9190d7fe5f4a7958c604ef91a058
Closes-Bug: #1656795
(cherry picked from commit 026f64ade4)
changes/90/435290/1
Alfredo Moralejo 5 years ago
parent
commit
fc04875852
  1. 4
      lib/puppet/provider/vs_port/ovs_redhat.rb
  2. 11
      lib/puppet/type/vs_port.rb
  3. 17
      spec/unit/puppet/lib/type/vs_port_spec.rb

4
lib/puppet/provider/vs_port/ovs_redhat.rb

@ -44,7 +44,7 @@ Puppet::Type.type(:vs_port).provide(
if interface_physical?
template = DEFAULT
extras = nil
extras = { 'OVS_EXTRA' => "\"set bridge #{@resource[:bridge]} fail_mode=#{@resource[:fail_mode]}\"" }
if link?
extras = dynamic_default if dynamic?
@ -132,7 +132,7 @@ Puppet::Type.type(:vs_port).provide(
bridge_mac_address = File.read("/sys/class/net/#{@resource[:port]}/address").chomp
if bridge_mac_address != ''
list.merge!({ 'OVS_EXTRA' =>
"\"set bridge #{@resource[:bridge]} other-config:hwaddr=#{bridge_mac_address}\"" })
"\"set bridge #{@resource[:bridge]} other-config:hwaddr=#{bridge_mac_address} fail_mode=#{@resource[:fail_mode]}\"" })
end
list
end

11
lib/puppet/type/vs_port.rb

@ -152,6 +152,17 @@ Puppet::Type.newtype(:vs_port) do
end
end
newparam(:fail_mode) do
desc "Set fail mode for this port.
Possible values are 'standalone' or 'secure'.
By default standalone is used."
defaultto "standalone"
newvalues(:"standalone", :"secure")
end
autorequire(:vs_bridge) do
self[:bridge] if self[:bridge]
end

17
spec/unit/puppet/lib/type/vs_port_spec.rb

@ -0,0 +1,17 @@
require 'spec_helper'
describe Puppet::Type.type(:vs_port) do
it "should support only secure and standalone as a value for fail_mode" do
expect do
described_class.new(:name => 'foo', :ensure => :present, :fail_mode => 'secure')
end.to_not raise_error
expect do
described_class.new(:name => 'foo', :ensure => :present, :fail_mode => 'standalone')
end.to_not raise_error
expect do
described_class.new(:name => 'foo', :ensure => :present, :fail_mode => 'nomode')
end.to raise_error(Puppet::ResourceError, /Invalid value/)
end
end
Loading…
Cancel
Save