fwd: host config file based on vendor specific options and service level

Cesar Forestier cforestier at gmail.com
Sat Apr 8 18:45:24 UTC 2006


Hi
I'm using a similar configuration in that the filename depends
from vendor options and services level.
I'm impressed with the solution from David, it's really good
and I'll try it.
At this moment I'm using a conf like this:

#Group Slow
group {
         if (substring (option Vendor.model, 0, 6) = "Model_1") {
                  filename "config_file_Model_1_service_slow";
          } elsif (substring (option Vendor.model, 0, 6) = "Model_2") {
                  filename "config_file_Model_2_service_slow";
          } elsif (substring (option Vendor.model, 0, 6) = "Model_3") {
                  filename "config_file_Model_3_service_slow";
          } elsif (substring (option Vendor.model, 0, 6) = "Model_4") {
                  filename "config_file_Model_4_service_slow";
          } else {
                  filename "config_file_catch_all";

          }
host A-1-001 {
       hardware ethernet yadda..;
       fixed-address yadda;
}
host A-1-002 {
       hardware ethernet yadda2..;
       fixed-address yadda2;
}

}
#End Group Slow

#Group Fast
group {
         if (substring (option Vendor.model, 0, 6) = "Model_1") {
                  filename "config_file_Model_1_service_fast";
          } elsif (substring (option Vendor.model, 0, 6) = "Model_2") {
                  filename "config_file_Model_2_service_fast";
          } elsif (substring (option Vendor.model, 0, 6) = "Model_3") {
                  filename "config_file_Model_3_service_fast";
          } elsif (substring (option Vendor.model, 0, 6) = "Model_4") {
                  filename "config_file_Model_4_service_fast";
          } else {
                  filename "config_file_catch_all";

          }
host B-1-001 {
       hardware ethernet yadda..;
       fixed-address yadda;
}
host B-1-002 {
       hardware ethernet yadda2..;
       fixed-address yadda2;
}

}
#End Group fast

Thanks in advance to the list users.
I'm learning a lot with this list.

Cesar Forestier.

2006/4/7, David W. Hankins <David_Hankins at isc.org>:
> 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