From 9c991e1188a494809d7ac1b7f8d7a009f0490910 Mon Sep 17 00:00:00 2001 From: Rob Sweet Date: Fri, 8 May 2015 11:57:27 -0400 Subject: [PATCH] Fix kernel module filename for OVS versions Better kernel module filename handling to support OVS v2; New fact for OVS version Closes-Bug: 1453213 Change-Id: I5bcfd00366bea5c46bb3a62cacd9e5b55d8c2ffe --- lib/facter/ovs.rb | 7 +++++++ manifests/ovs.pp | 10 +++++++++- spec/classes/vswitch_ovs_spec.rb | 14 ++++++++++++-- 3 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 lib/facter/ovs.rb diff --git a/lib/facter/ovs.rb b/lib/facter/ovs.rb new file mode 100644 index 00000000..3a6100cd --- /dev/null +++ b/lib/facter/ovs.rb @@ -0,0 +1,7 @@ +Facter.add("ovs_version") do + confine :kernel => "Linux" + + setcode do + Facter::Core::Execution.exec('/usr/bin/ovs-vsctl --version').gsub(/.*ovs-vsctl\s+\(Open\s+vSwitch\)\s+(\d+\.\d+\.\d+).*/, '\1') + end +end diff --git a/manifests/ovs.pp b/manifests/ovs.pp index c2c864a0..9735e4af 100644 --- a/manifests/ovs.pp +++ b/manifests/ovs.pp @@ -61,8 +61,16 @@ class vswitch::ovs( name => $::vswitch::params::ovs_service_name, hasstatus => false, # the supplied command returns true even if it's not running # Not perfect - should spot if either service is not running - but it'll do - status => $ovs_status + status => $ovs_status, } + + $major_version = regsubst($::ovs_version, '^(\d+).*', '\1') + if $major_version == '1' { + $kernel_mod_file = "/lib/modules/${::kernelrelease}/updates/dkms/openvswitch_mod.ko" + } else { + $kernel_mod_file = "/lib/modules/${::kernelrelease}/updates/dkms/openvswitch.ko" + } + } 'Redhat': { service { 'openvswitch': diff --git a/spec/classes/vswitch_ovs_spec.rb b/spec/classes/vswitch_ovs_spec.rb index 5bf8db9d..5cbb0281 100644 --- a/spec/classes/vswitch_ovs_spec.rb +++ b/spec/classes/vswitch_ovs_spec.rb @@ -96,7 +96,9 @@ describe 'vswitch::ovs' do let :params do default_params end let :facts do - {:osfamily => 'Redhat'} + {:osfamily => 'Redhat', + :ovs_version => '1.4.2', + } end let :platform_params do redhat_platform_params end @@ -113,7 +115,9 @@ describe 'vswitch::ovs' do end let :facts do - {:osfamily => 'Redhat'} + {:osfamily => 'Redhat', + :ovs_version => '1.4.2', + } end let :platform_params do redhat_platform_params end @@ -127,6 +131,7 @@ describe 'vswitch::ovs' do let :facts do {:osfamily => 'Debian', :operatingsystem => 'Debian', + :ovs_version => '1.4.2', } end let :platform_params do debian_platform_params end @@ -145,6 +150,7 @@ describe 'vswitch::ovs' do let :facts do {:osfamily => 'Debian', :operatingsystem => 'Debian', + :ovs_version => '1.4.2', } end let :platform_params do debian_platform_params end @@ -159,6 +165,7 @@ describe 'vswitch::ovs' do let :facts do {:osfamily => 'Debian', :operatingsystem => 'ubuntu', + :ovs_version => '1.4.2', } end let :platform_params do ubuntu_platform_params end @@ -177,6 +184,7 @@ describe 'vswitch::ovs' do let :facts do {:osfamily => 'Debian', :operatingsystem => 'ubuntu', + :ovs_version => '1.4.2', } end let :platform_params do ubuntu_platform_params end @@ -191,6 +199,7 @@ describe 'vswitch::ovs' do let :facts do {:osfamily => 'FreeBSD', :operatingsystem => 'FreeBSD', + :ovs_version => '1.4.2', } end let :platform_params do freebsd_platform_params end @@ -218,6 +227,7 @@ describe 'vswitch::ovs' do let :facts do {:osfamily => 'FreeBSD', :operatingsystem => 'FreeBSD', + :ovs_version => '1.4.2', } end let :platform_params do freebsd_platform_params end