# HG changeset patch # User Tero Marttila # Date 1424954915 -7200 # Node ID 7e44854e85d448eafe6e6537e4f72c3613ec1adb # Parent 1e68e3a30b5118d8c0d2cc7b98371ef0ec449c1a README and test host boot= and dynamic ip= diff -r 1e68e3a30b51 -r 7e44854e85d4 README --- a/README Thu Feb 26 14:40:37 2015 +0200 +++ b/README Thu Feb 26 14:48:35 2015 +0200 @@ -31,15 +31,15 @@ $ bin/pvl.hosts-dhcp etc/hosts/test host foo { - option host-name "foo"; - hardware ethernet 00:11:22:33:44:55; - fixed-address 127.0.0.1; + option host-name foo; + hardware ethernet 00:11:22:33:44:55; + fixed-address 127.0.0.1; } host bar { - option host-name "bar"; - hardware ethernet 01:23:45:67:89:ab; - fixed-address 127.0.0.2; + option host-name bar; + hardware ethernet 01:23:45:67:89:ab; + fixed-address 127.0.0.2; } === Generated hosts === @@ -81,3 +81,31 @@ 245.0.0 CNAME 245.240/29.0.0.10.in-addr.arpa. 246.0.0 CNAME 246.240/29.0.0.10.in-addr.arpa. 247.0.0 CNAME 247.240/29.0.0.10.in-addr.arpa. + +=== DHCP Options === +The hosts need not specify any fixed ip address, leaving IP address allocation to dhcpd: + + [foo] + ethernet = 00:11:22:33:44:55 + + $ bin/pvl.hosts-dhcp etc/hosts/dhcp1 + host foo { + option host-name foo; + hardware ethernet 00:11:22:33:44:55; + } + +=== DHCP Boot options === +The hosts can specify DHCP boot server/file options: + + [foo] + ethernet = 00:11:22:33:44:55 + boot = boot.lan:debian/wheezy/pxelinux.0 + + $ bin/pvl.hosts-dhcp etc/hosts/boot.dhcp + host foo { + option host-name foo; + hardware ethernet 00:11:22:33:44:55; + next-server boot.lan; + filename debian/wheezy/pxelinux.0; + } + diff -r 1e68e3a30b51 -r 7e44854e85d4 etc/hosts/boot.dhcp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/etc/hosts/boot.dhcp Thu Feb 26 14:48:35 2015 +0200 @@ -0,0 +1,3 @@ +[foo] + ethernet = 00:11:22:33:44:55 + boot = boot.lan:debian/wheezy/pxelinux.0 diff -r 1e68e3a30b51 -r 7e44854e85d4 etc/hosts/dhcp1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/etc/hosts/dhcp1 Thu Feb 26 14:48:35 2015 +0200 @@ -0,0 +1,2 @@ +[foo] + ethernet = 00:11:22:33:44:55 diff -r 1e68e3a30b51 -r 7e44854e85d4 pvl/hosts/tests.py --- a/pvl/hosts/tests.py Thu Feb 26 14:40:37 2015 +0200 +++ b/pvl/hosts/tests.py Thu Feb 26 14:48:35 2015 +0200 @@ -468,5 +468,32 @@ ], None) ]) + def testHostDynamic(self): + host = Host.build('foo', 'test', + ethernet = '00:11:22:33:44:55', + ) + + self.assertBlocksEqual(list(dhcp.dhcp_host(host)), [ + (('host', 'foo'), [ + ('option', 'host-name', "foo"), + ('hardware', 'ethernet', '00:11:22:33:44:55'), + ], None) + ]) + + def testHostBoot(self): + host = Host.build('foo', 'test', + ethernet = '00:11:22:33:44:55', + boot = 'boot.lan:debian/wheezy/pxelinux.0', + ) + + self.assertBlocksEqual(list(dhcp.dhcp_host(host)), [ + (('host', 'foo'), [ + ('option', 'host-name', "foo"), + ('hardware', 'ethernet', '00:11:22:33:44:55'), + ('next-server', 'boot.lan'), + ('filename', 'debian/wheezy/pxelinux.0'), + ], None) + ]) + if __name__ == '__main__': unittest.main()