fwd: host config file based on vendor specific options and service level
David W. Hankins
David_Hankins at isc.org
Fri Apr 7 15:34:20 UTC 2006
On Fri, Apr 07, 2006 at 03:04:11PM +0200, roger murray wrote:
> ex. host declarations before change:
>
> host A-1-001 {
> filename "service_A";
> hardware ethernet aa:bb:cc:dd:ee:ef;
> fixed-address 10.xx.yy.yz;
> }
>
> host B-1-001 {
> filename "service_B";
>
> hardware ethernet aa:bb:cc:dd:ee:ff;
> fixed-address 10.xx.yy.zz;
> }
>
>
> host A-1-001 {
>
> if (substring (option Vendor.model, 0, 6) = "Model_1") {
> filename "config_file_Model_1_service_A";
>
> } elsif (substring (option Vendor.model, 0, 6) = "Model_2") {
> filename "config_file_Model_2_service_A";
> } elsif (substring (option Vendor.model, 0, 6) = "Model_3") {
> filename "config_file_Model_3_service_A";
> } elsif (substring (option Vendor.model, 0, 6) = "Model_4") {
> filename "config_file_Model_4_service_A";
> } else {
> filename "config_file_catch_all";
> }
> hardware ethernet aa:bb:cc:dd:ee:ef;
> fixed-address 10.xx.yy.yz;
> }
>
> host B-117-001 {
>
> if (substring (option Vendor.model, 0, 6) = "Model_1") {
> filename "config_file_Model_1_service_B";
>
> } elsif (substring (option Vendor.model, 0, 6) = "Model_2") {
> filename "config_file_Model_2_service_B";
> } elsif (substring (option Vendor.model, 0, 6) = "Model_3") {
> filename "config_file_Model_3_service_B";
> } elsif (substring (option Vendor.model, 0, 6) = "Model_4") {
> filename "config_file_Model_4_service_B";
> } else {
> filename "config_file_catch_all";
>
> }
> hardware ethernet aa:bb:cc:dd:ee:ff;
> fixed-address 10.xx.yy.zz;
> }
Wow.
I know why that takes so long to load...it's a /lot/ of small memory
allocations to fill out all those executable statements for the if/else
chains.
May I suggest:
class "BootModels" {
match substring(option Vendor.model, 0, 6);
}
subclass "BootModels" "Model_1" { set pathprefix = "Model_1"; }
subclass "BootModels" "Model_2" { set pathprefix = "Model_2"; }
subclass "BootModels" "Model_3" { set pathprefix = "Model_3"; }
subclass "BootModels" "Model_4" { set pathprefix = "Model_4"; }
# Note: if Vendor.model substring really is "Model_4" and identical to
# what we're setting pathprefix to, you could just using that directly.
class "BootServices" {
match hardware;
}
subclass "BootServices" aa:bb:cc:dd:ee:ff { set pathsuffix = "A"; }
subclass "BootServices" gg:hh:ii:jj:kk:ll { set pathsuffix = "B"; }
filename = concat("config_file_", pathprefix, "_service_", pathsuffix);
#filename = concat("config_file_", substring(option Vendor.model, 0, 6),
# "_service_", pathsuffix);
host A-1-001 {
hardware ethernet yadda..;
fixed-address yadda;
}
host B-1-001 {
hardware ethernet yadda...;
fixed-address yadda;
}
Some ideas to play around with if you haven't already, anyway.
I don't know if that actually works. Binding scopes are a weird thing
to use for a static lease (they're meant to survive on dynamic lease
states in dhcpd.leases).
--
David W. Hankins "If you don't do it right the first time,
Software Engineer you'll just have to do it again."
Internet Systems Consortium, Inc. -- Jack T. Hankins
More information about the dhcp-users
mailing list