forked from int32bit/openstack-cheat-sheet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
convert_cinder_matrix_from_json_to_markdown.py
executable file
·51 lines (39 loc) · 1.29 KB
/
convert_cinder_matrix_from_json_to_markdown.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
#!/usr/bin/env python3
#coding=utf-8
from collections import OrderedDict
import json
from pprint import pprint
target = 'cinder_matrix.json'
FIELDS = ["Driver",
"Volume",
"Snapshot",
"Clone",
"Replication",
"Consistency Group",
"Qos",
"Extend(扩容)"]
def _convert_to_md_row(fields):
return '|' + '|'.join(fields) + '|'
def _print_header(fields):
print(_convert_to_md_row(fields))
print(_convert_to_md_row(['----'] * len(fields)))
def do_convert(matrix_file='cinder_matrix.json'):
_print_header(FIELDS)
with open(matrix_file) as f:
drivers = json.load(f)
for driver in drivers:
name = driver['Driver']
volume = driver['Create Volume']
snapshot = driver['Create Snapshot']
clone = driver['Create Volume from Volume (Clone)']
replication = driver['Volume Replication']
cgroup = driver['Consistency Group']
qos = driver['QoS']
extend = driver['Extend Volume']
print(_convert_to_md_row([name, volume, snapshot,
clone, replication, cgroup,
qos, extend]))
def main():
do_convert()
if __name__ == "__main__":
main()