boris 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +13 -0
  3. data/README.md +58 -30
  4. data/Rakefile +7 -1
  5. data/code_lookups.yml +94 -0
  6. data/lib/boris.rb +17 -2
  7. data/lib/boris/connectors.rb +3 -2
  8. data/lib/boris/connectors/ssh.rb +92 -48
  9. data/lib/boris/connectors/wmi.rb +8 -5
  10. data/lib/boris/{helpers → core_ext}/array.rb +0 -0
  11. data/lib/boris/core_ext/datetime.rb +38 -0
  12. data/lib/boris/{helpers → core_ext}/hash.rb +0 -0
  13. data/lib/boris/{helpers → core_ext}/string.rb +91 -33
  14. data/lib/boris/{helpers → core_ext}/time.rb +0 -0
  15. data/lib/boris/helpers/constants.rb +6 -3
  16. data/lib/boris/helpers/scrubber.rb +2 -1
  17. data/lib/boris/options.rb +29 -7
  18. data/lib/boris/profiler_core.rb +15 -0
  19. data/lib/boris/profilers/big_ip/big_ip10.rb +10 -0
  20. data/lib/boris/profilers/big_ip/big_ip11.rb +10 -0
  21. data/lib/boris/profilers/big_ip_core.rb +210 -0
  22. data/lib/boris/profilers/brocade_fos/fos6.rb +10 -0
  23. data/lib/boris/profilers/brocade_fos_core.rb +144 -0
  24. data/lib/boris/profilers/cisco/ios12.rb +21 -0
  25. data/lib/boris/profilers/cisco/nxos5.rb +11 -0
  26. data/lib/boris/profilers/cisco_ios_core.rb +138 -0
  27. data/lib/boris/profilers/cisco_nxos_core.rb +148 -0
  28. data/lib/boris/profilers/linux/redhat/rhel5.rb +13 -0
  29. data/lib/boris/profilers/linux/redhat/rhel6.rb +13 -0
  30. data/lib/boris/profilers/linux/{redhat.rb → redhat_core.rb} +2 -8
  31. data/lib/boris/profilers/linux_core.rb +25 -7
  32. data/lib/boris/profilers/onboard_administrator/oa3.rb +10 -0
  33. data/lib/boris/profilers/onboard_administrator_core.rb +96 -0
  34. data/lib/boris/profilers/unix/solaris/solaris10.rb +11 -0
  35. data/lib/boris/profilers/unix/solaris/solaris11.rb +11 -0
  36. data/lib/boris/profilers/unix/{solaris.rb → solaris_core.rb} +13 -13
  37. data/lib/boris/profilers/unix_core.rb +23 -6
  38. data/lib/boris/profilers/windows/windows2003.rb +1 -2
  39. data/lib/boris/profilers/windows/windows2008.rb +1 -2
  40. data/lib/boris/profilers/windows/windows2012.rb +1 -2
  41. data/lib/boris/profilers/windows_core.rb +29 -8
  42. data/lib/boris/structure.rb +15 -0
  43. data/lib/boris/target.rb +19 -3
  44. data/lib/boris/version.rb +1 -1
  45. metadata +27 -11
  46. data/lib/boris/helpers.rb +0 -7
  47. data/lib/boris/profiler.rb +0 -18
