Merging Hosts, Ethers, and Boot Parameters

Goal

We want to merge the following entry from /etc/hosts:

192.168.1.10  www.example.com www

with the following entry from /etc/ethers:

5A:CA:FE:BA:BE:23 www.example.com

with the following entry from /etc/bootparams:

www.vergenet.com root=server:/export/www/root swap=server:/export/www/swap domain=www.vergenet.com

into the following LDAP entry in Penrose:

dn: cn=www.example.com,ou=Merged Hosts,dc=NIS,dc=Example,dc=com
objectClass: bootableDevice
objectClass: device
objectClass: ieee802Device
objectClass: ipHost
macAddress: 5A:CA:FE:BA:BE:23
bootParameter: root=server:/export/www/root
bootParameter: swap=server:/export/www/swap
bootParameter: domain=www.example.com
ipHostNumber: 192.168.1.10
cn: www.example.com
cn: www

Solution

You can use the same sources that you created previously for hosts, ethers, and bootparams.

Then we create a new mapping that merges the three sources:

<entry dn="cn=...,ou=Merged Hosts,dc=NIS,dc=Example,dc=com">

    <oc>device</oc>
    <oc>ipHost</oc>
    <oc>ieee802Device</oc>
    <oc>bootableDevice</oc>

    <at name="cn" rdn="true">
      <variable>h.primaryKey.cn</variable>
    </at>
    <at name="cn">
      <variable>h.cn</variable>
    </at>
    <at name="ipHostNumber">
      <variable>h.ipHostNumber</variable>
    </at>
    <at name="macAddress">
      <variable>e.macAddress</variable>
    </at>
    <at name="bootFile">
      <variable>b.bootFile</variable>
    </at>
    <at name="bootParameter">
      <variable>b.bootParameter</variable>
    </at>

    <source name="h">
      <source-name>hosts</source-name>
      <field name="cn" primaryKey="true">
        <variable>rdn.cn</variable>
      </field>
      <field name="cn">
        <variable>cn</variable>
      </field>
      <field name="ipHostNumber">
        <variable>ipHostNumber</variable>
      </field>
    </source>

    <source name="e" required="false">
      <source-name>ethers</source-name>
      <field name="cn" primaryKey="true">
        <variable>cn</variable>
      </field>
      <field name="macAddress">
        <variable>macAddress</variable>
      </field>
    </source>

    <source name="b" required="false">
      <source-name>bootparams</source-name>
      <field name="cn" primaryKey="true">
        <variable>cn</variable>
      </field>
      <field name="bootFile">
        <variable>bootFile</variable>
      </field>
      <field name="bootParameter">
        <variable>bootParameter</variable>
      </field>
    </source>

    <relationship>
      <expression>h.cn = e.cn</expression>
    </relationship>
    <relationship>
      <expression>h.cn = b.cn</expression>
    </relationship>

</entry>

Performance Issue

Since Penrose has to download all entries before it can merge them, this particular mapping is slow. You can enable Cache to improve the performance.