-
Notifications
You must be signed in to change notification settings - Fork 1
/
oort.rb
executable file
·2757 lines (2569 loc) · 86.3 KB
/
oort.rb
1
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env ruby
# Name: oort (Oracle OBP Reporting/Reetrieval Tool)
# Version: 1.1.6
# Release: 1
# License: CC-BA (Creative Commons By Attrbution)
# http://creativecommons.org/licenses/by/4.0/legalcode
# Group: System
# Source: N/A
# URL: http://lateralblast.com.au/
# Distribution: UNIX
# Vendor: Lateral Blast
# Packager: Richard Spindler <richard@lateralblast.com.au>
# Description: Ruby script to Grep Oracle firmware site
# http//www.oracle.com/technetwork/systems/patches/firmware/release-history-jsp-138416.html
# Install gems if they can't be loaded
def install_gem(gem_name)
if gem_name.match(/getopt/)
install_name = "getopt"
else
install_name = gem_name.gsub(/\//,"-")
end
puts "Information:\tInstalling #{install_name}"
%x[gem install #{install_name}]
Gem.clear_paths
require "#{gem_name}"
end
# Required gem list
gem_list = [ "rubygems", "nokogiri", "open-uri", "getopt/std", "fileutils", "find",
"selenium-webdriver", "mechanize", "terminal-table", "io/console" ]
# Try to load gems
for gem_name in gem_list
begin
require "#{gem_name}"
rescue LoadError
install_gem(gem_name)
end
end
# Extend string class to strip out control characters
class String
def strip()
self.chars.inject("") do |str, char|
if char.ascii_only? and char.ord.between?(32,126)
str << char
end
str
end
end
end
# Create some defaults
# - Work directory
# - Verbose comments (-v sets to 1)
# - Test mode (does not download, -b sets this to 1)
$script = File.basename($0,".rb").chomp
$work_dir = ""
$verbose = 0
$test_mode = 0
$output_mode = "text"
options = "CHV?abcghlvZA:E:F:I:M:N:P:R:S:X:d:e:f:i:j:m:n:o:p:q:r:s:t:w:x:z:"
$headless = true
# Set Work Directory
def set_work_dir()
if !$work_dir.match(/\//)
if $0.match(/^\./)
$work_dir = Dir.pwd+"/data"
else
$work_dir = File.dirname($0)+"/data"
end
end
$html_dir = $work_dir+"/html"
$readme_dir = $work_dir+"/readme"
$firmware_dir = $work_dir+"/firmware"
$handbook_dir = $work_dir+"/handbook"
return
end
set_work_dir()
# Handle output routine
def handle_output(output)
if $output_mode == "text"
puts output
end
if $output_mode == "file"
file = File.open($output_file,"a")
file.write(output)
file.write("\n")
file.close()
end
return
end
# Remove embedded email from downloaded HTML file
def remove_mos_email_from_file(output_file)
if File.exist?(output_file)
(mos_username,mos_password) = get_mos_details()
mos_head = mos_username.upcase.split("@")[0]
mos_tail = mos_username.upcase.split("@")[1]
array = []
lines = File.readlines(output_file)
if lines.to_s.match(/#{mos_head}/)
lines.each do |line|
if line.match(/#{mos_head}/)
line = line.gsub(/#{mos_head}/,"")
line = line.gsub(/#{mos_tail}/,"")
end
array.push(line)
end
File.delete(output_file)
file = File.open(output_file,"w")
array.each do |line|
file.puts line
end
file.close
end
end
return
end
# Search the M Series firmware page for information
# This requires the use of selenium and a web browser as none of the ruby
# modules seem to work with the MOS site
def search_xcp_fw_page(search_xcp)
base_url = "https://support.oracle.com/epmos/faces/ui/patch/PatchDetail.jspx?patchId="
xcp_url = "https://support.oracle.com/epmos/faces/DocContentDisplay?id=1002631.1"
output_file = $html_dir+"/xcp.html"
if !File.exist?(output_file)
get_mos_url(xcp_url,output_file)
end
remove_mos_email_from_file(output_file)
xcp_rel = ""
xcp_post = ""
obp_post = ""
xcp_date = ""
mseries = ""
obp_prom = ""
xcp_prom = ""
patch_url = ""
xcp_model = ""
xcp_done = []
["M3000","M4000","M5000","M8000","M9000"].each do |mseries|
eval("#{mseries}_txts=[]")
eval("#{mseries}_urls=[]")
end
doc = Nokogiri::HTML(File.open(output_file))
doc.css("td").each { |td| td.inner_html = td.inner_html.gsub(/\n/,'') }
doc.css("td").each { |td| td.inner_html = td.inner_html.gsub(/<br>/,' ') }
doc.css("td").each do |node|
if node.text
lines = node.text.split(/\n(XCP)/)
lines.each do |line|
if !line.match(/XCP\.tar|Release|Matrix|^XCP$/)
line = line.gsub(/\n/," ").gsub(/\s+/," ").gsub(/^ /,"").gsub(/EOL /,"").gsub(/POST |Post /,"").gsub(/ - /,"-")
if line.match(/^[0-9][0-9][0-9][0-9]/)
xcp_info = line.split(/ /)
xcp_rel = "XCP"+xcp_info[0]
xcp_post = xcp_info[3]
obp_post = xcp_info[4]
obp_prom = xcp_info[1]
xcp_prom = xcp_info[2]
xcp_month = xcp_info[6]
xcp_year = xcp_info[7]
if xcp_info[6] and xcp_info[7]
xcp_date = xcp_info[6..7].join(" ")
end
if line.match(/Patch/)
if !xcp_done.to_s.match(/#{xcp_rel}/)
model_info = line.split(/ #{xcp_year} /)[1]
model_info = model_info.split(/ Bug /)[0]
model_info = model_info.split(/M/)
model_info.each do |patch_info|
if patch_info.match(/ Patch /)
(mseries,patch_no) = patch_info.split(/ Patch /)
mseries = "M"+mseries
patch_no = patch_no.gsub(/ /,"")
patch_url = base_url+patch_no
xcp_text = xcp_rel+" "+obp_prom+" "+xcp_prom+" POST "+xcp_post+" "+obp_post+" "+mseries+" "+xcp_date
xcp_text = xcp_text.gsub(/\s+/," ").gsub(/ $/,"")
eval("#{mseries}_txts.push(xcp_text)")
eval("#{mseries}_urls.push(patch_url)")
end
end
xcp_done.push(xcp_rel)
end
else
xcp_model = xcp_info[5]
if !xcp_done.to_s.match(/#{xcp_rel}/) and line.match(/-/)
xcp_text = xcp_rel+" "+obp_prom+" "+xcp_prom+" POST "+xcp_post+" "+obp_post+" "+xcp_model+" "+xcp_date
xcp_text = xcp_text.gsub(/\s+/," ").gsub(/ $/,"")
if xcp_model.match(/M3000/) and !xcp_model.match(/M3000\-/)
mseries = "M3000"
eval("#{mseries}_txts.push(xcp_text)")
eval("#{mseries}_urls.push(xcp_url)")
end
if xcp_model.match(/M3000\-M9000/)
["M3000","M4000","M5000","M8000","M9000"].each do |mseries|
eval("#{mseries}_txts.push(xcp_text)")
eval("#{mseries}_urls.push(xcp_url)")
end
end
if xcp_model.match(/M4000\-M9000/)
["M4000","M5000","M8000","M9000"].each do |mseries|
eval("#{mseries}_txts.push(xcp_text)")
eval("#{mseries}_urls.push(xcp_url)")
end
end
if xcp_model.match(/M5000\-M9000/)
["M5000","M8000","M9000"].each do |mseries|
eval("#{mseries}_txts.push(xcp_text)")
eval("#{mseries}_urls.push(xcp_url)")
end
end
if xcp_model.match(/M8000\-M9000/)
["M8000","M9000"].each do |mseries|
eval("#{mseries}_txts.push(xcp_text)")
eval("#{mseries}_urls.push(xcp_url)")
end
xcp_done.push(xcp_rel)
end
end
end
end
end
end
end
end
fw_text = {}
fw_urls = {}
["M3000","M4000","M5000","M8000","M9000"].each do |mseries|
fw_text[mseries] = eval("#{mseries}_txts")
fw_urls[mseries] = eval("#{mseries}_urls")
end
return fw_urls,fw_text
end
# Code to search patchdiag.xref for older V series (and other) firmware information
def search_prom_fw_page(search_model,url)
base_url = "https://support.oracle.com/epmos/faces/ui/patch/PatchDetail.jspx?patchId="
urls = []
txts = []
model = ""
fw_urls = {}
fw_text = {}
model_list = [ "CT900", "CP3220", "CP3250", "CP3260", "CP3270", "T31BA",
"V440", "V445", "V440", "V480", "V490", "V880", "V890",
"V125", "U45", "U25", "T6320", "T6340", "B2500", "B1500", "LTO6",
"T6300", "V42", "T5120", "T5220", "T5240", "T1000", "T2000", "L7",
"V215", "V245", "V210", "V240", "E6900", "E4900", "E2900", "LTO2",
"E6800", "E4800", "E3000", "E4000", "E5000", "E6000", "E3500",
"E4500", "E5500", "E6500", "E4810", "E3800", "V1280", "V100",
"X1", "U1", "U2", "U1E", "U30", "U5", "U80", "E220R", "E280R",
"E250", "E450", "D2", "T1", "E420R", "X1", "B100", "B150", "SL48",
"T10000A", "L280", "DLT4000", "DDS3", "L11000", "DLT7000", "SL24",
"L1800", "L1000", "DLT8000", "L3500", "DDS4", "Ultrium1", "LTO4",
"SLXX", "353D", "Z68S", "Y68S", "23DS", "E4J0", "33ES", "T10000B",
"J3ES", "E4J0", "X69S", "I6BW", "Z68W", "I6BS", "W61W", "W62W",
"H6EW", "B63W", "L180", "L700", "66K8", "G69S", "L6HS", "M6BS",
"B63S", "H67S", "C7Q0", "C7QH", "H.70", "F.20", "DAT72", "M63Z",
"S63D", "F6CZ", "L63Z", "S63Z", "G63Z", "V51", "V43", "G67D",
"FC420", "SDLT600", "F63D", "SDLT320", "Ultrium2", "SDLT220",
"SDLT320", "V1613", "DLT4700", "LTO", "LTO3", "LTO2V", "LTO6HH",
"LTO5HH", "LTO3HH", "L25", "L100" ]
doc=open_patchdiag_xref()
if not search_model.match(/T[3-9]\-[0-9]|M[6-9]\-[0-9]/)
search_model = search_model.gsub(/\-/,"")
end
if search_model == "all"
prom_info = doc.grep(/PROM:|Tape/)
else
if not search_model.match(/T[3-9]\-[0-9]|M[6-9]\-[0-9]|X[3-9]\-[0-9]/)
prom_info = doc.grep(/[#{search_model}|x00]/).grep(/PROM:|Tape/)
else
prom_info = doc.grep(/PROM:|Tape/)
end
end
if prom_info.to_s.match(/[A-z]/)
prom_info.each do |line|
if !line.downcase.match(/withdrawn|obsolete|cpld|fem/)
line = line.chomp
line = line.split("|")
patch_no = line[0]+"-"+line[1]
if line.to_s.match(/PROM/)
patch_text = line[10].split(/PROM: /)[1..-1].join
else
patch_text = line[10]
end
patch_text = patch_text.gsub(/t1 /,"T1 ")
patch_text = patch_text.gsub(/Drive-/,"")
patch_text = patch_text.gsub(/DDS\-/,"DDS")
patch_text = patch_text.gsub(/LTO\-/,"LTO")
patch_text = patch_text.gsub(/Ultrium\-/,"Ultrium")
patch_text = patch_text.gsub(/6800\/4800\/4810i\/3800/,"E6800 E4800 E4810 E3800 ")
patch_text = patch_text.gsub(/Sun Blade 100\/150 /,"B100 B150 ")
patch_text = patch_text.gsub(/Sun Blade 1500 /,"B1500 ")
patch_text = patch_text.gsub(/Sun Blade 2500 /,"B2500 ")
patch_text = patch_text.gsub(/Ultra 2 /,"U2 ")
patch_text = patch_text.gsub(/Enterprise 450 /,"E450 ")
patch_text = patch_text.gsub(/Sun Enterprise 3x00\/4x00\/5x00\/6x00/,"E3000 E4000 E5000 E6000 E3500 E4500 E5500 E6500 E3800 E4800 E6800 E4900 E6900")
patch_text = patch_text.gsub(/Enterprise 250 /,"E250 ")
patch_text = patch_text.gsub(/Ultra 25 /,"U25 ")
patch_text = patch_text.gsub(/Ultra 45 /,"U45 ")
patch_text = patch_text.gsub(/Ultra 1E /,"U1E ")
patch_text = patch_text.gsub(/Ultra 1 /,"U1 ")
patch_text = patch_text.gsub(/Ultra 30 /,"U30 ")
patch_text = patch_text.gsub(/Ultra 60 /,"U60 ")
patch_text = patch_text.gsub(/Ultra 80 /,"U80 ")
model_info = patch_text
patch_url = base_url+patch_no
if search_model == "all" or patch_text.downcase.match(/#{search_model.downcase} |#{search_model.downcase}$|#{search_model.downcase}\,|#{search_model.downcase}\//)
doc = open_patch_readme(patch_no)
if doc[1]
doc.each do |readme_line|
check_strings = [ "ILOM", "Hostconfig", "Hypervisor", "OpenBoot",
"POST", "OBP", "System Firmware", "ScApp",
"PROM", "RTOS", "FCode", "Tape" ]
readme_line = readme_line.chomp
readme_line = readme_line.lstrip
check_strings.each do |check_string|
if readme_line.match(/#{check_string} /) and readme_line.match(/[0-9]\.[0-9]/)
check_info = readme_line.split(/#{check_string} /)[1]
end
if readme_line.match(/#{check_string}_/) and readme_line.match(/[0-9]\.[0-9]/)
check_info = readme_line.split(/#{check_string}_/)[1]
end
if readme_line.match(/#{check_string}:/) and readme_line.match(/[0-9]\.[0-9]/)
check_info = readme_line.split(/#{check_string}:/)[1]
end
if check_info
if check_info.match(/,/)
check_info = check_info.split(/,/)[0]
end
if check_info.match(/:/)
check_info = check_info.split(/:/)[0]
end
if check_info.match(/ /)
check_info = check_info.split(/ /)[0]
end
if !patch_text.match(/#{check_string}/) and check_info.match(/[0-9]\.[0-9]/)
patch_text = patch_text+" "+check_string+" "+check_info
end
end
end
end
urls.push(patch_url)
txts.push(patch_text)
model_list.each do |model_no|
if patch_text.match(/#{model_no} |#{model_no}$|#{model_no}\/|#{model_no}\,/)
if model_no.match(/V480/)
fw_urls["480R"] = urls
fw_text["480R"] = txts
end
fw_urls[model_no] = urls
fw_text[model_no] = txts
end
end
#urls = []
#txts = []
#models = []
end
end
end
end
end
return fw_urls,fw_text
end
# Code to search patchdiag.xref for disk firmware information
def search_disk_fw_page(search_model,url)
base_url = "https://support.oracle.com/epmos/faces/ui/patch/PatchDetail.jspx?patchId="
urls = []
txts = []
model = ""
fw_urls = {}
fw_text = {}
doc=open_patchdiag_xref()
if search_model == "all"
disk_info = doc.grep(/Disk/)
else
disk_info = doc.grep(/#{search_model}/)
end
if disk_info.to_s.match(/[A-z]/)
disk_info.each do |line|
line = line.split("|")
patch_no = line[0]+"-"+line[1]
doc = open_patch_readme(patch_no)
if doc[1]
doc.each do |readme_line|
patch_text = line[10].chomp
patch_url = base_url+patch_no
readme_line = readme_line.chomp
if readme_line.match(/\.fw/)
readme_line = readme_line.gsub(/^\s+/,'')
readme_line = readme_line.gsub(/,/,'')
if readme_line.match(/\s+/)
fw_info = readme_line.split(/\s+/)
if fw_info[0].match(/fw$/) and fw_info[0].match(/^[A-Z]/)
fw_info = fw_info[0].split(/\./)
model = fw_info[0]
fw_rev = fw_info[1]
if patch_text.match(/[A-z]/) and model.match(/[A-z]|[0-9]/)
urls.push(patch_url)
patch_text = patch_text+" ("+fw_rev+")"
txts.push(patch_text)
fw_urls[model] = urls
fw_text[model] = txts
urls = []
txts = []
end
end
end
end
end
end
end
end
return fw_urls,fw_text
end
# This code searches two places for firmware information:
# - Qlogic site (later 8Gb models)
# - patchdiag.xref for older HBAs
def search_qlogic_fw_page(search_model,url)
base_url = "https://support.oracle.com/epmos/faces/ui/patch/PatchDetail.jspx?patchId="
#qf8_url = "http://driverdownloads.qlogic.com/QLogicDriverDownloads_UI/SearchByProductOracle.aspx?oemid=124&productid=928&OSTYPE=Solaris&category=3"
qf8_url = "https://driverdownloads.qlogic.com/QLogicDriverDownloads_UI/SearchByOs.aspx?ProductCategory=39&OsCategory=5&Os=22&OsCategoryName=Solaris&ProductCategoryName=Fibre%20Channel%20Adapters&OSName=Solaris%20SPARC"
fw_text = {}
fw_urls = {}
fw_version = ""
qf8_file = "qf8.html"
# Information from Sun System Handbook
hba_info = {}
hba_info["SG-XPCIEFCGBE-Q8-Z"] = "8Gb/sec PCI Express Dual FC / Dual Gigabit Ethernet Host Adapter ExpressModule, QLogic"
hba_info["SG-XPCIE2FC-QB4-Z"] = "4Gb/sec PCI Express Dual Fibre Channel ExpressModule Host Adapter, QLogic"
hba_info["SG-XPCIE2FCGBE-Q-Z"] = "4Gb/sec PCI Express Dual FC / Dual Gigabit Ethernet ExpressModule Host Adapter, QLogic"
hba_info["SG-XPCI2FC-QF4-Z"] = "4Gb PCI-X Dual FC Host Adapter"
hba_info["SG-XPCIE1FC-QF8-Z"] = "8Gigabit/Sec PCI Express Single FC Host Adapter"
hba_info["SG-XPCIE2FC-QF8-Z"] = "8Gigabit/Sec PCI Express Dual FC Host Adapter"
hba_info["SG-XPCI1FC-QF4-Z"] = "4Gb PCI-X Single FC Host Adapter"
hba_info["SG-XPCIE1FC-QF4-Z"] = "4Gigabit/Sec PCI Express Single FC Host Adapter"
hba_info["SG-XPCIE2FC-QF4-Z"] = "4Gigabit/Sec PCI Express Dual FC Host Adapter"
urls = []
txts = []
search_list = []
doc = open_patchdiag_xref()
if search_model.match(/all/)
hba_info.each do |model|
model = model[0]
if model.match(/[A-z]/)
search_list.push(model)
end
end
else
search_list[0] = "#{search_model}"
end
search_list.each do |model|
patch_no = ""
if model.match(/2$|2-Z$|4$|4-Z$|Q$|Q-Z$|all/)
if model.match(/XPCI1FC-QF2|all/)
patch_no = "114873"
end
if model.match(/XPCI2FC-QF2|XPCI2FC-QF2|XPCI1FC-QL2|all/)
patch_no = "114874"
end
if model.match(/QF4|QB4|Q$|Q-Z$/)
patch_no = "123305"
end
end
text=hba_info[model]
if !model.match(/QF8|Q8/)
if patch_no.match(/^[0-9]/)
doc = open_patchdiag_xref()
patch_info = doc.grep(/^#{patch_no}/)
patch_info = patch_info[0].split("|")
patch_no = patch_info[0]+"-"+patch_info[1]
doc = open_patch_readme(patch_no)
fcode_info = doc.grep(/Unbundled Release/)
fcode_info = fcode_info[0].split(": ")
fcode_info = fcode_info[1].gsub(%r{</?[^>]+?>}, '').chomp
patch_url = base_url+patch_no
text = text+" "+fcode_info
end
else
# Fetch file and process locally
if search_model.match(/all|8$/)
get_url(qf8_url,qf8_file)
doc = Nokogiri::HTML(File.open(qf8_file))
node = doc.css('table tr').each do |node|
if node.text.match(/#{model}/)
fw_version = node.text.split(/This Preload Table/)[0].split(/\s+/)[-1]
end
end
end
text = text+" Firmware Version "+fw_version
patch_url = qf8_url
end
txts.push(text)
urls.push(patch_url)
fw_urls[model] = urls
fw_text[model] = txts
urls = []
txts = []
end
return fw_urls,fw_text
end
# If a ~/,mospasswd doesn't exist ask for details
def get_mos_details()
mos_passwd_file = Dir.home+"/.mospasswd"
if !File.exist?(mos_passwd_file)
puts "Enter MOS Username:"
STDOUT.flush
mos_username = gets.chomp
puts "Enter MOS Password:"
STDOUT.flush
mos_password = STDIN.noecho(&:gets).chomp
create_mos_passwd_file(mos_username,mos_password)
else
mos_data = File.readlines(mos_passwd_file)
mos_data.each do |line|
line.chomp
if line.match(/http-user/)
mos_username = line.split(/\=/)[1].chomp
end
if line.match(/http-password/)
mos_password = line.split(/\=/)[1].chomp
end
end
end
return mos_username,mos_password
end
# Search patchdiag.xref for latest version of patch
def get_patch_full_id(patch_no)
if !patch_no.match(/-/)
doc = open_patchdiag_xref()
patch_no = doc.grep(/^#{patch_no}/)
patch_no = patch_no.join.split("|")
patch_no = patch_no[0]+"-"+patch_no[1]
end
return patch_no
end
# Search patchdiag.xref
def search_patchdiag_ref(search_string)
doc = open_patchdiag_xref()
result = doc.grep(/#{search_string}/)
return result
end
# If given a patch number generate the URL and download it
def get_patch_file(patch_no,output_file)
base_url = "https://getupdates.oracle.com/all_unsigned/"
patch_no = get_patch_full_id(patch_no)
if !output_file.match(/[A-z]/)
output_file = $work_dir+"/"+patch_no+".zip"
end
url = base_url+patch_no+".zip"
get_download(url,output_file)
end
# Open a patch README and put it into an array
def open_patch_readme(patch_no)
doc = ""
patch_no = get_patch_full_id(patch_no)
output_file = $readme_dir+"/README."+patch_no
get_patch_readme(patch_no,output_file)
if File.exist?(output_file)
remove_mos_email_from_file(output_file)
doc = IO.readlines(output_file)
else
if $verbose == 1
puts "README does not exist for: "+patch_no
end
end
return doc
end
# Get header for handbook file
def get_handbook_header(model)
model = model.gsub(/M2$/,"_M2")
case model
when /X[2,4][0-9][0-9][0-9]/
header = "SunFire"+model
when /^N/
header = "Netra_"+model.gsub(/^N/,"")
when /^V|K$/
header = "SunFire"+model
when /X6[0-9][0-9][0-9]|X8[0-9][0-9][0-9]|T6[0-9][0-9][0-9]/
header = "SunBlade"+model
when /T3-|T4-|T5-|M10-|M5-|M6-/
header = "SPARC_"+model
when /X[3,4][-,_]/
header = "Sun_Server_"+model
when /O[3,4][-,_]/
header = "ODA_"+model.gsub(/^O/,"X")
when /ULTRA[0-9]/
header = "U"+model
when /E[3,4,6]8[1,0]0/
header = "SunFire"+model.gsub(/E/,"")
when /SUNBLADE[0-9]/
header = "SunBlade"+model.gsub(/SUNBLADE/,"")
when /B[0-9]/
header = "SunBlade"+model.gsub(/B/,"")
when /T[1,2,5][0-9][0-9][0-9]|M[3,4,5,8,9]000/
header = "SE_"+model
when /X2-4/
header = "SunFireX4470_M2"
when /X3-4/
header = "SunFireX4470_M3"
when /X3-2$/
header = "SunFireX4170_M3"
when /X3-2L/
header = "SunFireX4270_M3"
else
header = model
end
header = header.gsub(/-/,"_")
return header
end
# Handle handbook info file
def process_handbook_info_file(info_file)
if File.exist?(info_file)
doc = Nokogiri::HTML(File.open(info_file))
facts = doc.css("table")[3]
info = facts.css("tr")[4..-1]
title = ""
items = {}
titles = []
info.each do |node|
if node.to_s.match(/\<b\>[A-z]/) and !node.to_s.match(/Quick Facts/)
title = node.css("b").text.gsub(/\n/,"").gsub(/\s+/," ").gsub(/\[tm\]/,"").gsub(/Operating Environment Versions/,"")
titles.push(title)
items[title] = []
if title
if node.to_s.match(/http/)
url = node.css("a").to_s.split(/"/)[1]
items[title].push(url)
else
text = node.css("td")[1..-1].text.gsub(/^\n/,"").gsub(/^\s+|\s+$/,"").gsub(/ \s+/," ").gsub(/Oracle /,"")
items[title].push(text)
end
end
end
end
table = Terminal::Table.new :title => "Support Information", :headings => [ 'Item', 'Value' ]
length = titles.length
index = 0
titles.each_with_index do |title,index|
content = ""
items[title].each do |item|
content = items[title].join(" ")
end
row = [ title, content ]
table.add_row(row)
if index < length-1
table.add_separator
end
end
handle_output(table)
handle_output("\n")
handle_output("\n")
end
return
end
# Handle handbook spec file
def process_handbook_spec_file(spec_file)
if File.exist?(spec_file)
doc = Nokogiri::HTML(File.open(spec_file))
tables = doc.css("table")
title = ""
t_table = ""
item = ""
value = ""
counter = 0
t_end = 0
tables.each do |table|
if !table.to_s.match(/Oracle System Handbook|Current Systems|Former STK Products|EOL Systems|Components|General Info|Cancel/)
rows = table.css("td")
rows.each do |row|
t_row = []
if row.to_s.match(/name/) and row.to_s.match(/sshtablecaption/) and !row.to_s.match(/label[A-z]/)
title = row.css("b").text.gsub(/\n/,"").gsub(/\s+/," ")
if title.match(/[A-z]/)
if t_table
handle_output(t_table)
handle_output("\n")
t_end = 0
end
if title == "Rack Mounting" or title == "Power Supplies"
t_table = Terminal::Table.new :title => title
else
t_table = Terminal::Table.new :title => title, :headings => [ 'Item', 'Value' ]
counter = 0
end
end
else
if title
if title.match(/[A-z]/)
if row.to_s.match(/[A-z]/) and !row.to_s.match(/label[A-z]/)
text = row.text.gsub(/^\n|\t/,"").gsub(/\s+/," ").gsub(/^\s+/,"")
if !text.match(/^x4$|^x8$|^[0-9]$|^x16$/)
length = text.length
if length > 70
text = text.gsub(/(.{1,78})(\s+|\Z)/, "\\1\n")
end
if counter == 0
if !row.next_element.to_s.match(/[A-z]/) and t_end == 0
t_row = [ text ]
t_table.add_row(t_row)
else
if title == "Rack Mounting"
if text.match(/Drive/)
t_end = 1
end
t_row = [ text ]
if t_end == 0
t_table.add_row(t_row)
end
else
item = text
counter = 1
end
end
else
if t_end == 0
value = text
counter = 0
t_row = [ item, value ]
t_table.add_row(t_row)
end
end
end
end
end
end
end
end
end
end
if t_table
handle_output(t_table)
handle_output("\n")
end
end
return
end
# Process handbook components file
def process_handbook_list_file(list_file)
if File.exist?(list_file)
doc = Nokogiri::HTML(File.open(list_file))
tables = doc.css("table")
title = ""
notes = []
t_table = ""
tables.each do |table|
rows = table.css("tr")
rows.each do |row|
counter = 0
if row.to_s.match(/name/)
title = row.css("a").text
if !title.match(/Oracle System Handbook|Cancel|Table Legend|Exploded View/) and title.match(/[A-z]/)
if t_table
handle_output(t_table)
handle_output("\n")
end
t_table = Terminal::Table.new :title => title, :headings => ['Option Part', 'Manufacturing Part', 'Description', 'Previous Part']
counter = 0
end
else
if title
if !title.match(/Oracle System Handbook|Cancel|Table Legend|Exploded View/) and title.match(/[A-z]/)
if !row.to_s.match(/Manufacturing Part#|Not Shown|Field Replaceable Unit/)
t_row = []
if counter > 1
if t_table
t_table.add_separator
end
else
counter = counter + 1
end
supported = "-"
current = "-"
description = "-"
previous = "-"
row.css("td").each do |cell|
case cell.to_s
when /ssh_supported|ssh_xop|ssh_expcode/
supported = cell.text.gsub(/\n/,"").gsub(/^\s+|\s+$/,"")
when /ssh_mfpart|ssh_exppart/
current = cell.text.gsub(/\n/,"").gsub(/^\s+|\s+$/,"")
when /ssh_desc|ssh_expdesc/
description = cell.text.gsub(/\n/,"").gsub(/^\s+|\s+$/,"")
when /ssh_pre/
previous = cell.text.gsub(/\n/,"").gsub(/^\s+|\s+$/,"")
when /ssh_note/
notes.push(cell.text)
end
end
if t_table
t_row = [ supported, current, description, previous ]
if t_row.to_s.match(/[0-9]/)
t_table.add_row(t_row)
end
end
else
row.css("td").each do |cell|
case cell.to_s
when /ssh_note/
notes.push(cell.text)
end
end
end
else
row.css("td").each do |cell|
case cell.to_s
when /ssh_note/
notes.push(cell.text)
end
end
end
end
end
end
end
if t_table
handle_output(t_table)
handle_output("\n")
end
if notes[0]
notes.each do |note|
if note.match(/^[0-9] |[0-9][0-9] /)
note = note.gsub(/^\n/,"")
length = note.length
if length > 75
note = note.gsub(/\. /,".\n")
end
length = note.length
if length > 75
note = note.gsub(/\, /,".\n")
end
handle_output(note)
end
end
handle_output("\n")
end
end
return
end
# Get server list from html
def get_model_list_from_html(file_name,model_list)
if File.exist?(file_name)
doc = Nokogiri::HTML(File.open(file_name))
nodes = doc.css("table").css("a")
nodes.each do |node|
text = node.text
if text.match(/SPARC|Server|Blade|Netra|Appliance|Machine|modular|Sun|Oracle/) and !text.match(/SPARCcenter|[S,s]torage|StorEdge|[S,s]tation|Netra [i,s,f,c,x,C,t]|Ultra 1\/|Tek|Ray|Cobalt|ETL|Gate/)
text = text.gsub(/ M2/,"M2").gsub(/ M3/,"M3")
if text.match(/\n|\(/)
text = text.split(/\n/)[0]
text = text.split(/\(/)[0]
end
info = text.split(/\s+/)
model = info.grep(/[0-9]/)[0]
if model
if model.match(/[A-Z]|[0-9]/)
if text.match(/Blade|modular/)
if !model.match(/^[A-Z]/)
model = "B"+model
end
end
if text.match(/Sun Fire|Enterprise/)
if !model.match(/^[A-Z]/)
if model.match(/^[3,4,5,6][5,8,9][0,1]0|10000/)
model = "E"+model
end
end
end
if text.match(/Netra/)
if !model.match(/^N/)
model = "N"+model
end
end
model = model.gsub(/\//,"").gsub(/T31B/,"T3-1B").gsub(/T41B/,"T4-1B").gsub(/Enterprise/,"")
if !model.match(/^A|^C|^N[0-9][0-9]$|Sun-/)
model_list.push(model)
end
end
end
end
end
end
return model_list
end
# Get handbook model list
def get_handbook_model_list()
model_list = []
current_url = "https://support.oracle.com/handbook_private/Systems/index.html"
current_file = $handbook_dir+"/current.html"
legacy_url = "https://support.oracle.com/handbook_private/Systems/eolSystemList.html"
legacy_file = $handbook_dir+"/legacy.html"
get_download(current_url,current_file)
get_download(legacy_url,legacy_file)
model_list = get_model_list_from_html(current_file,model_list)
model_list = get_model_list_from_html(legacy_file,model_list)
return model_list
end
# Process handbook
def process_oracle_handbook(model,download_only)
if !File.directory?($handbook_dir) and !File.symlink?($handbook_dir)
Dir.mkdir($handbook_dir)
end
model_list = []
if model == "all"
model_list = get_handbook_model_list()
else
model_list[0] = model
end
model_list.each do |model|
model = model.upcase
header = get_handbook_header(model)
model_dir = $handbook_dir+"/"+header
if !File.directory?(model_dir)
Dir.mkdir(model_dir)
end
base_url = "https://support.oracle.com/handbook_private/Systems"
model_url = base_url+"/"+header
info_file = model_dir+"/"+header+".html"
info_url = model_url+"/"+header+".html"
spec_file = model_dir+"/spec.html"
spec_url = model_url+"/spec.html"
list_file = model_dir+"/components.html"
list_url = model_url+"/components.html"
small_image_url = model_url+"/images/"+header+".jpg"
small_image_file = model_dir+"/"+header+".jpg"
front_thumb_url = model_url+"/images/"+header+"_front_thumb.jpg"
front_thumb_file = model_dir+"/"+header+"_front_thumb.jpg"
top_thumb_url = model_url+"/images/"+header+"_top_thumb.jpg"
top_thumb_file = model_dir+"/"+header+"_top_thumb.jpg"
rear_thumb_url = model_url+"/images/"+header+"_rear_thumb.jpg"
rear_thumb_file = model_dir+"/"+header+"_rear_thumb.jpg"
front_zoom_url = model_url+"/images/"+header+"_front_zoom.jpg"
front_zoom_file = model_dir+"/"+header+"_front_zoom.jpg"
rear_zoom_url = model_url+"/images/"+header+"_rear_zoom.jpg"
rear_zoom_file = model_dir+"/"+header+"_rear_zoom.jpg"
top_zoom_url = model_url+"/images/"+header+"_top_zoom.jpg"
top_zoom_file = model_dir+"/"+header+"_top_zoom.jpg"
get_download(info_url,info_file)
get_download(spec_url,spec_file)
get_download(list_url,list_file)
if download_only == "yes"
get_download(small_image_url,small_image_file)
get_download(front_thumb_url,top_thumb_file)
get_download(rear_thumb_url,rear_thumb_file)
get_download(front_zoom_url,front_zoom_file)
get_download(rear_zoom_url,rear_zoom_file)
get_download(top_zoom_url,top_zoom_file)
end
if download_only == "no"
process_handbook_info_file(info_file)
process_handbook_spec_file(spec_file)
process_handbook_list_file(list_file)
end
end