-
Notifications
You must be signed in to change notification settings - Fork 0
/
host.dylan
36 lines (30 loc) · 1.12 KB
/
host.dylan
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
module: buddha
author: Hannes Mehnert <[email protected]>
define web-class <host> (<object>)
data host-name :: <string>;
data mac-address :: <mac-address> = as(<mac-address>, "00deadbeef00");
data ipv4-address :: <ipv4-address>;
data ipv6-address :: <ipv6-address>, autoconf-v6(object.ipv6-subnet, object.mac-address);
data time-to-live :: <integer> = 300;
has-a ipv4-subnet;
has-a ipv6-subnet = $bottom-v6-subnet;
has-a zone;
end;
define method print-object (host :: <host>, stream :: <stream>)
=> ()
format(stream, "Host: %s\n", as(<string>, host))
end;
define method \< (a :: <host>, b :: <host>) => (res :: <boolean>)
a.ipv4-address < b.ipv4-address
end;
define method as (class == <string>, host :: <host>)
=> (res :: <string>)
concatenate(host.host-name, " ", as(<string>, host.ipv4-address));
end;
define method print-isc-dhcpd-file (host :: <host>, stream :: <stream>)
=> ()
format(stream, "host %s {\n", host.host-name);
format(stream, "\thardware ethernet %s;\n", as(<string>, host.mac-address));
format(stream, "\tfixed-address %s;\n", as(<string>, host.ipv4-address));
format(stream, "}\n\n");
end;