Skip to content

Instantly share code, notes, and snippets.

@kvisle
Created March 12, 2021 08:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kvisle/720ac51a9922576c052528e62585051d to your computer and use it in GitHub Desktop.
Save kvisle/720ac51a9922576c052528e62585051d to your computer and use it in GitHub Desktop.
#!/usr/bin/python
import subprocess
import re
import sys
sups = [
{'sup':'02.01.0013','bios':'SE5C620.86B.02.01.0013','me':'04.01.04.423','bmc':'2.48.CE3E3BD2','sdr':'1.45'},
{'sup':'02.01.0012','bios':'SE5C620.86B.02.01.0012','me':'04.01.04.381','bmc':'2.48.89B32E0D','sdr':'1.45'},
{'sup':'02.01.0011','bios':'SE5C620.86B.02.01.0011','me':'04.01.04.339','bmc':'2.42.D0B788A4','sdr':'1.44'},
{'sup':'02.01.0010','bios':'SE5C620.86B.02.01.0010','me':'04.01.04.339','bmc':'2.37.1F190479','sdr':'1.43'},
{'sup':'02.01.0009','bios':'SE5C620.86B.02.01.0009','me':'04.01.04.323','bmc':'2.22.59C3B83A','sdr':'1.41'},
{'sup':'02.01.0008','bios':'SE5C620.86B.02.01.0008','me':'04.01.04.251','bmc':'1.93.870CF4F0','sdr':'1.39'},
{'sup':'00.01.0016','bios':'SE5C620.86B.00.01.0016','me':'04.00.04.393','bmc':'1.90.0CF6E935','sdr':'1.39'},
{'sup':'00.01.0014','bios':'SE5C620.86B.00.01.0014','me':'04.00.04.340','bmc':'1.60.56','sdr':'1.37'},
{'sup':'00.01.0013; 1.43.91','bios':'SE5C620.86B.00.01.0013','me':'04.00.04.294','bmc':'1.43.91F76955','sdr':'1.30'},
{'sup':'00.01.0013; 1.43.66','bios':'SE5C620.86B.00.01.0013','me':'04.00.04.294','bmc':'1.43.660A4315','sdr':'1.30'}
]
res = subprocess.check_output(['syscfg','/i']).split('\n')
versions = {}
for line in res:
if line.startswith('BIOS Version'):
versions['bios'] = line[26:]
if line.startswith(' Op Code'):
versions['bmc'] = line[26:]
if line.startswith('ME Firmware Version'):
versions['me'] = line[26:].lower()
if line.startswith('SDR Version'):
versions['sdr'] = line[38:]
aspects = ['bios','me','bmc','sdr']
ages = {}
for aspect in aspects:
ages[aspect] = {'age':0, 'matched': False}
for sup in sups:
for aspect in aspects:
if not ages[aspect]['matched']:
if versions[aspect] == sup[aspect]:
ages[aspect]['matched'] = True
else:
ages[aspect]['age'] += 1
oldest = None
youngest = None
for aspect in aspects:
if not oldest or ages[aspect]['age'] > ages[oldest]['age']:
oldest = aspect
if not youngest or ages[aspect]['age'] < ages[youngest]['age']:
youngest = aspect
if ages[oldest]['age'] >= len(sups):
print("At least one FW version is unknown to this tool.")
sys.exit(3)
if ages[oldest]['age'] != ages[youngest]['age']:
print("Firmware discrepency detected. Reflash sup version " + sups[ages[oldest]['age']]['sup'])
sys.exit(2)
if ages[oldest]['age'] > 5:
print("You are far behind on FW updates. Get cracking." + sups[ages[oldest]['age']]['sup'])
sys.exit(2)
if ages[oldest]['age'] > 0:
print("You are behind, but only by " + ages[oldest]['age'] + " revisions. Flashing mostly safe here.")
sys.exit(1)
if ages[oldest]['age'] == 0:
print("You are running the latest firmware-releases we know.")
sys.exit(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment