143: def self.get_interface_value(interface, label)
144: tmp1 = []
145:
146: kernel = Facter.value(:kernel).downcase.to_sym
147:
148:
149: unless map = REGEX_MAP[kernel] || REGEX_MAP.values.find { |tmp| tmp[:aliases] and tmp[:aliases].include?(kernel) }
150: return []
151: end
152:
153:
154: regex = map[label.to_sym]
155:
156:
157:
158:
159: bonddev = get_bonding_master(interface)
160: if label == 'macaddress' and bonddev
161: bondinfo = IO.readlines("/proc/net/bonding/#{bonddev}")
162: hwaddrre = /^Slave Interface: #{interface}\n[^\n].+?\nPermanent HW addr: (([0-9a-fA-F]{2}:?)*)$/m
163: value = hwaddrre.match(bondinfo.to_s)[1].upcase
164: else
165: output_int = get_output_for_interface_and_label(interface, label)
166:
167: output_int.each_line do |s|
168: if s =~ regex
169: value = $1
170: if label == 'netmask' && convert_from_hex?(kernel)
171: value = value.scan(/../).collect do |byte| byte.to_i(16) end.join('.')
172: end
173: tmp1.push(value)
174: end
175: end
176:
177: if tmp1
178: value = tmp1.shift
179: end
180: end
181: end