@@ -0,0 +1,10 @@
1
+ require 'boris/profilers/brocade_fos_core'
2
+
3
+ module Boris; module Profilers
4
+ class FOS6 < BrocadeFOSCore
5
+
6
+ def self.matches_target?(connector)
7
+ return true if connector.values_at('version').join =~ /fabric os.*v6/i
8
+ end
9
+ end
10
+ end; end
@@ -0,0 +1,144 @@
1
+ require 'boris/profiler_core'
2
+
3
+ module Boris; module Profilers
4
+ class BrocadeFOSCore
5
+ include ProfilerCore
6
+
7
+ def self.connection_type
8
+ Boris::SSHConnector
9
+ end
10
+
11
+ def switchshow_data
12
+ @switchshow_data ||= @connector.values_at('switchshow')
13
+ end
14
+
15
+ def version_data
16
+ @version_data ||= @connector.values_at('version')
17
+ end
18
+
19
+ def get_file_systems; super; end
20
+
21
+ def get_hardware
22
+ super
23
+
24
+ switch_type_id = switchshow_data.grep(/switchtype/i)[0].after_colon.extract(/(\d+)\./).to_i
25
+
26
+ @hardware[:firmware_version] = version_data.grep(/bootprom/i)[0].after_colon
27
+
28
+ @hardware[:model] = CODE_LOOKUPS['brocade']['switches'][switch_type_id]
29
+
30
+ serial = @connector.value_at('chassisshow | grep "Factory Serial"')
31
+ @hardware[:serial] = serial.after_colon.strip.upcase
32
+
33
+ @hardware[:vendor] = VENDOR_BROCADE
34
+
35
+ @hardware
36
+ end
37
+
38
+ def get_hosted_shares; super; end
39
+ def get_installed_applications; super; end
40
+ def get_installed_patches; super; end
41
+ def get_installed_services; super; end
42
+ def get_local_user_groups; super; end
43
+
44
+ def get_network_id
45
+ super
46
+
47
+ hostname = switchshow_data.grep(/switchname/i)[0].after_colon.split('.')
48
+
49
+ @network_id[:hostname] = hostname.shift
50
+ @network_id[:domain] = hostname.join('.') if hostname.any?
51
+
52
+ @network_id
53
+ end
54
+
55
+ def get_network_interfaces
56
+ super
57
+
58
+ # get the management (ethernet) port... usually eth0
59
+ ifmodeshow_data = @connector.values_at('ifmodeshow "eth0"')
60
+
61
+ if ifmodeshow_data.join =~ /mac address/i
62
+ h = network_interface_template
63
+
64
+ link_data = ifmodeshow_data.grep(/link mode/i)[0].after_colon
65
+
66
+ h[:auto_negotiate] = link_data =~ /negotiated/i ? true : false
67
+ h[:mac_address] = ifmodeshow_data.grep(/mac address/i)[0].split.last.upcase
68
+ h[:model] = 'Unknown Ethernet Adapter'
69
+ h[:name] = 'eth0'
70
+ h[:status] = link_data =~ /link ok/i ? 'up' : 'down'
71
+ h[:type] = 'ethernet'
72
+ h[:vendor] = VENDOR_BROCADE
73
+
74
+ if h[:status] == 'up'
75
+ h[:current_speed_mbps] = link_data.extract(/(\d+)base/i).to_i
76
+
77
+ ip_data = @connector.values_at('ipaddrshow')
78
+
79
+ h[:ip_addresses] << {
80
+ :ip_address=>ip_data.grep(/ethernet ip address/i)[0].after_colon,
81
+ :subnet=>ip_data.grep(/ethernet subnet/i)[0].after_colon
82
+ }
83
+ end
84
+
85
+ @network_interfaces << h
86
+ end
87
+
88
+ # now get the fibre ports
89
+ # first we have determine whether the data from the switchshow command includes slot numbers
90
+ offset = switchshow_data.grep(/media.*speed.*state/i)[0] =~ /slot/i ? 1 : 0
91
+
92
+ switch_ports = switchshow_data.join("\n").split(/\=+/).last.strip.split(/\n/) unless switchshow_data.empty?
93
+
94
+ switch_ports.each do |switch_port|
95
+ switch_port = switch_port.strip.gsub(/\s+/, ' ').split
96
+
97
+ h = network_interface_template
98
+
99
+ port_id = offset == 1 ? switch_port[1] + '/' + switch_port[2] : switch_port[1]
100
+
101
+ portshow_data = @connector.values_at("portshow #{port_id}")
102
+
103
+ h[:model] = 'Unknown Fibre Adapter'
104
+ h[:name] = 'fc' + port_id
105
+ h[:port_wwn] = portshow_data.grep(/portwwn\:/i)[0].split.last.upcase
106
+
107
+ h[:type] = 'fibre'
108
+ h[:status] = switch_port[5 + offset] =~ /online/i ? 'up' : 'down'
109
+ h[:vendor] = VENDOR_BROCADE
110
+
111
+ if h[:status] == 'up'
112
+ speed = switch_port[4 + offset]
113
+ h[:auto_negotiate] = true if speed =~ /^N/
114
+ h[:current_speed_mbps] = speed.scan(/\d+/).join.to_i * 1000
115
+
116
+ remote_wwns = portshow_data.join("\n").extract(/portWwn of device\(s\) connected\:(.*)Distance/im).strip.split(/\n/)
117
+
118
+ if switch_port.join =~ /upstream/i || remote_wwns.count > 1
119
+ h[:is_uplink] = true
120
+ elsif remote_wwns.count == 1
121
+ h[:remote_wwn] = remote_wwns[0].strip
122
+ end
123
+ end
124
+
125
+ @network_interfaces << h
126
+ end
127
+
128
+ @network_interfaces
129
+ end
130
+
131
+ def get_operating_system
132
+ super
133
+
134
+ @operating_system[:kernel] = version_data.grep(/kernel/i)[0].after_colon
135
+ @operating_system[:name] = 'Brocade Fabric OS'
136
+ @operating_system[:version] = version_data.grep(/fabric os/i)[0].after_colon.delete('v')
137
+
138
+ @operating_system
139
+ end
140
+
141
+ def get_running_processes; super; end
142
+
143
+ end
144
+ end; end
@@ -0,0 +1,21 @@
1
+ require 'boris/profilers/cisco_ios_core'
2
+
3
+ module Boris; module Profilers
4
+ class IOS12 < CiscoIOSCore
5
+
6
+ def self.matches_target?(connector)
7
+ version = connector.values_at('show version | include (Version|ROM)')
8
+ return true if version[0] =~ /cisco ios.*version 12/i && version.join =~ /ROM:\s+12/i
9
+ end
10
+
11
+ def get_operating_system
12
+ super
13
+
14
+ @operating_system[:name] = 'Cisco IOS'
15
+ @operating_system[:version] = version_data[0].extract(/version (.*),/i)
16
+
17
+ @operating_system
18
+ end
19
+
20
+ end
21
+ end; end
@@ -0,0 +1,11 @@
1
+ require 'boris/profilers/cisco_nxos_core'
2
+
3
+ module Boris; module Profilers
4
+ class NXOS5 < CiscoNXOSCore
5
+
6
+ def self.matches_target?(connector)
7
+ return true if connector.value_at("show version | grep -i 'system version'") =~ /version\: 5/i
8
+ end
9
+
10
+ end
11
+ end; end
@@ -0,0 +1,138 @@
1
+ require 'boris/profiler_core'
2
+
3
+ module Boris; module Profilers
4
+ class CiscoIOSCore
5
+ include ProfilerCore
6
+
7
+ attr_reader :version_data
8
+
9
+ def self.connection_type
10
+ Boris::SSHConnector
11
+ end
12
+
13
+ def version_data
14
+ @version_data ||= @connector.values_at('show version | include (Version|ROM|uptime|CPU|bytes of memory)')
15
+ end
16
+
17
+ def get_file_systems; super; end
18
+
19
+ def get_hardware
20
+ super
21
+
22
+ cpu_data = version_data.grep(/cpu/i)[0]
23
+
24
+ @hardware[:cpu_model] = cpu_data.extract(/\s*(\w+) CPU/)
25
+ @hardware[:cpu_physical_count] = 1
26
+
27
+ cpu_speed = cpu_data.extract(/CPU at (\d+(?=[ghz|mhz]))/i).to_i
28
+
29
+ @hardware[:cpu_speed_mhz] = cpu_data =~ /ghz/i ? cpu_speed * 1000 : cpu_speed
30
+ @hardware[:firmware_version] = version_data.join("\n").extract(/ROM: (.+)/i)
31
+
32
+ hardware_data = @connector.values_at('show idprom chassis | include (Product|Serial Number)')
33
+
34
+ @hardware[:model] = hardware_data.grep(/product/i)[0].value_after_character('=')
35
+ @hardware[:memory_installed_mb] = version_data.grep(/memory/i)[0].extract(/(\d+)K bytes/).to_i / 1024
36
+ @hardware[:serial] = hardware_data.grep(/serial number/i)[0].value_after_character('=')
37
+ @hardware[:vendor] = VENDOR_CISCO
38
+
39
+ @hardware
40
+ end
41
+
42
+ def get_hosted_shares; super; end
43
+ def get_installed_applications; super; end
44
+ def get_installed_patches; super; end
45
+ def get_installed_services; super; end
46
+ def get_local_user_groups; super; end
47
+
48
+ def get_network_id
49
+ super
50
+
51
+ @network_id[:hostname] = version_data.grep(/uptime is/)[0].strip.extract(/^(.+) uptime is/i)
52
+
53
+ @network_id
54
+ end
55
+
56
+ def get_network_interfaces
57
+ super
58
+
59
+ interface_data = @connector.values_at('show interface | include (protocol|Hardware|Internet|MTU|duplex|Members)').join("\n").split(/^(?=\w)/)
60
+
61
+ physical_uplink_ports = []
62
+
63
+ interface_data.each do |interface|
64
+
65
+ # don't bother with LOM ports
66
+ next if interface =~ /out of band/i
67
+
68
+ h = network_interface_template
69
+
70
+ interface = interface.split(/\n/)
71
+
72
+ status = interface.grep(/protocol/)[0]
73
+ hardware = interface.grep(/hardware/i)[0]
74
+ ip = interface.grep(/internet address/i)[0]
75
+ mtu = interface.grep(/mtu/i)[0]
76
+
77
+
78
+ h[:mac_address] = hardware.extract(/\(bia (.+)\)/i).delete('.').scan(/../).join(':').upcase
79
+ h[:mtu] = mtu.extract(/mtu (\d+) bytes/i).to_i
80
+ h[:model] = hardware.extract(/hardware is (.+),/i)
81
+
82
+ h[:name] = status.split[0]
83
+
84
+ if h[:name] =~ /port\-*channel/i
85
+ physical_uplink_ports.concat(interface.grep(/members in this channel/i)[0].after_colon.strip.split)
86
+ end
87
+
88
+ h[:status] = status =~ /down/i ? 'down' : 'up'
89
+ h[:type] = 'ethernet'
90
+ h[:vendor] = VENDOR_CISCO
91
+
92
+ connection = interface.grep(/duplex/i)[0]
93
+
94
+ if connection && h[:status] == 'up'
95
+ connection = connection.split(',')
96
+ h[:auto_negotiate] = true if connection[2] =~ /link type is auto/i
97
+
98
+ if connection[1] =~ /mb|gb/i
99
+ speed = connection[1].extract(/(\d+)/i).to_i
100
+ h[:current_speed_mbps] = connection[1] =~ /gb/i ? speed * 1000 : speed
101
+ end
102
+
103
+ h[:duplex] = connection[0].extract(/(\w+)-duplex/i).downcase
104
+ end
105
+
106
+ if ip
107
+ ip_data = ip.extract(/internet address is (.+)$/i).split(/\//)
108
+
109
+ ip_address = ip_data.first
110
+ subnet = NetAddr.i_to_ip(NetAddr.bits_to_mask(ip_data.last.to_i, NetAddr::CIDRv4))
111
+
112
+ h[:ip_addresses] << {:ip_address=>ip_address, :subnet=>subnet}
113
+ end
114
+
115
+ @network_interfaces << h
116
+ end
117
+
118
+ mac_address_table = @connector.values_at('show mac-address-table')
119
+
120
+ @network_interfaces.each do |h|
121
+ short_name = h[:name].sub(h[:name].extract(/^..(\D+)/), '')
122
+
123
+ remote_mac_addresses = mac_address_table.grep(/#{h[:name]}/)
124
+
125
+ if physical_uplink_ports.include?(short_name) || remote_mac_addresses.count > 1
126
+ h[:is_uplink] = true
127
+ elsif remote_mac_addresses.any?
128
+ h[:remote_mac_address] = remote_mac_addresses[0].split[1].delete('.').scan(/../).join(':').upcase
129
+ end
130
+ end
131
+
132
+ @network_interfaces
133
+ end
134
+
135
+ def get_operating_system; super; end
136
+
137
+ end
138
+ end; end
@@ -0,0 +1,148 @@
1
+ require 'boris/profiler_core'
2
+
3
+ module Boris; module Profilers
4
+ class CiscoNXOSCore
5
+ include ProfilerCore
6
+
7
+ attr_reader :version_data
8
+
9
+ def self.connection_type
10
+ Boris::SSHConnector
11
+ end
12
+
13
+ def version_data
14
+ @version_data ||= @connector.values_at('show version | grep -i "bios:\|system version\|chassis\|memory\|device"')
15
+ end
16
+
17
+ def get_file_systems; super; end
18
+
19
+ def get_hardware
20
+ super
21
+
22
+ cpu_data = version_data.grep(/cpu/i)[0]
23
+
24
+ @hardware[:cpu_model] = cpu_data.extract(/\s*(.*)\s*with/).strip
25
+ @hardware[:cpu_physical_count] = 1
26
+
27
+ @hardware[:firmware_version] = version_data.join("\n").extract(/BIOS\:\s*version\s*(.+)/i)
28
+
29
+ hardware_data = @connector.values_at('show sprom backplane | grep Product\|Serial')
30
+
31
+ @hardware[:model] = hardware_data.grep(/product number/i)[0].after_colon
32
+ @hardware[:memory_installed_mb] = cpu_data.extract(/(\d+) kb/i).to_i / 1024
33
+ @hardware[:serial] = hardware_data.grep(/serial number/i)[0].after_colon
34
+ @hardware[:vendor] = VENDOR_CISCO
35
+
36
+ @hardware
37
+ end
38
+
39
+ def get_hosted_shares; super; end
40
+ def get_installed_applications; super; end
41
+ def get_installed_patches; super; end
42
+ def get_installed_services; super; end
43
+ def get_local_user_groups; super; end
44
+
45
+ def get_network_id
46
+ super
47
+
48
+ @network_id[:hostname] = version_data.grep(/device name/i)[0].after_colon
49
+
50
+ @network_id
51
+ end
52
+
53
+ def get_network_interfaces
54
+ super
55
+
56
+ interface_data = @connector.values_at('show interface | grep "is up\|is down\|Hardware\|Internet\|MTU\|duplex\|Members"').join("\n").split(/^(?=\w)/)
57
+
58
+ physical_uplink_ports = []
59
+
60
+ interface_data.each do |interface|
61
+
62
+ # don't bother with LOM ports
63
+ next if interface =~ /mgmt\d/i
64
+
65
+ h = network_interface_template
66
+
67
+ interface = interface.split(/\n/)
68
+
69
+ status = interface.grep(/is up|is down/)[0]
70
+ hardware = interface.grep(/hardware/i)[0].gsub(': ', ' is ')
71
+ ip = interface.grep(/internet address/i)[0]
72
+ mtu = interface.grep(/mtu/i)[0]
73
+
74
+ h[:mac_address] = hardware.extract(/address is\s*(.{4}\..{4}\..{4})/i).delete('.').scan(/../).join(':').upcase
75
+ h[:mtu] = mtu.extract(/mtu (\d+) bytes/i).to_i
76
+ h[:model] = hardware.extract(/hardware is (.+),/i)
77
+
78
+ h[:name] = status.split[0]
79
+
80
+ if h[:name] =~ /port\-*channel/i
81
+ physical_uplink_ports.concat(interface.grep(/members in this channel/i)[0].after_colon.strip.split)
82
+ h[:type] = 'port-channel'
83
+ else
84
+ h[:type] = 'ethernet'
85
+ end
86
+
87
+ h[:status] = status =~ /down/i ? 'down' : 'up'
88
+ h[:vendor] = VENDOR_CISCO
89
+
90
+ connection = interface.grep(/duplex/i)[0]
91
+
92
+ if connection && h[:status] == 'up'
93
+ connection = connection.split(',')
94
+ h[:auto_negotiate] = true if connection[2] =~ /link type is auto/i
95
+
96
+ if connection[1] =~ /mb|gb/i
97
+ speed = connection[1].extract(/(\d+)/i).to_i
98
+ h[:current_speed_mbps] = connection[1] =~ /gb/i ? speed * 1000 : speed
99
+ end
100
+
101
+ h[:duplex] = connection[0].extract(/(\w+)-duplex/i).downcase
102
+ end
103
+
104
+ if ip
105
+ ip_data = ip.extract(/internet address is (.+)$/i).split(/\//)
106
+
107
+ ip_address = ip_data.first
108
+ subnet = NetAddr.i_to_ip(NetAddr.bits_to_mask(ip_data.last.to_i, NetAddr::CIDRv4))
109
+
110
+ h[:ip_addresses] << {:ip_address=>ip_address, :subnet=>subnet}
111
+ end
112
+
113
+ @network_interfaces << h
114
+ end
115
+
116
+ mac_address_table = @connector.values_at('show mac-address-table')
117
+
118
+ @network_interfaces.each do |h|
119
+ short_name = if h[:name] =~ /ethernet/i
120
+ h[:name].sub(h[:name].extract(/^...(\D+)/), '')
121
+ else
122
+ h[:name].sub(h[:name].extract(/^..(\D+)/), '')
123
+ end
124
+
125
+ remote_mac_addresses = mac_address_table.grep(/#{short_name}/i)
126
+
127
+ if physical_uplink_ports.include?(short_name) || remote_mac_addresses.count > 1
128
+ h[:is_uplink] = true
129
+ elsif remote_mac_addresses.any?
130
+ h[:remote_mac_address] = remote_mac_addresses[0].split[2].delete('.').scan(/../).join(':').upcase
131
+ end
132
+ end
133
+
134
+ @network_interfaces
135
+ end
136
+
137
+ def get_operating_system
138
+ super
139
+
140
+ @operating_system[:kernel] = version_data.grep(/system version/i)[0].after_colon
141
+ @operating_system[:name] = 'Cisco Nexus Operating System'
142
+ @operating_system[:version] = @operating_system[:kernel].split('(')[0]
143
+
144
+ @operating_system
145
+ end
146
+
147
+ end
148
+ end; end