summaryrefslogtreecommitdiff
path: root/lib/model.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/model.py')
-rw-r--r--lib/model.py20
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/model.py b/lib/model.py
index 933d901..1d1c605 100644
--- a/lib/model.py
+++ b/lib/model.py
@@ -1,6 +1,7 @@
from xml.etree.ElementTree import ElementTree
from lib.config import Config
+from lib.core import Answer, AnswerValue, AnswerAdminValue
class Network():
"""A simple network definition"""
@@ -12,26 +13,25 @@ class Network():
self.ip_blocks = []
self.data = {}
- def as_dict(self, data):
+ def as_answer(self, data):
# Beautify
- result = {}
+ result = Answer()
domains = data.get_domains()
persons = data.get_persons()
- result['name'] = self.name
+ result.add_value(AnswerValue(0, 'Name', self.name))
# Domains
- result['domains'] = []
for d in self.domains:
- result['domains'].append(domains[d])
+ result.add_value(AnswerValue(1, 'Domain', domains[d].name))
+
+ # Networks
+ for block in self.ip_blocks:
+ result.add_value(AnswerValue(1, 'Network', block))
# Admins
- result['admins'] = []
for a in self.admins:
- result['admins'].append(persons[a])
-
- # Networks
- result['networks'] = self.ip_blocks
+ result.add_value(AnswerAdminValue(2, persons[a]))
return result
nihil fit ex nihilo