39 lines
986 B
Python
39 lines
986 B
Python
#!/usr/bin/env python3
|
|
"""Validate the system_info.json output."""
|
|
import json
|
|
import sys
|
|
|
|
def validate():
|
|
with open('/root/.hermes/wizard-outputs/spark/system_info.json') as f:
|
|
d = json.load(f)
|
|
|
|
errors = []
|
|
|
|
if 'hermes' not in d:
|
|
errors.append('missing hermes key')
|
|
else:
|
|
if 'profile' not in d['hermes']:
|
|
errors.append('missing hermes.profile')
|
|
elif d['hermes']['profile'] != 'spark':
|
|
errors.append(f"wrong profile: {d['hermes']['profile']}")
|
|
|
|
if 'timestamp' not in d:
|
|
errors.append('missing timestamp')
|
|
|
|
if 'platform' not in d:
|
|
errors.append('missing platform')
|
|
|
|
if 'node_id' not in d:
|
|
errors.append('missing node_id')
|
|
|
|
if errors:
|
|
for e in errors:
|
|
print(f"ERROR: {e}")
|
|
return False
|
|
|
|
print("VALIDATION PASSED")
|
|
return True
|
|
|
|
if __name__ == '__main__':
|
|
success = validate()
|
|
sys.exit(0 if success else 1) |