Increase timeout for member stop
[integration/test.git] / csit / scripts / generate_dashVis.py
1 # SPDX-License-Identifier: EPL-1.0
2 ##############################################################################
3 # Copyright (c) 2018 The Linux Foundation and others.
4 #
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Eclipse Public License v1.0
7 # which accompanies this distribution, and is available at
8 # http://www.eclipse.org/legal/epl-v10.html
9 ##############################################################################
10 import yaml
11 import copy
12
13 import json
14
15 # Pretty Printer
16
17
18 def p(x):
19     print(json.dumps(x, indent=4, sort_keys=False))
20
21
22 class panelsJSON:
23     def __init__(self):
24         self.content = {
25             'gridData': {
26                 'h': None,
27                 'i': None,
28                 'w': None,
29                 'x': None,
30                 'y': None
31             },
32             'id': None,
33             'panelIndex': None,
34             'type': 'visualization',
35             'version': '6.2.4'
36         }
37
38         self.counter = 0
39
40     def create(self, co_ords, id):
41         self.counter += 1
42         temp = copy.deepcopy(self.content)
43         temp['gridData']['h'] = co_ords['h']
44         temp['gridData']['i'] = str(self.counter)
45         temp['gridData']['w'] = co_ords['w']
46         temp['gridData']['x'] = co_ords['x']
47         temp['gridData']['y'] = co_ords['y']
48
49         temp['id'] = id
50         temp['panelIndex'] = str(self.counter)
51
52         return temp
53
54
55 def generate(viz_config):
56     dash = panelsJSON()
57     viz = [dash.create(i['co_ords'], i['id']) for _, i in viz_config.items()]
58     return viz
59
60
61 if __name__ == '__main__':
62     with open('dashboard.yaml', 'r') as f:
63         config = yaml.safe_load(f)
64         p(generate(config['dashboard']['viz']))