-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathserializers.py
81 lines (73 loc) · 2.15 KB
/
serializers.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
from haproxy import *
import json
class OptionJSON():
def __init__(self, oid, option):
odict = {
'id' : oid,
'name' : option.name,
'params' : option.params
}
self.json = json.dumps(odict)
def getJSON(self):
return self.json
class GlobalJSON():
def __init__(self, globalh):
oa = []
for index, opt in enumerate(globalh.options):
oj = OptionJSON(index, opt)
ojs = oj.json
ojs = json.loads(ojs)
oa.append(ojs)
gdict = {'options' : oa}
self.json = json.dumps(gdict)
def getJSON(self):
return self.json
class DefaultsJSON():
def __init__(self, defaults):
oa = []
for index, opt in enumerate(defaults.options):
oj = OptionJSON(index, opt)
ojs = oj.json
ojs = json.loads(ojs)
oa.append(ojs)
ddict = {'options': oa}
self.json = json.dumps(ddict)
class FrontendJSON():
def __init__(self, frontend):
oa = []
for index, opt in enumerate(frontend.options):
oj = OptionJSON(index, opt)
ojs = oj.json
ojs = json.loads(ojs)
oa.append(ojs)
fdict = {
'options': oa,
'name' : frontend.name
}
self.json = json.dumps(fdict)
class BackendJSON():
def __init__(self, backend):
oa = []
for index, opt in enumerate(backend.options):
oj = OptionJSON(index, opt)
ojs = oj.json
ojs = json.loads(ojs)
oa.append(ojs)
bdict = {
'options': oa,
'name': backend.name
}
self.json = json.dumps(bdict)
class ListenJSON():
def __init__(self, listen):
oa = []
for index, opt in enumerate(listen.options):
oj = OptionJSON(index, opt)
ojs = oj.json
ojs = json.loads(ojs)
oa.append(ojs)
ldict = {
'options': oa,
'name': listen.name
}
self.json = json.dumps(ldict)