summaryrefslogtreecommitdiff
path: root/reconfigure/items/dhcpd.py
diff options
context:
space:
mode:
Diffstat (limited to 'reconfigure/items/dhcpd.py')
-rw-r--r--reconfigure/items/dhcpd.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/reconfigure/items/dhcpd.py b/reconfigure/items/dhcpd.py
new file mode 100644
index 0000000..aadda9a
--- /dev/null
+++ b/reconfigure/items/dhcpd.py
@@ -0,0 +1,35 @@
+from reconfigure.nodes import Node, PropertyNode
+from reconfigure.items.bound import BoundData
+
+
+class DHCPDData (BoundData):
+ pass
+
+
+class SubnetData (BoundData):
+ def template(self):
+ return Node(
+ 'subnet',
+ parameter='192.168.0.0 netmask 255.255.255.0',
+ )
+
+
+class RangeData (BoundData):
+ def template(self):
+ return PropertyNode('range', '192.168.0.1 192.168.0.100')
+
+
+class OptionData (BoundData):
+ def template(self):
+ return PropertyNode('option', '')
+
+
+DHCPDData.bind_collection('subnets', selector=lambda x: x.name == 'subnet', item_class=SubnetData)
+SubnetData.bind_attribute('parameter', 'name')
+SubnetData.bind_collection('subnets', selector=lambda x: x.name == 'subnet', item_class=SubnetData)
+SubnetData.bind_collection('ranges', selector=lambda x: x.name == 'range', item_class=RangeData)
+RangeData.bind_attribute('value', 'range')
+OptionData.bind_attribute('value', 'value')
+
+for x in [DHCPDData, SubnetData]:
+ x.bind_collection('options', selector=lambda x: x.name == 'option', item_class=OptionData)