summaryrefslogtreecommitdiffstats
path: root/lib/facter/util/vlans.rb
blob: 2b2a72f4542337ec24cdaf7b698a9a6473741f26 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# A module to gather vlan facts
#
module Facter::Util::Vlans
    def self.get_vlan_config
        output = ""
            if File.exists?('/proc/net/vlan/config') and File.readable?('/proc/net/vlan/config')
                output = File.open('/proc/net/vlan/config').read
            end
        output
    end

    def self.get_vlans
        vlans = Array.new
        if self.get_vlan_config
            self.get_vlan_config.each_line do |line|
                if line =~ /^([0-9A-Za-z]+)\.([0-9]+) /
                    vlans.insert(-1, $~[2]) if $~[2]
                end
            end
        end

        vlans.join(',')
    end
end