boris 1.0.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE.md +9 -0
- data/README.md +94 -0
- data/boris.gemspec +28 -0
- data/doc/Array.html +437 -0
- data/doc/Boris.html +230 -0
- data/doc/Boris/ConnectionAlreadyActive.html +123 -0
- data/doc/Boris/ConnectionFailed.html +127 -0
- data/doc/Boris/Connector.html +794 -0
- data/doc/Boris/InvalidCredentials.html +131 -0
- data/doc/Boris/InvalidOption.html +123 -0
- data/doc/Boris/InvalidTargetName.html +123 -0
- data/doc/Boris/Lumberjack.html +466 -0
- data/doc/Boris/MissingCredentials.html +123 -0
- data/doc/Boris/NoActiveConnection.html +123 -0
- data/doc/Boris/NoProfileDetected.html +123 -0
- data/doc/Boris/Options.html +783 -0
- data/doc/Boris/Profiles.html +117 -0
- data/doc/Boris/Profiles/Linux.html +1151 -0
- data/doc/Boris/Profiles/RedHat.html +875 -0
- data/doc/Boris/Profiles/Solaris.html +1230 -0
- data/doc/Boris/Profiles/Structure.html +2050 -0
- data/doc/Boris/Profiles/UNIX.html +893 -0
- data/doc/Boris/Profiles/Windows.html +1846 -0
- data/doc/Boris/Profiles/Windows/Windows2003.html +304 -0
- data/doc/Boris/Profiles/Windows/Windows2008.html +379 -0
- data/doc/Boris/Profiles/Windows/Windows2012.html +304 -0
- data/doc/Boris/SNMPConnector.html +512 -0
- data/doc/Boris/SSHConnector.html +633 -0
- data/doc/Boris/Target.html +2002 -0
- data/doc/Boris/WMIConnector.html +1134 -0
- data/doc/BorisLogger.html +217 -0
- data/doc/Hash.html +195 -0
- data/doc/String.html +1246 -0
- data/doc/_index.html +420 -0
- data/doc/class_list.html +53 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +57 -0
- data/doc/css/style.css +328 -0
- data/doc/file.README.html +183 -0
- data/doc/file_list.html +55 -0
- data/doc/frames.html +28 -0
- data/doc/index.html +183 -0
- data/doc/js/app.js +214 -0
- data/doc/js/full_list.js +173 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +1468 -0
- data/doc/top-level-namespace.html +126 -0
- data/lib/boris.rb +30 -0
- data/lib/boris/connectors.rb +47 -0
- data/lib/boris/connectors/snmp.rb +56 -0
- data/lib/boris/connectors/ssh.rb +110 -0
- data/lib/boris/connectors/wmi.rb +186 -0
- data/lib/boris/errors.rb +17 -0
- data/lib/boris/helpers/array.rb +63 -0
- data/lib/boris/helpers/constants.rb +20 -0
- data/lib/boris/helpers/hash.rb +8 -0
- data/lib/boris/helpers/scrubber.rb +51 -0
- data/lib/boris/helpers/string.rb +130 -0
- data/lib/boris/lumberjack.rb +47 -0
- data/lib/boris/options.rb +86 -0
- data/lib/boris/profiles/linux/redhat.rb +77 -0
- data/lib/boris/profiles/linux_core.rb +216 -0
- data/lib/boris/profiles/unix/solaris.rb +307 -0
- data/lib/boris/profiles/unix_core.rb +85 -0
- data/lib/boris/profiles/windows/windows2003.rb +15 -0
- data/lib/boris/profiles/windows/windows2008.rb +23 -0
- data/lib/boris/profiles/windows/windows2012.rb +15 -0
- data/lib/boris/profiles/windows_core.rb +530 -0
- data/lib/boris/structure.rb +167 -0
- data/lib/boris/target.rb +340 -0
- data/test/connector_tests/test_snmp.rb +35 -0
- data/test/connector_tests/test_ssh.rb +51 -0
- data/test/connector_tests/test_wmi.rb +129 -0
- data/test/helper_tests/test_array.rb +25 -0
- data/test/helper_tests/test_hash.rb +10 -0
- data/test/helper_tests/test_string.rb +136 -0
- data/test/profile_tests/test_core_skeleton +107 -0
- data/test/profile_tests/test_linux_core.rb +331 -0
- data/test/profile_tests/test_redhat.rb +134 -0
- data/test/profile_tests/test_solaris.rb +523 -0
- data/test/profile_tests/test_unix_core.rb +117 -0
- data/test/profile_tests/test_windows.rb +536 -0
- data/test/setup_tests.rb +14 -0
- data/test/test_all.rb +8 -0
- data/test/test_options.rb +44 -0
- data/test/test_structure.rb +136 -0
- data/test/test_target.rb +146 -0
- metadata +241 -0
@@ -0,0 +1,523 @@
|
|
1
|
+
require 'setup_tests'
|
2
|
+
|
3
|
+
class SolarisCoreTest < ProfileTestSetup
|
4
|
+
context 'a Solaris target' do
|
5
|
+
setup do
|
6
|
+
@connector = @target.connector = instance_of(SSHConnector)
|
7
|
+
@target.stubs(:target_profile).returns(Profiles::Solaris)
|
8
|
+
@target.extend(Profiles::Solaris)
|
9
|
+
@connector.stubs(:value_at).with('uname').returns('SunOS')
|
10
|
+
end
|
11
|
+
|
12
|
+
should 'detect when a target should use the Solaris profile' do
|
13
|
+
assert_equal(Profiles::Solaris, @target.target_profile)
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'being scanned' do
|
17
|
+
setup do
|
18
|
+
@showrev_command = 'showrev'
|
19
|
+
@zoneadm_command = '/usr/sbin/zoneadm list'
|
20
|
+
end
|
21
|
+
|
22
|
+
# handled by UNIX core
|
23
|
+
#context 'for file system information' do
|
24
|
+
#end
|
25
|
+
|
26
|
+
context 'for hardware information' do
|
27
|
+
setup do
|
28
|
+
@memory_command = "/usr/sbin/prtconf | egrep -i 'memory size' | awk '{print $3}'"
|
29
|
+
@memory_data = '1024'
|
30
|
+
@connector.stubs(:value_at).with(@memory_command).returns(@memory_data)
|
31
|
+
|
32
|
+
@isainfo_command = "isainfo -v | egrep -i applications | awk '{print $1}'"
|
33
|
+
@isainfo_data = ['64-bit', '32-bit']
|
34
|
+
@connector.stubs(:values_at).with(@isainfo_command).returns(@isainfo_data)
|
35
|
+
|
36
|
+
@sparc_model_command = '/usr/sbin/prtconf -b | grep banner-name'
|
37
|
+
|
38
|
+
@cpu_command = %q{kstat -m cpu_info | nawk '{if(tolower($1)~/^(chip_id|core_id|clock_mhz|vendor_id|brand)/) {sub($1, $1"|"); print $0}}'}
|
39
|
+
@smbios_command = "/usr/sbin/smbios -t SMB_TYPE_SYSTEM | egrep -i 'manufacturer|product|serial'"
|
40
|
+
|
41
|
+
@sparc_firmware_command = %q{/usr/platform/`uname -m`/sbin/prtdiag -v | egrep -i "^obp" | awk '{print $2}'}
|
42
|
+
@x86_firmware_command = '/usr/sbin/smbios -t SMB_TYPE_BIOS | grep -i "version string"'
|
43
|
+
@connector.stubs(:value_at).with(@x86_firmware_command).returns('Version string: 6.0')
|
44
|
+
@connector.stubs(:value_at).with(@sparc_firmware_command).returns('6.0')
|
45
|
+
end
|
46
|
+
|
47
|
+
context 'for an x86-based platform' do
|
48
|
+
setup do
|
49
|
+
@showrev_data = ['Application architecture: i386']
|
50
|
+
@cpu_data = %q{
|
51
|
+
brand| Intel(r) Xeon(r) CPU X5680 @ 3.33GHz
|
52
|
+
chip_id| 0
|
53
|
+
clock_MHz| 3333
|
54
|
+
core_id| 0
|
55
|
+
vendor_id| GenuineIntel
|
56
|
+
brand| Intel(r) Xeon(r) CPU X5680 @ 3.33GHz
|
57
|
+
chip_id| 0
|
58
|
+
clock_MHz| 3333
|
59
|
+
core_id| 1
|
60
|
+
vendor_id| GenuineIntel
|
61
|
+
}.strip.split(/\n/)
|
62
|
+
@cpu_data += @cpu_data # add another instance of this cpu, to emulate a hyperthreaded cpu
|
63
|
+
|
64
|
+
@expected_data = {
|
65
|
+
:cpu_architecture=>64,
|
66
|
+
:cpu_core_count=>2,
|
67
|
+
:cpu_model=>'Intel(r) Xeon(r) CPU X5680 @ 3.33GHz',
|
68
|
+
:cpu_physical_count=>1,
|
69
|
+
:cpu_speed_mhz=>3333,
|
70
|
+
:cpu_vendor=>'GenuineIntel',
|
71
|
+
:firmware_version=>'6.0',
|
72
|
+
:model=>'System x3650 M3 -[1234ABCD]-',
|
73
|
+
:memory_installed_mb=>1024,
|
74
|
+
:serial=>'ABCD1234',
|
75
|
+
:vendor=>'IBM'
|
76
|
+
}
|
77
|
+
|
78
|
+
@connector.stubs(:values_at).with(@showrev_command).returns(@showrev_data)
|
79
|
+
@connector.stubs(:values_at).with(@cpu_command).returns(@cpu_data)
|
80
|
+
end
|
81
|
+
|
82
|
+
context 'in the global zone' do
|
83
|
+
should 'return hardware information via #get_hardware' do
|
84
|
+
|
85
|
+
@smbios_data = %q{
|
86
|
+
Manufacturer: IBM
|
87
|
+
Product: System x3650 M3 -[1234ABCD]-
|
88
|
+
Serial Number: ABCD1234
|
89
|
+
}.strip.split(/\n/)
|
90
|
+
@connector.stubs(:values_at).with(@smbios_command).returns(@smbios_data)
|
91
|
+
|
92
|
+
@connector.stubs(:values_at).with(@zoneadm_command).returns('global')
|
93
|
+
|
94
|
+
@target.get_hardware
|
95
|
+
assert_equal(@expected_data, @target.hardware)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
context 'for a SPARC-based platform' do
|
101
|
+
setup do
|
102
|
+
@showrev_data = ['Application architecture: sparc']
|
103
|
+
@cpu_data = %q{
|
104
|
+
brand| SPARC64-VI
|
105
|
+
chip_id| 0
|
106
|
+
clock_MHz| 2400
|
107
|
+
core_id| 0
|
108
|
+
brand| SPARC64-VI
|
109
|
+
chip_id| 0
|
110
|
+
clock_MHz| 2400
|
111
|
+
core_id| 1
|
112
|
+
}.strip.split(/\n/)
|
113
|
+
|
114
|
+
@expected_data = {
|
115
|
+
:cpu_architecture=>64,
|
116
|
+
:cpu_core_count=>2,
|
117
|
+
:cpu_model=>'SPARC64-VI',
|
118
|
+
:cpu_physical_count=>1,
|
119
|
+
:cpu_speed_mhz=>2400,
|
120
|
+
:cpu_vendor=>VENDOR_ORACLE,
|
121
|
+
:firmware_version=>'6.0',
|
122
|
+
:model=>nil,
|
123
|
+
:memory_installed_mb=>1024,
|
124
|
+
:serial=>nil,
|
125
|
+
:vendor=>VENDOR_ORACLE
|
126
|
+
}
|
127
|
+
|
128
|
+
@connector.stubs(:values_at).with(@showrev_command).returns(@showrev_data)
|
129
|
+
@connector.stubs(:values_at).with(@cpu_command).returns(@cpu_data)
|
130
|
+
end
|
131
|
+
|
132
|
+
context 'in the global zone' do
|
133
|
+
should 'return hardware information via #get_hardware' do
|
134
|
+
@connector.stubs(:value_at).with(@sparc_model_command).returns('banner-name: Sun Fire 480R')
|
135
|
+
|
136
|
+
@expected_data[:model] = 'Sun Fire 480R'
|
137
|
+
|
138
|
+
@connector.stubs(:values_at).with(@zoneadm_command).returns('global')
|
139
|
+
|
140
|
+
@target.get_hardware
|
141
|
+
assert_equal(@expected_data, @target.hardware)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
context 'within a zone' do
|
146
|
+
should 'return hardware information via #get_hardware' do
|
147
|
+
@expected_data[:model] = 'Oracle Virtual Platform'
|
148
|
+
@expected_data[:firmware_version] = nil
|
149
|
+
|
150
|
+
@connector.stubs(:values_at).with(@smbios_command).returns([])
|
151
|
+
@connector.stubs(:values_at).with(@zoneadm_command).returns('somezone')
|
152
|
+
|
153
|
+
@target.get_hardware
|
154
|
+
assert_equal(@expected_data, @target.hardware)
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
context 'for hosted shares' do
|
161
|
+
setup do
|
162
|
+
@share_data = [
|
163
|
+
'/export/someshare|/dev/vs/dsk/ADMINSHARE/vol_someshare',
|
164
|
+
'/export/someothershare|/dev/vs/dsk/ADMINSHARE/vol_someothershare'
|
165
|
+
]
|
166
|
+
|
167
|
+
@expected_data = [
|
168
|
+
{:name=>@share_data[0].split('|')[0], :path=>@share_data[0].split('|')[1]},
|
169
|
+
{:name=>@share_data[1].split('|')[0], :path=>@share_data[1].split('|')[1]}
|
170
|
+
]
|
171
|
+
end
|
172
|
+
|
173
|
+
should 'return hosted share information via #get_hosted_shares' do
|
174
|
+
share_command = %q{nawk '{system("df -k | grep " $2)}' /usr/sbin/shares | nawk '{print $NF "|" $1}'}
|
175
|
+
|
176
|
+
@connector.stubs(:values_at).with(share_command).returns(@share_data)
|
177
|
+
|
178
|
+
@target.get_hosted_shares
|
179
|
+
assert_equal(@expected_data, @target.hosted_shares)
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
context 'for installed applications' do
|
184
|
+
setup do
|
185
|
+
@application_data = %q{
|
186
|
+
NAME: The Python interpreter, libraries and utilities
|
187
|
+
VERSION: 2.3.3
|
188
|
+
INSTDATE: Jan 1 2013 00:00
|
189
|
+
|
190
|
+
NAME: The Python interpreter, libraries and utilities - development files
|
191
|
+
VERSION: 2.3.3
|
192
|
+
BASEDIR: /usr
|
193
|
+
VENDOR: Oracle Corporation
|
194
|
+
INSTDATE: Jan 1 2013 00:00
|
195
|
+
}.strip.split(/\n/)
|
196
|
+
|
197
|
+
@expected_data = [
|
198
|
+
{
|
199
|
+
:date_installed=>DateTime.parse('Jan 1 2013 00:00'),
|
200
|
+
:install_location=>nil,
|
201
|
+
:license_key=>nil,
|
202
|
+
:name=>'The Python interpreter, libraries and utilities',
|
203
|
+
:vendor=>nil,
|
204
|
+
:version=>'2.3.3'
|
205
|
+
},
|
206
|
+
{
|
207
|
+
:date_installed=>DateTime.parse('Jan 1 2013 00:00'),
|
208
|
+
:install_location=>'/usr',
|
209
|
+
:license_key=>nil,
|
210
|
+
:name=>'The Python interpreter, libraries and utilities - development files',
|
211
|
+
:vendor=>'Oracle Corporation',
|
212
|
+
:version=>'2.3.3'
|
213
|
+
}
|
214
|
+
]
|
215
|
+
end
|
216
|
+
|
217
|
+
should 'return installed applications via #get_installed_applications' do
|
218
|
+
application_command = "pkginfo -il -c application | egrep -i '^$|(name|version|basedir|vendor|instdate):'"
|
219
|
+
|
220
|
+
@connector.stubs(:values_at).with(application_command).returns(@application_data)
|
221
|
+
|
222
|
+
@target.get_installed_applications
|
223
|
+
assert_equal(@expected_data, @target.installed_applications)
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
context 'for installed patches' do
|
228
|
+
setup do
|
229
|
+
@patch_dir_data = '143506-01|Jan 1 00:00:00 2013'
|
230
|
+
|
231
|
+
@patch_data = [
|
232
|
+
'143506-01|SUNWPython-devel',
|
233
|
+
'121671-01|SUNWPython'
|
234
|
+
]
|
235
|
+
|
236
|
+
@expected_data = [
|
237
|
+
{
|
238
|
+
:date_installed=>DateTime.parse(@patch_dir_data.split('|')[1]),
|
239
|
+
:installed_by=>nil,
|
240
|
+
:patch_code=>@patch_dir_data.split('|')[0]
|
241
|
+
},
|
242
|
+
]
|
243
|
+
end
|
244
|
+
|
245
|
+
should 'return installed patches via #get_installed_patches' do
|
246
|
+
patch_dir_command = %q{ls -ego /var/sadm/patch | grep -v '^total' | nawk '{print $NF "|" $4 " " $5 " " $6 " " $7}'}
|
247
|
+
|
248
|
+
@connector.stubs(:values_at).with(patch_dir_command).returns([@patch_dir_data])
|
249
|
+
|
250
|
+
@target.get_installed_patches
|
251
|
+
assert_equal(@expected_data, @target.installed_patches)
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
255
|
+
context 'for installed services' do
|
256
|
+
setup do
|
257
|
+
@expected_data = [
|
258
|
+
{:name=>'svc:/network/smtp:sendmail', :install_location=>nil, :start_mode=>nil},
|
259
|
+
{:name=>'svc:/network/ftp:default', :install_location=>nil, :start_mode=>nil}
|
260
|
+
]
|
261
|
+
end
|
262
|
+
|
263
|
+
should 'return service information via #get_installed_services' do
|
264
|
+
@connector.stubs(:values_at).with("svcs -a | nawk '{print $NF}'").returns(@expected_data.collect{|svc| svc[:name]})
|
265
|
+
|
266
|
+
@target.get_installed_services
|
267
|
+
assert_equal(@expected_data, @target.installed_services)
|
268
|
+
end
|
269
|
+
end
|
270
|
+
|
271
|
+
# handled by UNIX core
|
272
|
+
#context 'for local users and groups' do
|
273
|
+
#end
|
274
|
+
|
275
|
+
# handled by UNIX core
|
276
|
+
#context 'for network identification' do
|
277
|
+
#end
|
278
|
+
|
279
|
+
context 'for network interfaces' do
|
280
|
+
setup do
|
281
|
+
|
282
|
+
@dns_server_command = "cat /etc/resolv.conf | grep ^nameserver | awk '{print $2}'"
|
283
|
+
@dns_server_data = ['192.168.1.1', '192.168.1.2']
|
284
|
+
@connector.stubs(:values_at).with(@dns_server_command).returns(@dns_server_data)
|
285
|
+
|
286
|
+
@connector.stubs(:values_at).with(@showrev_command).returns(['Application architecture: sparc'])
|
287
|
+
|
288
|
+
@kstat_command = %q{/usr/bin/kstat -c net -p | egrep "ifspeed|link_(up|duplex|autoneg)" | nawk '{print $1 "|" $2}'}
|
289
|
+
|
290
|
+
@prtpicl_ethernet_command = %q{/usr/sbin/prtpicl -c network -v | egrep ':model|:driver-name|:instance|:local-mac-address|:vendor-id|:device-id|\(network' | nawk '{if ($0 ~ /\(network/) print ""; else {first=$1; $1=""; print first "|" $0}}'}
|
291
|
+
|
292
|
+
@fcinfo_command = %q{/usr/local/bin/sudo /usr/sbin/fcinfo hba-port | egrep -i "wwn|device name|model|manufacturer|driver name|state|current speed" | nawk '{$1=$1; if(tolower($1) ~ /^node/) print $0 "\n"; else print $0;}'}
|
293
|
+
|
294
|
+
@mac_mapping_command = %q{/usr/bin/netstat -pn | grep SP | nawk '{print $1 "|" $2 "|" toupper($5)}'}
|
295
|
+
|
296
|
+
@ifconfig_command = %q{/sbin/ifconfig -a | egrep 'flags|inet|zone' | nawk '{if($2~/^flags/ && $1!~/^(lo|dman|sppp)/) {current_line=$0; getline; {if($1!~/^zone/) {$1=$1; print current_line "\n" $0 "\n"}}}}'}
|
297
|
+
end
|
298
|
+
|
299
|
+
context 'in a standard three-interface setup' do
|
300
|
+
setup do
|
301
|
+
@connector.stubs(:values_at).with(@fcinfo_command).returns([])
|
302
|
+
@connector.stubs(:values_at).with(@zoneadm_command).returns(['global'])
|
303
|
+
|
304
|
+
@expected_ethernet_data = []
|
305
|
+
|
306
|
+
# this interface is fully online... standard setup with multiple ipv4/ipv6 addresses
|
307
|
+
@expected_ethernet_data << @target.network_interface_template.merge({
|
308
|
+
:auto_negotiate=>false,
|
309
|
+
:current_speed_mbps=>1000,
|
310
|
+
:dns_servers=>['192.168.1.1', '192.168.1.2'],
|
311
|
+
:duplex=>'full',
|
312
|
+
:ip_addresses=>[
|
313
|
+
{:ip_address=>'192.168.1.5', :subnet=>'255.255.255.0'},
|
314
|
+
{:ip_address=>'fe80::a00::ffff:ffff:1000/10', :subnet=>nil}
|
315
|
+
],
|
316
|
+
:mac_address=>'01:01:01:01:01:01',
|
317
|
+
:model=>'Unknown Ethernet Adapter',
|
318
|
+
:model_id=>'0x1234',
|
319
|
+
:mtu=>1500,
|
320
|
+
:name=>'e1000g0',
|
321
|
+
:status=>'up',
|
322
|
+
:type=>'ethernet',
|
323
|
+
:vendor=>'Unknown',
|
324
|
+
:vendor_id=>'0x1234'
|
325
|
+
})
|
326
|
+
|
327
|
+
# this interface has no physical connection but is configured to be up with ipv4 addresses...
|
328
|
+
# should report status as down with no ip or link data
|
329
|
+
@expected_ethernet_data << @target.network_interface_template.merge({
|
330
|
+
:dns_servers=>['192.168.1.1', '192.168.1.2'],
|
331
|
+
:mac_address=>'01:01:01:01:01:01',
|
332
|
+
:model=>'Unknown Ethernet Adapter',
|
333
|
+
:model_id=>'0x1234',
|
334
|
+
:name=>'nxge0',
|
335
|
+
:status=>'down',
|
336
|
+
:type=>'ethernet',
|
337
|
+
:vendor=>'Unknown',
|
338
|
+
:vendor_id=>'0x1234'
|
339
|
+
})
|
340
|
+
|
341
|
+
# this port has a physical connection but is not configured for use...
|
342
|
+
# should report status as down
|
343
|
+
@expected_ethernet_data << @expected_ethernet_data[1].merge({:name=>'ce0'})
|
344
|
+
end
|
345
|
+
|
346
|
+
should 'return ethernet information for both interfaces via #get_network_interfaces' do
|
347
|
+
@connector.stubs(:values_at).with(@prtpicl_fibre_command).returns([])
|
348
|
+
|
349
|
+
prtpicl_ethernet_data = %q{
|
350
|
+
:vendor-id|0x1234
|
351
|
+
:device-id|0x1234
|
352
|
+
:local-mac-address|01 01 01 01 01 01
|
353
|
+
:instance|0
|
354
|
+
:driver-name|e1000g
|
355
|
+
|
356
|
+
:vendor-id|0x1234
|
357
|
+
:device-id|0x1234
|
358
|
+
:local-mac-address|01 01 01 01 01 01
|
359
|
+
:instance|0
|
360
|
+
:driver-name|nxge
|
361
|
+
|
362
|
+
:vendor-id|0x1234
|
363
|
+
:device-id|0x1234
|
364
|
+
:local-mac-address|01 01 01 01 01 01
|
365
|
+
:instance|0
|
366
|
+
:driver-name|ce
|
367
|
+
}.strip.split(/\n/)
|
368
|
+
@connector.stubs(:values_at).with(@prtpicl_ethernet_command).returns(prtpicl_ethernet_data)
|
369
|
+
|
370
|
+
ifconfig_data = %q{
|
371
|
+
e1000g0: flags=123456<UP,BROADCAST,RUNNING,MULTICAST,DEPRECATED,IPv4,FIXEDMTU> mtu 1500 index 2
|
372
|
+
inet 192.168.1.5 netmask ffffff00 broadcast 192.168.1.255
|
373
|
+
|
374
|
+
e1000g0:1: flags=123456<UP,MULTICAST,IPv6> mtu 1500 index 2
|
375
|
+
inet6 fe80::a00::ffff:ffff:1000/10
|
376
|
+
|
377
|
+
nxge1: flags=123456<UP,BROADCAST,MULTICAST,IPv4> mtu 1500 index 3
|
378
|
+
inet 192.168.1.6 netmask ffffff00 broadcast 192.168.1.255
|
379
|
+
|
380
|
+
nxge1:1 flags=123456<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 3
|
381
|
+
inet 192.168.1.7
|
382
|
+
}.strip.split(/\n/)
|
383
|
+
@connector.stubs(:values_at).with(@ifconfig_command).returns(ifconfig_data)
|
384
|
+
|
385
|
+
kstat_data = %q{
|
386
|
+
e1000g:0:mac:ifspeed|1000000000
|
387
|
+
e1000g:0:mac:link_autoneg|0
|
388
|
+
e1000g:0:mac:link_duplex|2
|
389
|
+
e1000g:0:mac:link_up|1
|
390
|
+
nxge:0:mac:ifspeed|1000000000
|
391
|
+
nxge:0:mac:link_autoneg|1
|
392
|
+
nxge:0:mac:link_duplex|2
|
393
|
+
nxge:0:mac:link_up|0
|
394
|
+
ce:0:ce0:ifspeed|1000000000
|
395
|
+
ce:0:mac:link_autoneg|1
|
396
|
+
ce:0:mac:link_duplex|2
|
397
|
+
ce:0:mac:link_up|1
|
398
|
+
}.strip.split(/\n/)
|
399
|
+
@connector.stubs(:values_at).with(@kstat_command).returns(kstat_data)
|
400
|
+
|
401
|
+
mac_mapping_data = ['e1000g0|192.168.1.5|01:01:01:01:01:01', 'ce0|192.168.1.5|01:01:01:01:01:01']
|
402
|
+
@connector.stubs(:values_at).with(@mac_mapping_command).returns(mac_mapping_data)
|
403
|
+
|
404
|
+
@target.get_network_interfaces
|
405
|
+
assert_equal(@expected_ethernet_data, @target.network_interfaces)
|
406
|
+
end
|
407
|
+
end
|
408
|
+
|
409
|
+
context 'of a child zone' do
|
410
|
+
setup do
|
411
|
+
@connector.stubs(:values_at).with(@zoneadm_command).returns(['childzone'])
|
412
|
+
|
413
|
+
@expected_ethernet_data = [@target.network_interface_template.merge({
|
414
|
+
:current_speed_mbps=>1000,
|
415
|
+
:dns_servers=>['192.168.1.1', '192.168.1.2'],
|
416
|
+
:duplex=>'full',
|
417
|
+
:ip_addresses=>[{:ip_address=>'192.168.1.2', :subnet=>'255.255.255.0'}],
|
418
|
+
:mac_address=>'01:01:01:01:01:01',
|
419
|
+
:model=>'Virtual Ethernet Adapter',
|
420
|
+
:mtu=>1500,
|
421
|
+
:name=>'ce1',
|
422
|
+
:status=>'up',
|
423
|
+
:type=>'ethernet',
|
424
|
+
:vendor=>VENDOR_ORACLE
|
425
|
+
})]
|
426
|
+
end
|
427
|
+
|
428
|
+
should 'return ethernet information for an interface on a zone via #get_network_interfaces' do
|
429
|
+
@connector.stubs(:values_at).with(@fcinfo_command).returns([])
|
430
|
+
|
431
|
+
# a child zone may show the interfaces of the host via kstat, but not via ifconfig,
|
432
|
+
# so any active interfaces found in kstat should be ignored
|
433
|
+
ifconfig_data = %q{
|
434
|
+
ce1:1: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 3
|
435
|
+
inet 192.168.1.2 netmask ffffff00 broadcast 192.168.1.1
|
436
|
+
}.strip.split(/\n/)
|
437
|
+
@connector.stubs(:values_at).with(@ifconfig_command).returns(ifconfig_data)
|
438
|
+
|
439
|
+
kstat_data = %q{
|
440
|
+
ce:1:ce1:ifspeed|1000000000
|
441
|
+
ce:1:ce1:link_duplex|2
|
442
|
+
ce:1:ce1:link_up|1
|
443
|
+
e1000g:0:e1000g0:ifspeed|1000000000
|
444
|
+
e1000g:0:mac:ifspeed|1000000000
|
445
|
+
e1000g:0:mac:link_autoneg|1
|
446
|
+
e1000g:0:mac:link_duplex|2
|
447
|
+
e1000g:0:mac:link_up|1
|
448
|
+
}.strip.split(/\n/)
|
449
|
+
@connector.stubs(:values_at).with(@kstat_command).returns(kstat_data)
|
450
|
+
|
451
|
+
mac_mapping_data = ['ce1|192.168.1.2|01:01:01:01:01:01']
|
452
|
+
@connector.stubs(:values_at).with(@mac_mapping_command).returns(mac_mapping_data)
|
453
|
+
|
454
|
+
@target.get_network_interfaces
|
455
|
+
assert_equal(@expected_ethernet_data, @target.network_interfaces)
|
456
|
+
end
|
457
|
+
end
|
458
|
+
|
459
|
+
context 'in a fibre channel setup' do
|
460
|
+
setup do
|
461
|
+
@expected_fibre_data = [@target.network_interface_template.merge({
|
462
|
+
:current_speed_mbps=>4000,
|
463
|
+
:model=>'375-2200-xx',
|
464
|
+
:name=>'/dev/cfg/c1',
|
465
|
+
:node_wwn=>'00000000aaaaaaaa',
|
466
|
+
:port_wwn=>'00000000aaaaaaaa',
|
467
|
+
:status=>'up',
|
468
|
+
:type=>'fibre',
|
469
|
+
:vendor=>'QLogic Corp.',
|
470
|
+
})]
|
471
|
+
|
472
|
+
@connector.stubs(:values_at).with(@kstat_command).returns([])
|
473
|
+
@connector.stubs(:values_at).with(@mac_mapping_command).returns([])
|
474
|
+
@connector.stubs(:values_at).with(@ifconfig_command).returns([])
|
475
|
+
@connector.stubs(:values_at).with(@zoneadm_command).returns(['global'])
|
476
|
+
end
|
477
|
+
|
478
|
+
should 'return fibre interface information via #get_network_interfaces' do
|
479
|
+
fcinfo_data = %q{
|
480
|
+
HBA Port WWN: 00000000aaaaaaaa
|
481
|
+
OS Device Name: /dev/cfg/c1
|
482
|
+
Manufacturer: QLogic Corp.
|
483
|
+
Model: 375-2200-xx
|
484
|
+
Driver Name: qlc
|
485
|
+
State: online
|
486
|
+
Current Speed: 4Gb
|
487
|
+
Node WWN: 00000000aaaaaaaa
|
488
|
+
}.strip.split(/\n/)
|
489
|
+
@connector.stubs(:values_at).with(@fcinfo_command).returns(fcinfo_data)
|
490
|
+
|
491
|
+
@target.get_network_interfaces
|
492
|
+
assert_equal(@expected_fibre_data, @target.network_interfaces)
|
493
|
+
end
|
494
|
+
end
|
495
|
+
end
|
496
|
+
|
497
|
+
context 'for operating system information' do
|
498
|
+
setup do
|
499
|
+
@os_data = '5.10 Generic_1234567-89'
|
500
|
+
|
501
|
+
@expected_data = {
|
502
|
+
:date_installed=>DateTime.parse('Jan 1 2013'),
|
503
|
+
:features=>[],
|
504
|
+
:kernel=>@os_data.split[1],
|
505
|
+
:license_key=>nil,
|
506
|
+
:name=>'Oracle Solaris',
|
507
|
+
:roles=>[],
|
508
|
+
:service_pack=>nil,
|
509
|
+
:version=>@os_data.split[0]
|
510
|
+
}
|
511
|
+
end
|
512
|
+
|
513
|
+
should 'return operating system information via #get_operating_system' do
|
514
|
+
@connector.stubs(:value_at).with("ls -l /var/sadm/system/logs/install_log | nawk '{print $6" "$7" "$8'}").returns('Jan 1 2013')
|
515
|
+
@connector.stubs(:value_at).with('uname -rv').returns(@os_data)
|
516
|
+
|
517
|
+
@target.get_operating_system
|
518
|
+
assert_equal(@expected_data, @target.operating_system)
|
519
|
+
end
|
520
|
+
end
|
521
|
+
end
|
522
|
+
end
|
523
|
+
end
|