2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/facter/onering_properties_network.rb', line 2
def _format(key, value)
rv = []
value = nil if value =~ /Not received/i
begin
case key
when :autoneg
v0, v1 = value.split('/')
rv << [:autoneg_supported, (v0 == 'supported')]
rv << [:autoneg_enabled, (v1 == 'enabled')]
when :mgmt_ip
rv << [:management_ip, value]
when :mau_oper_type
rv << [:mau_type, value]
when :port_id
value = value.split(' ')
value = value.select{|i| i =~ /..:..:..:..:..:../ }.first
rv << [:port_mac, value.upcase]
when :chassis_id
value = value.split(' ')
value = value.select{|i| i =~ /..:..:..:..:..:../ }.first
rv << [:chassis_mac, value.upcase]
when :port_descr
port = value.split(/[^0-9]([0-9])/, 2)
port.shift
port = port.join('')
rv << [:port_name, value]
rv << [:port, port]
when :mfs
rv << [:mfs, (value.split(' ').first.to_i rescue nil)]
when :sys_name
rv << [:switch, value]
when :lldp_med_device_type,
:lldp_med_capabilities,
:caps,
:sys_descr
return []
else
rv << [key, value]
end
rescue
nil
end
return rv
end
|