113 |
113 |
114 class ConfFile (Section, conf.File) : |
114 class ConfFile (Section, conf.File) : |
115 DEFAULT_NAME = "dhcpd.conf" |
115 DEFAULT_NAME = "dhcpd.conf" |
116 DEFAULT_PATH = "/etc/dhcp3/dhcpd.conf" |
116 DEFAULT_PATH = "/etc/dhcp3/dhcpd.conf" |
117 |
117 |
118 def __init__ (self, name=DEFAULT_NAME, path=DEFAULT_PATH, params=None, decls=None) : |
118 def __init__ (self, name=DEFAULT_NAME, path=DEFAULT_PATH, params=None, decls=None, comment=None) : |
119 """ |
119 """ |
120 Initialize the dhcpd config file, but don't open it yet. |
120 Initialize the dhcpd config file, but don't open it yet. |
121 """ |
121 """ |
122 |
122 |
123 conf.File.__init__(self, name, path) |
123 conf.File.__init__(self, name, path) |
124 Section.__init__(self, params, decls) |
124 Section.__init__(self, params, decls, comment) |
125 |
125 |
126 class Statement (Object) : |
126 class Statement (Object) : |
127 """ |
127 """ |
128 A statement is a single line in the config file |
128 A statement is a single line in the config file |
129 """ |
129 """ |
268 [ parameters ] |
268 [ parameters ] |
269 [ declarations ] |
269 [ declarations ] |
270 } |
270 } |
271 """ |
271 """ |
272 |
272 |
273 def __init__ (self, name, params=[], decls=[]) : |
273 def __init__ (self, name, *args, **kwargs) : |
274 """ |
274 """ |
275 @param name the name of the shared-subnet |
275 @param name the name of the shared-subnet |
276 @param params optional parameters |
276 """ |
277 @param decls the iterable of subnets or other declarations in the shared network |
277 |
278 """ |
278 super(SharedNetwork, self).__init__("shared-network", [name], *args, **kwargs) |
279 |
|
280 super(SharedNetwork, self).__init__("shared-network", [name], params, decls) |
|
281 |
279 |
282 class Subnet (Declaration) : |
280 class Subnet (Declaration) : |
283 """ |
281 """ |
284 A subnet is used to provide the information about a subnet required to identify whether or not an IP address is |
282 A subnet is used to provide the information about a subnet required to identify whether or not an IP address is |
285 on that subnet, and may also be used to specify parameters/declarations for that subnet. |
283 on that subnet, and may also be used to specify parameters/declarations for that subnet. |
288 [ parameters ] |
286 [ parameters ] |
289 [ declarations ] |
287 [ declarations ] |
290 } |
288 } |
291 """ |
289 """ |
292 |
290 |
293 def __init__ (self, network, params=None, decls=None) : |
291 def __init__ (self, network, *args, **kwargs) : |
294 """ |
292 """ |
295 @param network the addr.Network for the subnet |
293 @param network the addr.Network for the subnet |
296 @param params optional parameters |
294 """ |
297 @param decls optional decls, e.g. subnets |
295 |
298 """ |
296 super(Subnet, self).__init__("subnet", [network.net(), "netmask", network.netmask()], *args, **kwargs) |
299 |
|
300 super(Subnet, self).__init__("subnet", [network.net(), "netmask", network.netmask()], params, decls) |
|
301 |
297 |
302 class Group (Declaration) : |
298 class Group (Declaration) : |
303 """ |
299 """ |
304 A group is simply used to apply a set of parameters to a set of declarations. |
300 A group is simply used to apply a set of parameters to a set of declarations. |
305 |
301 |
307 [ parameters ] |
303 [ parameters ] |
308 [ declarations ] |
304 [ declarations ] |
309 } |
305 } |
310 """ |
306 """ |
311 |
307 |
312 def __init__ (self, params=None, decls=None) : |
308 def __init__ (self, *args, **kwargs) : |
313 super(Group, self).__init__("group", [], params, decls) |
309 super(Group, self).__init__("group", [], *args, **kwargs) |
314 |
310 |
315 |
311 |
316 class Host (Declaration) : |
312 class Host (Declaration) : |
317 """ |
313 """ |
318 A host is used to match a request against specific host, and then apply settings for that host. |
314 A host is used to match a request against specific host, and then apply settings for that host. |
326 [ parameters ] |
322 [ parameters ] |
327 [ declarations ] |
323 [ declarations ] |
328 } |
324 } |
329 """ |
325 """ |
330 |
326 |
331 def __init__ (self, hostname, params=None, decls=None) : |
327 def __init__ (self, hostname, *args, **kwargs) : |
332 super(Host, self).__init__("host", [hostname], params, decls) |
328 super(Host, self).__init__("host", [hostname], *args, **kwargs) |
333 |
329 |
334 class Option (Parameter) : |
330 class Option (Parameter) : |
335 """ |
331 """ |
336 A generic 'option' parameter for a dhcpd.conf file |
332 A generic 'option' parameter for a dhcpd.conf file |
337 """ |
333 """ |
338 |
334 |
339 def __init__ (self, name, *args) : |
335 def __init__ (self, name, *args, **kwargs) : |
340 """ |
336 """ |
341 Formatted as a Satement with a name of "option <name>". |
337 Formatted as a Satement with a name of "option <name>". |
342 """ |
338 """ |
343 |
339 |
344 super(Option, self).__init__("option %s" % name, *args) |
340 super(Option, self).__init__("option %s" % name, *args, **kwargs) |
345 |
341 |