[Pkg-puppet-devel] [facter] 325/352: (FACT-379) Don't return VLANs when only header is present

Stig Sandbeck Mathisen ssm at debian.org
Sun Apr 6 22:21:57 UTC 2014


This is an automated email from the git hooks/post-receive script.

ssm pushed a commit to branch master
in repository facter.

commit 8e5e9e9eda63e113e2053963c3da927cfe62ca6a
Author: Adrien Thebo <git at somethingsinistral.net>
Date:   Tue Mar 11 15:44:35 2014 -0700

    (FACT-379) Don't return VLANs when only header is present
    
    On CentOS 5 the vlans file is always present regardless of if any vlans
    is defined, which behaves like there are VLANs defined but doesn't match
    any regexps. This commit explicitly ensures that we have a non-empty
    list of VLANs before returning anything.
---
 lib/facter/util/vlans.rb                        | 2 +-
 spec/fixtures/unit/util/vlans/centos-5-no-vlans | 2 ++
 spec/unit/util/vlans_spec.rb                    | 5 +++++
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/lib/facter/util/vlans.rb b/lib/facter/util/vlans.rb
index e42a28f..5082380 100644
--- a/lib/facter/util/vlans.rb
+++ b/lib/facter/util/vlans.rb
@@ -15,7 +15,7 @@ module Facter::Util::Vlans
           vlans << match[2] if match[2]
         end
       end
-      vlans.join(',')
+      vlans.join(',') unless vlans.empty?
     end
   end
 end
diff --git a/spec/fixtures/unit/util/vlans/centos-5-no-vlans b/spec/fixtures/unit/util/vlans/centos-5-no-vlans
new file mode 100644
index 0000000..22028c8
--- /dev/null
+++ b/spec/fixtures/unit/util/vlans/centos-5-no-vlans
@@ -0,0 +1,2 @@
+VLAN Dev name	 | VLAN ID
+Name-Type: VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD
diff --git a/spec/unit/util/vlans_spec.rb b/spec/unit/util/vlans_spec.rb
index caed3a6..989c914 100755
--- a/spec/unit/util/vlans_spec.rb
+++ b/spec/unit/util/vlans_spec.rb
@@ -33,5 +33,10 @@ describe Facter::Util::Vlans do
       Facter::Util::Vlans.stubs(:get_vlan_config).returns(nil)
       expect(Facter::Util::Vlans.get_vlans()).to be_nil
     end
+
+    it "returns nil when only the vlan header is returned" do
+      Facter::Util::Vlans.stubs(:get_vlan_config).returns(my_fixture_read("centos-5-no-vlans"))
+      expect(Facter::Util::Vlans.get_vlans()).to be_nil
+    end
   end
 end

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-puppet/facter.git



More information about the Pkg-puppet-devel mailing list