|
| 1 | +#!/usr/bin/env python3 |
| 2 | +# |
| 3 | +# Adjusts the testnet monitor dashboard for the specified release channel |
| 4 | +# |
| 5 | + |
| 6 | +import sys |
| 7 | +import json |
| 8 | + |
| 9 | +if len(sys.argv) != 3: |
| 10 | + print('Error: Dashboard or Channel not specified') |
| 11 | + sys.exit(1) |
| 12 | + |
| 13 | +dashboard_json = sys.argv[1] |
| 14 | +channel = sys.argv[2] |
| 15 | +if channel not in ['edge', 'beta', 'stable']: |
| 16 | + print('Error: Unknown channel:', channel) |
| 17 | + sys.exit(2) |
| 18 | + |
| 19 | +with open(dashboard_json, 'r') as read_file: |
| 20 | + data = json.load(read_file) |
| 21 | + |
| 22 | +if channel == 'stable': |
| 23 | + # Stable dashboard only allows the user to select between the stable |
| 24 | + # testnet databases |
| 25 | + data['title'] = 'Testnet Monitor' |
| 26 | + data['uid'] = 'testnet' |
| 27 | + data['templating']['list'] = [{'allValue': None, |
| 28 | + 'current': {'text': 'testnet', |
| 29 | + 'value': 'testnet'}, |
| 30 | + 'hide': 1, |
| 31 | + 'includeAll': False, |
| 32 | + 'label': 'Testnet', |
| 33 | + 'multi': False, |
| 34 | + 'name': 'testnet', |
| 35 | + 'options': [{'selected': False, |
| 36 | + 'text': 'testnet', |
| 37 | + 'value': 'testnet'}, |
| 38 | + {'selected': True, |
| 39 | + 'text': 'testnet-perf', |
| 40 | + 'value': 'testnet-perf'}], |
| 41 | + 'query': 'testnet,testnet-perf', |
| 42 | + 'type': 'custom'}] |
| 43 | +else: |
| 44 | + # Non-stable dashboard only allows the user to select between all testnet |
| 45 | + # databases |
| 46 | + data['title'] = 'Testnet Monitor ({})'.format(channel) |
| 47 | + data['uid'] = 'testnet-' + channel |
| 48 | + data['templating']['list'] = [{'allValue': None, |
| 49 | + 'current': {'text': 'testnet', |
| 50 | + 'value': 'testnet'}, |
| 51 | + 'datasource': 'Solana Metrics (read-only)', |
| 52 | + 'hide': 1, |
| 53 | + 'includeAll': False, |
| 54 | + 'label': 'Testnet', |
| 55 | + 'multi': False, |
| 56 | + 'name': 'testnet', |
| 57 | + 'options': [], |
| 58 | + 'query': 'show databases', |
| 59 | + 'refresh': 1, |
| 60 | + 'regex': 'testnet.*', |
| 61 | + 'sort': 1, |
| 62 | + 'tagValuesQuery': '', |
| 63 | + 'tags': [], |
| 64 | + 'tagsQuery': '', |
| 65 | + 'type': 'query', |
| 66 | + 'useTags': False}] |
| 67 | + |
| 68 | +with open(dashboard_json, 'w') as write_file: |
| 69 | + json.dump(data, write_file, indent=2) |
0 commit comments