Fix the problem with regression after reboot
*Add new if_type vport *Test coverage Change-Id: I65cbbad1c35a34dac86b7331a04468fc0d060d83 Closes-bug: #1510072
This commit is contained in:
parent
b1f1a04b03
commit
f93b87f54d
|
@ -16,7 +16,7 @@ Puppet::Type.type(:l23_stored_config).provide(:ovs_ubuntu, :parent => Puppet::Pr
|
|||
rv = super
|
||||
rv.merge!({
|
||||
#todo(sv): :onboot => '', # should not be used (may be if no ipaddr)
|
||||
:ovs_type => 'ovs_type',
|
||||
:if_type => 'ovs_type',
|
||||
:bridge => 'ovs_bridge',
|
||||
:bridge_ports => 'ovs_ports',
|
||||
:bond_slaves => 'ovs_bonds',
|
||||
|
@ -85,25 +85,23 @@ Puppet::Type.type(:l23_stored_config).provide(:ovs_ubuntu, :parent => Puppet::Pr
|
|||
if provider.if_type.to_s == 'bridge'
|
||||
header << "auto #{provider.name}" if provider.onboot
|
||||
header << "allow-ovs #{provider.name}"
|
||||
props[:ovs_type] = 'OVSBridge'
|
||||
props[:bridge] = nil
|
||||
elsif provider.if_type.to_s == 'bond'
|
||||
# there are no 'auto bond-name' should be here. Because!
|
||||
header << "allow-#{bridge} #{provider.name}"
|
||||
props[:ovs_type] = 'OVSBond'
|
||||
props[:bridge] = bridge
|
||||
elsif provider.if_type.to_s == 'patch'
|
||||
header << "auto #{provider.name}" if provider.onboot
|
||||
header << "allow-#{bridge} #{provider.name}"
|
||||
props[:bridge] = bridge
|
||||
props[:ovs_type] = 'OVSPort'
|
||||
provider.mtu = nil
|
||||
else
|
||||
elsif provider.if_type.to_s == 'vport'
|
||||
header << "auto #{provider.name}" if provider.onboot
|
||||
header << "allow-#{bridge} #{provider.name}"
|
||||
props[:ovs_type] = 'OVSIntPort'
|
||||
props[:bridge] = bridge
|
||||
provider.jacks = nil
|
||||
else
|
||||
header << "auto #{provider.name}" if provider.onboot
|
||||
end
|
||||
# Add iface header
|
||||
header << "iface #{provider.name} inet #{provider.method}"
|
||||
|
@ -111,6 +109,20 @@ Puppet::Type.type(:l23_stored_config).provide(:ovs_ubuntu, :parent => Puppet::Pr
|
|||
return header, props
|
||||
end
|
||||
|
||||
def self.unmangle__if_type(provider, val)
|
||||
val = "OVS#{val.to_s.capitalize}".to_sym
|
||||
val = 'OVSPort' if val.to_s == 'OVSPatch'
|
||||
val = 'OVSIntPort' if val.to_s == 'OVSVport'
|
||||
val
|
||||
end
|
||||
|
||||
def self.mangle__if_type(val)
|
||||
val = val.gsub('OVS', '').downcase.to_sym
|
||||
val = :patch if val.to_s == 'port'
|
||||
val = :vport if val.to_s == 'intport'
|
||||
val
|
||||
end
|
||||
|
||||
def self.collected_properties
|
||||
rv = super
|
||||
rv.merge!({
|
||||
|
|
|
@ -402,6 +402,7 @@ class Puppet::Provider::L23_stored_config_ubuntu < Puppet::Provider::L23_stored_
|
|||
property_mappings.reject{|k,v| (properties_fake.include?(k) or v.empty?)}.keys.each do |type_name|
|
||||
next if props.has_key? type_name
|
||||
val = provider.send(type_name)
|
||||
val = false if ( val.is_a?(Array) and val.reject{ |x| x.to_s == 'absent' }.empty? )
|
||||
if val and val.to_s != 'absent'
|
||||
props[type_name] = val
|
||||
end
|
||||
|
|
|
@ -36,7 +36,7 @@ Puppet::Type.newtype(:l23_stored_config) do
|
|||
|
||||
newproperty(:if_type) do
|
||||
desc "Device type. Service property, shouldn't be setting by puppet"
|
||||
newvalues(:ethernet, :bridge, :bond, :patch)
|
||||
newvalues(:ethernet, :bridge, :bond, :patch, :vport)
|
||||
end
|
||||
|
||||
newproperty(:if_provider) do
|
||||
|
|
|
@ -100,7 +100,7 @@ define l23network::l2::patch (
|
|||
}
|
||||
L23_stored_config <| title == $patch_jacks_names[0] |> {
|
||||
ensure => $ensure,
|
||||
if_type => 'ethernet',
|
||||
if_type => 'vport',
|
||||
bridge => $act_bridges,
|
||||
jacks => $patch_jacks_names,
|
||||
mtu => $mtu,
|
||||
|
|
|
@ -106,7 +106,7 @@ end
|
|||
it do
|
||||
should contain_l23_stored_config('p_33470efd-0').with({
|
||||
'ensure' => 'present',
|
||||
'if_type' => 'ethernet',
|
||||
'if_type' => 'vport',
|
||||
'bridge' => ["br-ovs", "br1"],
|
||||
'jacks' => ['p_33470efd-0', 'p_33470efd-1'],
|
||||
'provider' => 'ovs_ubuntu'
|
||||
|
|
|
@ -6,11 +6,11 @@ describe Puppet::Type.type(:l23_stored_config).provider(:lnx_ubuntu) do
|
|||
let(:input_data) do
|
||||
{
|
||||
:eth1 => {
|
||||
:name => "eth1",
|
||||
:method => "static",
|
||||
:ipaddr => "169.254.0.1/24",
|
||||
:delay_while_up => "25",
|
||||
:provider => "lnx_ubuntu",
|
||||
:name => 'eth1',
|
||||
:method => 'static',
|
||||
:ipaddr => '169.254.0.1/24',
|
||||
:delay_while_up => '25',
|
||||
:provider => 'lnx_ubuntu',
|
||||
},
|
||||
}
|
||||
end
|
||||
|
@ -56,13 +56,6 @@ describe Puppet::Type.type(:l23_stored_config).provider(:lnx_ubuntu) do
|
|||
File.read(fixture_file(file))
|
||||
end
|
||||
|
||||
# context "the method property" do
|
||||
# context 'when dhcp' do
|
||||
# let(:data) { subject.class.parse_file('eth0', fixture_data('ifcfg-eth0'))[0] }
|
||||
# it { expect(data[:method]).to eq :dhcp }
|
||||
# end
|
||||
# end
|
||||
|
||||
context "just eth interface" do
|
||||
|
||||
context 'format file' do
|
||||
|
@ -85,6 +78,61 @@ describe Puppet::Type.type(:l23_stored_config).provider(:lnx_ubuntu) do
|
|||
end
|
||||
end
|
||||
|
||||
describe Puppet::Type.type(:l23_stored_config).provider(:ovs_ubuntu) do
|
||||
|
||||
let(:input_data) do
|
||||
{
|
||||
:eth1 => {
|
||||
:name => 'eth1',
|
||||
:method => 'static',
|
||||
:ipaddr => '169.254.0.1/24',
|
||||
:provider => 'ovs_ubuntu',
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
let(:resources) do
|
||||
resources = {}
|
||||
input_data.each do |name, res|
|
||||
resources.store name, Puppet::Type.type(:l23_stored_config).new(res)
|
||||
end
|
||||
resources
|
||||
end
|
||||
|
||||
let(:providers) do
|
||||
providers = {}
|
||||
resources.each do |name, resource|
|
||||
provider = resource.provider
|
||||
if ENV['SPEC_PUPPET_DEBUG']
|
||||
class << provider
|
||||
def debug(msg)
|
||||
puts msg
|
||||
end
|
||||
end
|
||||
end
|
||||
provider.create
|
||||
providers.store name, provider
|
||||
end
|
||||
providers
|
||||
end
|
||||
|
||||
before(:each) do
|
||||
puppet_debug_override()
|
||||
end
|
||||
|
||||
context "just eth interface with OVS provider" do
|
||||
|
||||
context 'format file with OVS provider' do
|
||||
subject { providers[:eth1] }
|
||||
let(:data) { subject.class.format_file('filepath', [subject]) }
|
||||
it { p data ; expect(data).to match(/auto\s+eth1/) }
|
||||
it { expect(data).to match(/iface\s+eth1\s+inet\s+static/) }
|
||||
it { expect(data).to match(/address\s+169\.254\.0\.1\/24/) }
|
||||
it { expect(data.split(/\n/).reject{|x| x=~/^\s*$/}.length). to eq(3) } # no more lines in the interface file
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
### multiple IP per interface
|
||||
describe Puppet::Type.type(:l23_stored_config).provider(:lnx_ubuntu) do
|
||||
|
||||
|
@ -162,4 +210,4 @@ describe Puppet::Type.type(:l23_stored_config).provider(:lnx_ubuntu) do
|
|||
it { expect(data[:ipaddr_aliases]).to eq ['192.168.1.1/24','192.168.2.2/25','192.168.3.3/26'] }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -19,7 +19,7 @@ resources_map = {
|
|||
},
|
||||
:'p_33470efd-0' => {
|
||||
:name => "p_33470efd-0",
|
||||
:if_type => "ethernet",
|
||||
:if_type => 'vport',
|
||||
:bridge => ["br-ovs", "br1"],
|
||||
:jacks => ['p_33470efd-0', 'p_33470efd-1'],
|
||||
:provider => "ovs_ubuntu",
|
||||
|
@ -133,7 +133,7 @@ describe Puppet::Type.type(:l23_stored_config).provider(:ovs_ubuntu) do
|
|||
it { expect(res[:onboot]).to eq true }
|
||||
it { expect(res[:name]).to eq 'p_33470efd-0' }
|
||||
it { expect(res[:bridge]).to eq "br-ovs" }
|
||||
it { expect(res[:if_type].to_s).to eq 'ethernet' }
|
||||
it { expect(res[:if_type].to_s).to eq 'vport' }
|
||||
it { expect(res[:if_provider].to_s).to eq 'ovs' }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,10 +9,11 @@ describe Puppet::Type.type(:l23_stored_config).provider(:ovs_ubuntu) do
|
|||
:name => 'ttt0',
|
||||
:ensure => 'present',
|
||||
:bridge => 'br9',
|
||||
:if_type => 'vport',
|
||||
:mtu => '6000',
|
||||
:onboot => true,
|
||||
:method => 'manual',
|
||||
:provider => "ovs_ubuntu",
|
||||
:provider => 'ovs_ubuntu',
|
||||
},
|
||||
}
|
||||
end
|
||||
|
@ -85,7 +86,7 @@ describe Puppet::Type.type(:l23_stored_config).provider(:ovs_ubuntu) do
|
|||
it { expect(res[:method]).to eq :manual }
|
||||
it { expect(res[:mtu]).to eq '6000' }
|
||||
it { expect(res[:bridge]).to eq 'br9' }
|
||||
it { expect(res[:if_type].to_s).to eq 'ethernet' }
|
||||
it { expect(res[:if_type].to_s).to eq 'vport' }
|
||||
it { expect(res[:if_provider].to_s).to eq 'ovs' }
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue