This repository has been archived by the owner on Jul 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
mor.py
executable file
·3347 lines (3113 loc) · 115 KB
/
mor.py
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/python
import json
import os
import sys
import datetime
import subprocess
import platform
import argparse
import socket
import importlib
import hashlib
import re
import shlex
import logging
import multiprocessing
try:
raw_input # Python 2
PYTHON3 = False
except NameError: # Python 3
raw_input = input
PYTHON3 = True
if PYTHON3:
import subprocess
else:
import commands
# Start the clock
start_time_date = datetime.datetime.now()
# This script version, independent from the JSON versions
MOR_VERSION = "1.63"
# GIT URLs
GITREPOURL = "https://github.com/IBM/SpectrumScale_ECE_OS_READINESS"
GITREPOURL_TUNED = "https://github.com/IBM/SpectrumScale_ECE_tuned_profile"
GITREPOURL_STORAGE_TOOL = "https://github.com/IBM/SpectrumScale_ECE_STORAGE_READINESS"
# Colorful constants
RED = '\033[91m'
GREEN = '\033[92m'
YELLOW = '\033[93m'
NOCOLOR = '\033[0m'
# Message labels
INFO = "[ " + GREEN + "INFO" + NOCOLOR + " ] "
WARNING = "[ " + YELLOW + "WARN" + NOCOLOR + " ] "
ERROR = "[ " + RED + "FATAL" + NOCOLOR + " ] "
# Get hostname for output on screen
LOCAL_HOSTNAME = platform.node().split('.', 1)[0]
# Regex patterns
SASPATT = re.compile('.*"SAS address"\s*:\s*"0x(?P<sasaddr>.*)"')
WWNPATT = re.compile('.*"WWN"\s*:\s*"(?P<wwn>.*)"')
OSVERPATT = re.compile('(?P<major>\d+)[\.](?P<minor>\d+)[\.].*')
PCIPATT = re.compile('(?P<pciaddr>[a-fA-f0-9]{2}:[a-fA-f0-9]{2}[\.][0-9])'
'[\ ](?P<pcival>.*)')
# Next are python modules that need to be checked before import
if platform.processor() != 's390x':
try:
import dmidecode
except ImportError:
if PYTHON3:
sys.exit(
ERROR +
LOCAL_HOSTNAME +
" cannot import dmidecode, please check python3-dmidecode" +
" is installed")
else:
sys.exit(
ERROR +
LOCAL_HOSTNAME +
" cannot import dmidecode, please check python-dmidecode" +
" is installed")
if PYTHON3:
try:
import distro
except ImportError:
sys.exit(
ERROR +
LOCAL_HOSTNAME +
" cannot import distro, please check python3-distro" +
" is installed")
try:
import ethtool
except ImportError:
if PYTHON3:
sys.exit(
ERROR +
LOCAL_HOSTNAME +
" cannot import ethtool, please check python3-ethtool is installed")
else:
sys.exit(
ERROR +
LOCAL_HOSTNAME +
" cannot import ethtool, please check python-ethtool is installed")
# devnull redirect destination
DEVNULL = open(os.devnull, 'w')
# Define expected MD5 hashes of JSON input files
HW_REQUIREMENTS_MD5 = "cde42d073fd4339197f33f0a8ddb7824"
NIC_ADAPTERS_MD5 = "00412088e36bce959350caea5b490001"
PACKAGES_MD5 = "a15b08b05998d455aad792ef5d3cc811"
SAS_ADAPTERS_MD5 = "4c28f6f00ccd6639bfa00318e2b51256"
SUPPORTED_OS_MD5 = "dfa2260da176cf3f62782851a8bb50cc"
# Functions
def set_logger_up(output_dir, log_file, verbose):
if os.path.isdir(output_dir) == False:
try:
os.makedirs(output_dir)
except BaseException:
sys.exit(
ERROR +
LOCAL_HOSTNAME +
" Cannot create " +
output_dir
)
log_format = '%(asctime)s %(levelname)-4s:\t %(message)s'
logging.basicConfig(level=logging.DEBUG,
format=log_format,
filename=log_file,
filemode='w')
console = logging.StreamHandler()
if verbose:
console.setLevel(logging.DEBUG)
else:
console.setLevel(logging.INFO)
console.setFormatter(logging.Formatter(log_format))
logging.getLogger('').addHandler(console)
log = logging.getLogger("MOR")
return log
def parse_arguments():
parser = argparse.ArgumentParser()
parser.add_argument(
'--FIPS',
action='store_true',
dest='fips',
help='Does not run parts of the code that cannot run on FIPS systems. ' +
'The run with this parameter is not complete and cannot be used for acceptance.',
default=False)
parser.add_argument(
'--ip',
required=True,
action='store',
dest='ip_address',
help='Local IP address linked to device used for NSD',
metavar='IPv4_ADDRESS',
type=str,
default="NO IP")
parser.add_argument(
'--path',
action='store',
dest='path',
help='Path where JSON files are located. Defaults to local directory',
metavar='PATH/',
type=str,
default='./')
parser.add_argument(
'--no-cpu-check',
action='store_false',
dest='cpu_check',
help='Does not run CPU checks',
default=True)
parser.add_argument(
'--no-md5-check',
action='store_false',
dest='md5_check',
help='Does not check MD5 of JSON files',
default=True)
parser.add_argument(
'--no-mem-check',
action='store_false',
dest='mem_check',
help='Does not run memory checks',
default=True)
parser.add_argument(
'--no-os-check',
action='store_false',
dest='os_check',
help='Does not run OS checks',
default=True)
parser.add_argument(
'--no-packages-check',
action='store_false',
dest='packages_ch',
help='Does not run packages checks',
default=True)
parser.add_argument(
'--no-net-check',
action='store_false',
dest='net_check',
help='Does not run network checks',
default=True)
parser.add_argument(
'--no-storage-check',
action='store_false',
dest='storage_check',
help='Does not run storage checks',
default=True)
parser.add_argument(
'--no-tuned-check',
action='store_false',
dest='tuned_check',
help='Does not run tuned checks',
default=True)
parser.add_argument(
'--allow_sata',
action='store_true',
dest='sata_on',
help='EXPERIMENTAL: To do checks on SATA drives. Do NOT use for real checks',
default=False)
parser.add_argument(
'--toolkit',
action='store_true',
dest='toolkit_run',
help='To indicate is being run from Spectrum Scale install toolkit',
default=False)
parser.add_argument(
'-V',
'--version',
action='version',
version='IBM Spectrum Scale Erasure Code Edition OS readiness ' +
'version: ' + MOR_VERSION)
parser.add_argument(
'-v',
'--verbose',
action='store_true',
dest='is_verbose',
help='Shows debug messages on console',
default=False)
args = parser.parse_args()
return (args.fips,
args.ip_address,
args.path,
args.cpu_check,
args.md5_check,
args.mem_check,
args.os_check,
args.packages_ch,
args.storage_check,
args.net_check,
args.tuned_check,
args.sata_on,
args.toolkit_run,
args.is_verbose)
def load_json(json_file_str):
# Loads JSON into a dictionary or quits the program if it cannot.
try:
with open(json_file_str, "r") as json_file:
json_dict = json.load(json_file)
return json_dict
except BaseException:
sys.exit(
ERROR +
LOCAL_HOSTNAME +
" cannot open or parse JSON file: '" +
json_file_str +
"'. Please check the file exists and has JSON format")
def md5_chksum(json_file_str):
# Files are small not doing chunks
try:
md5_hash = (hashlib.md5(open(json_file_str, 'rb').read()).hexdigest())
return md5_hash
except BaseException:
sys.exit(
ERROR +
LOCAL_HOSTNAME +
" cannot create MD5 sum of file: " +
json_file_str)
def md5_verify(md5_check, json_file_str, md5_hash_real, md5_hash_expected):
# Compare expected MD5 with real one and print message if OK and message
# plus exit if not OK
if md5_hash_real == md5_hash_expected:
# print(INFO + LOCAL_HOSTNAME +
# " MD5 hash verified for " + json_file_str)
return True
elif md5_check:
sys.exit(
ERROR +
LOCAL_HOSTNAME +
" MD5 hash failed to verify file: " +
json_file_str)
else:
print(
WARNING +
LOCAL_HOSTNAME +
" MD5 hash failed to verify file: " +
json_file_str)
return False
def convert_to_bytes(size, unit):
unit_dict = { "KB":10**3, "MB":10**6,"GB":10**9, "TB":10**12, "KiB":2**10, "MiB":2**20, "GiB":2**30, "TiB": 2**40 }
size_in_bytes = -1
if unit in unit_dict.keys():
size_in_bytes = size * unit_dict[unit]
return size_in_bytes
def show_header(moh_version, json_version, toolkit_run):
print(
INFO +
LOCAL_HOSTNAME +
" IBM Spectrum Scale Erasure Code Edition OS readiness version " +
moh_version)
if not toolkit_run:
print(
INFO +
LOCAL_HOSTNAME +
" This tool comes with absolute not warranty")
print(
INFO +
LOCAL_HOSTNAME +
" Please check " + GITREPOURL + " for details")
print(INFO + LOCAL_HOSTNAME + " JSON files versions:")
print(
INFO +
LOCAL_HOSTNAME +
" \tsupported OS:\t\t" +
json_version['supported_OS'])
print(
INFO +
LOCAL_HOSTNAME +
" \tpackages: \t\t" +
json_version['packages'])
print(
INFO +
LOCAL_HOSTNAME +
" \tSAS adapters:\t\t" +
json_version['SAS_adapters'])
print(
INFO +
LOCAL_HOSTNAME +
" \tNIC adapters:\t\t" +
json_version['NIC_adapters'])
print(
INFO +
LOCAL_HOSTNAME +
" \tHW requirements:\t" +
json_version['HW_requirements'])
def rpm_is_installed(rpm_package):
# returns the RC of rpm -q rpm_package or quits if it cannot run rpm
try:
return_code = subprocess.call(
['rpm', '-q', rpm_package], stdout=DEVNULL, stderr=DEVNULL)
except BaseException:
sys.exit(ERROR + LOCAL_HOSTNAME + " cannot run rpm")
return return_code
def is_IP_address(ip):
# Lets check is a full ip by counting dots
if ip.count('.') != 3:
return False
try:
socket.inet_aton(ip)
return True
except Exception:
return False
def list_net_devices():
# This works on Linux only
# net_devices = os.listdir('/sys/class/net/')
net_devices = ethtool.get_active_devices()
return net_devices
def what_interface_has_ip(net_devices, ip_address):
fatal_error = True
for device in net_devices:
try:
device_ip = ethtool.get_ipaddr(str(device))
except BaseException:
continue
if device_ip != ip_address:
fatal_error = True
else:
fatal_error = False
print(
INFO +
LOCAL_HOSTNAME +
" the IP address " +
ip_address +
" is found on device " +
device)
return fatal_error, device
print(
ERROR +
LOCAL_HOSTNAME +
" cannot find interface with IP address " +
ip_address)
return fatal_error, "NONE"
def check_NIC_speed(net_interface, min_link_speed):
fatal_error = False
device_speed = 0
try:
if PYTHON3:
ethtool_out = subprocess.getoutput(
'ethtool ' + net_interface + ' | grep "Speed:"').split()
else:
ethtool_out = commands.getoutput(
'ethtool ' + net_interface + ' | grep "Speed:"').split()
device_speed = ''.join(ethtool_out[1].split())
device_speed = device_speed[:-4]
device_speed = device_speed[-6:]
if int(device_speed) > min_link_speed:
print(
INFO +
LOCAL_HOSTNAME +
" interface " +
net_interface +
" has a link of " +
device_speed +
" Mb/s. Which is supported to run ECE")
else:
print(
ERROR +
LOCAL_HOSTNAME +
" interface " +
net_interface +
" has a link of " +
device_speed +
" Mb/s. Which is not supported to run ECE")
fatal_error = True
except BaseException:
fatal_error = True
print(
ERROR +
LOCAL_HOSTNAME +
" cannot determine link speed on " +
net_interface +
". Is the link up?")
return fatal_error, device_speed
def check_root_user():
effective_uid = os.getuid()
if effective_uid == 0:
print(
INFO +
LOCAL_HOSTNAME +
" the tool is being run as root")
else:
sys.exit(ERROR +
LOCAL_HOSTNAME +
" this tool needs to be run as root\n")
def packages_check(packages_dictionary):
# Checks if packages from JSON are installed or not based on the input
# data ont eh JSON
errors = 0
print(INFO + LOCAL_HOSTNAME + " checking packages install status")
for package in packages_dictionary.keys():
if platform.processor() == 's390x' and package == 'dmidecode':
continue
if package != "json_version":
current_package_rc = rpm_is_installed(package)
expected_package_rc = packages_dictionary[package]
if current_package_rc == expected_package_rc:
print(
INFO +
LOCAL_HOSTNAME +
" installation status of " +
package +
" is as expected")
else:
print(
WARNING +
LOCAL_HOSTNAME +
" installation status of " +
package +
" is *NOT* as expected")
errors = errors + 1
return(errors)
def get_system_serial():
# For now we do OS call, not standarized output on python dmidecode
fatal_error = False
system_serial = "00000000"
if platform.processor() == 's390x': # No serial# checking on s390x
return fatal_error, system_serial
try:
if PYTHON3:
system_serial = subprocess.getoutput(
"dmidecode -s system-serial-number"
)
else:
system_serial = commands.getoutput(
"dmidecode -s system-serial-number"
)
except BaseException:
fatal_error = True
print(
WARNING +
LOCAL_HOSTNAME +
" cannot query system serial"
)
return fatal_error, system_serial
def check_processor():
fatal_error = False
print(INFO + LOCAL_HOSTNAME + " checking processor compatibility")
current_processor = platform.processor()
if current_processor == 'x86_64' or current_processor == 's390x':
print(
INFO +
LOCAL_HOSTNAME +
" " +
current_processor +
" processor is supported to run ECE")
else:
print(
ERROR +
LOCAL_HOSTNAME +
" " +
current_processor +
" processor is not supported to run ECE")
fatal_error = True
return fatal_error, current_processor
def check_sockets_cores(min_socket, amd_socket, min_cores, AMD_min_cores):
fatal_error = False
cores = []
if platform.processor() != 's390x':
print(INFO + LOCAL_HOSTNAME + " checking socket count")
sockets = dmidecode.processor()
for socket in sockets.keys():
socket_version = sockets[socket]['data']['Version'].decode()
if "AMD" in socket_version:
is_AMD = True
pattern_EPYC_1st_gen = re.compile(r'EPYC\s\d{3}1')
is_EPYC_1st_gen = pattern_EPYC_1st_gen.search(socket_version)
if is_EPYC_1st_gen:
fatal_error = True
print(ERROR + LOCAL_HOSTNAME + " AMD EPYC 1st Generation (Naples) is not supported by ECE")
else:
is_AMD = False
num_sockets = len(sockets)
if is_AMD:
min_socket = amd_socket
min_cores = AMD_min_cores
print(
INFO +
LOCAL_HOSTNAME +
" this system is AMD based"
)
else:
print(
INFO +
LOCAL_HOSTNAME +
" this system is Intel based"
)
if num_sockets != min_socket:
print(
ERROR +
LOCAL_HOSTNAME +
" this system has " +
str(num_sockets) +
" socket[s] which is not " +
str(min_socket) +
" socket[s] required to support ECE")
fatal_error = True
else:
print(
INFO +
LOCAL_HOSTNAME +
" this system has " +
str(num_sockets) +
" socket[s] which complies with the number of " +
str(min_socket) +
" socket[s] required to support ECE")
print(INFO + LOCAL_HOSTNAME + " checking core count")
if platform.processor() == 's390x':
cores = core_count = multiprocessing.cpu_count()
num_sockets = min_socket
if core_count < min_cores:
print(
ERROR +
LOCAL_HOSTNAME +
" has " +
str(core_count) +
" core[s] which is less than " +
str(min_cores) +
" cores required to run ECE")
fatal_error = True
else:
print(
INFO +
LOCAL_HOSTNAME +
" has " +
str(core_count) +
" core[s] which copmplies with " +
str(min_cores) +
" cores required to support ECE")
else:
for socket in sockets.keys():
core_count = sockets[socket]['data']['Core Count']
# For socket but no chip installed
if core_count == "None":
core_count = 0
if core_count is None:
core_count = 0
cores.append(core_count)
if core_count < min_cores:
print(
ERROR +
LOCAL_HOSTNAME +
" socket " +
str(socket) +
" has " +
str(core_count) +
" core[s] which is less than " +
str(min_cores) +
" cores per socket required to run ECE")
fatal_error = True
else:
print(
INFO +
LOCAL_HOSTNAME +
" socket " +
str(socket) +
" has " +
str(core_count) +
" core[s] which complies with " +
str(min_cores) +
" cores per socket required to support ECE")
return fatal_error, num_sockets, cores
def check_memory(min_gb_ram):
fatal_error = False
print(INFO + LOCAL_HOSTNAME + " checking memory")
# Total memory
if platform.processor() == 's390x':
meminfo = dict((i.split()[0].rstrip(':'),int(i.split()[1])) for i in open('/proc/meminfo').readlines())
mem_kib = meminfo['MemTotal'] # e.g. 3921852
mem_gb = round(mem_kib / 1024 / 1024, 2)
else:
mem_b = os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES')
mem_gb = mem_b / 1024**3
if mem_gb < min_gb_ram:
print(
ERROR +
LOCAL_HOSTNAME +
" total memory is less than " +
str(min_gb_ram) +
" GB required to run ECE")
fatal_error = True
else:
print(
INFO +
LOCAL_HOSTNAME +
" total memory is " +
str(mem_gb) +
" GB, which is sufficient to run ECE")
# Memory DIMMs
if platform.processor() == 's390x': # no dims on s390x
dimms = 0
num_dimms = 0
empty_dimms = 0
main_memory_size = 0
else:
dimms = {}
m_slots = dmidecode.memory()
for slot in m_slots.keys():
# Avoiding 'System Board Or Motherboard'. Need more data
if m_slots[slot]['data']['Error Information Handle'] == 'Not Provided':
continue
try:
dimms[m_slots[slot]['data']['Locator']] = m_slots[slot]['data']['Size']
except BaseException:
continue
empty_dimms = 0
num_dimms = len(dimms)
dimm_size = {}
for dimm in dimms.keys():
if dimms[dimm] is None:
empty_dimms = empty_dimms + 1
elif dimms[dimm] == "NO DIMM":
empty_dimms = empty_dimms + 1
else:
dimm_size[dimm] = dimms[dimm]
if empty_dimms > 0:
print(
WARNING +
LOCAL_HOSTNAME +
" not all " +
str(num_dimms) +
" DIMM slot[s] are populated. This system has " +
str(empty_dimms) +
" empty DIMM slot[s]. This is not optimal if NVMe devices are used")
else:
print(INFO + LOCAL_HOSTNAME + " all " + str(num_dimms) +
" DIMM slot[s] are populated. This is recommended when NVMe devices are used")
dimm_memory_size = []
for dimm in dimm_size.keys():
dimm_memory_size.append(dimm_size[dimm])
main_memory_size = unique_list(dimm_memory_size)
if len(main_memory_size) == 1:
print(
INFO +
LOCAL_HOSTNAME +
" all populated DIMM slots have same memory size")
else:
print(
ERROR +
LOCAL_HOSTNAME +
" all populated DIMM slots do not have same memory sizes")
fatal_error = True
return fatal_error, mem_gb, dimms, num_dimms, empty_dimms, main_memory_size
def unique_list(inputlist):
outputlist = []
for item in inputlist:
if item not in outputlist:
outputlist.append(item)
return outputlist
def check_os_redhat(os_dictionary):
redhat8 = False
fatal_error = False
# Check redhat-release vs dictionary list
redhat_distribution = platform.linux_distribution()
version_string = redhat_distribution[1]
if platform.dist()[0] == "centos":
try:
matchobj = re.match(OSVERPATT, version_string)
version_string = "{}.{}".format(matchobj.group('major'),
matchobj.group('minor'))
except AttributeError:
pass
redhat_distribution_str = redhat_distribution[0] + \
" " + version_string
if version_string.startswith("8."):
redhat8 = True
error_message = ERROR + LOCAL_HOSTNAME + " " + \
redhat_distribution_str + " is not a supported OS to run ECE\n"
try:
if os_dictionary[redhat_distribution_str] == 'OK':
print(
INFO +
LOCAL_HOSTNAME +
" " +
redhat_distribution_str +
" is a supported OS to run ECE")
elif os_dictionary[redhat_distribution_str] == 'WARN':
print(
WARNING +
LOCAL_HOSTNAME +
" " +
redhat_distribution_str +
" is a clone OS that is not officially supported" +
" to run ECE." +
" See Spectrum Scale FAQ for restrictions.")
else:
sys.exit(error_message)
fatal_error = True
except BaseException:
sys.exit(error_message)
fatal_error = True
return fatal_error, redhat_distribution_str, redhat8
def get_json_versions(
os_dictionary,
packages_dictionary,
SAS_dictionary,
NIC_dictionary,
HW_dictionary):
# Gets the versions of the json files into a dictionary
json_version = {}
# Lets see if we can load version, if not quit
try:
json_version['supported_OS'] = os_dictionary['json_version']
except BaseException:
sys.exit(
ERROR +
LOCAL_HOSTNAME +
" cannot load version from supported OS JSON")
try:
json_version['packages'] = packages_dictionary['json_version']
except BaseException:
sys.exit(
ERROR +
LOCAL_HOSTNAME +
" cannot load version from packages JSON")
try:
json_version['SAS_adapters'] = SAS_dictionary['json_version']
except BaseException:
sys.exit(ERROR + LOCAL_HOSTNAME + " cannot load version from SAS JSON")
try:
json_version['NIC_adapters'] = NIC_dictionary['json_version']
except BaseException:
sys.exit(ERROR + LOCAL_HOSTNAME + " cannot load version from SAS JSON")
try:
json_version['HW_requirements'] = HW_dictionary['json_version']
except BaseException:
sys.exit(ERROR + LOCAL_HOSTNAME + " cannot load version from HW JSON")
# If we made it this far lets return the dictionary. This was being stored
# in its own file before
return json_version
def check_NVME():
fatal_error = False
print(INFO + LOCAL_HOSTNAME + " checking NVMe devices")
try:
nvme_devices = os.listdir('/sys/class/nvme/')
num_nvme_devices = len(nvme_devices)
if num_nvme_devices == 0:
print(WARNING + LOCAL_HOSTNAME + " no NVMe devices detected")
fatal_error = True
else:
print(
INFO +
LOCAL_HOSTNAME +
" has " +
str(num_nvme_devices) +
" NVMe device[s] detected")
except BaseException:
num_nvme_devices = 0
print(WARNING + LOCAL_HOSTNAME + " no NVMe devices detected")
fatal_error = True
return fatal_error, num_nvme_devices
def check_NVME_packages(packages_ch):
fatal_error = False
nvme_packages = {"nvme-cli": 0}
if packages_ch:
print(INFO +
LOCAL_HOSTNAME +
" checking that needed software for NVMe is installed")
nvme_packages_errors = packages_check(nvme_packages)
if nvme_packages_errors:
fatal_error = True
return fatal_error
def check_SAS_packages(packages_ch):
fatal_error = False
sas_packages = {"storcli": 0}
if packages_ch:
print(INFO +
LOCAL_HOSTNAME +
" checking that needed software for SAS is installed")
sas_packages_errors = packages_check(sas_packages)
if sas_packages_errors:
fatal_error = True
return fatal_error
def check_NVME_disks():
# If we run this we already check elsewhere that there are NVme drives
fatal_error = False
try:
if PYTHON3:
drives_raw = subprocess.getoutput("nvme list -o json")
else:
drives_raw = commands.getoutput("nvme list -o json")
drives_dict = {}
drives_size_list = []
drives = json.loads(drives_raw)
for single_drive in drives['Devices']:
drives_dict[single_drive['Index']] = [single_drive['DevicePath'],
single_drive['ModelNumber'],
single_drive['PhysicalSize'],
single_drive['Firmware'],
single_drive['SerialNumber']]
drives_size_list.append(single_drive['PhysicalSize'])
drives_unique_size = unique_list(drives_size_list)
if len(drives_unique_size) == 1:
print(
INFO +
LOCAL_HOSTNAME +
" all NVMe devices have the same size")
else:
# fatal_error = True
print(
WARNING +
LOCAL_HOSTNAME +
" not all NVMe devices have the same size")
except BaseException:
fatal_error = True
print(
WARNING +
LOCAL_HOSTNAME +
" cannot query NVMe devices"
)
return fatal_error, drives_dict
def check_NVME_log_home(drives_dict, size):
log_home_found = False
for drive in drives_dict.keys():
if int(drives_dict[drive][2]) >= size:
log_home_found = True
break
return log_home_found
def check_NVME_ID(drives_dict):
fatal_error = False
nvme_id_dict = {}
eui_list = []
nguid_list = []
duplicates = 0
eui_zero = '0000000000000000'
nguid_zero = '00000000000000000000000000000000'
for drive_index in drives_dict.keys():
drive = drives_dict[drive_index][0]
try:
if PYTHON3:
eui = subprocess.getoutput("nvme id-ns " + drive + " | grep 'eui64' | awk '{print$3}'")
nguid = subprocess.getoutput("nvme id-ns " + drive + " | grep 'nguid' | awk '{print$3}'")
else:
eui = commands.getoutput("nvme id-ns " + drive + " | grep 'eui64' | awk '{print$3}'")
nguid = commands.getoutput("nvme id-ns " + drive + " | grep 'nguid' | awk '{print$3}'")
except BaseException:
fatal_error = True
print(
WARNING +
LOCAL_HOSTNAME +
" cannot query IDs on NVMe device " +
drive
)
if str(eui) != eui_zero and str(eui) in eui_list:
duplicates = duplicates + 1
else:
eui_list.append(str(eui))
if str(nguid) != nguid_zero and str(nguid) in nguid_list:
duplicates = duplicates + 1
else:
nguid_list.append(str(nguid))
nvme_id_dict[drive] = [eui, nguid]
if fatal_error == False:
if duplicates > 0:
fatal_error = True
print(
ERROR +