The Condense section contains variables that define operations on tokens resulting from the Extract section, or any previously defined variable in the table definition.
It simplifies the attribute value definitions given in the Build section.
Variables defined in the Condense section can contain:
A token specified in the same table section
A configuration variable specified in the Common section for the same NIS table, or in the Common section that applies to all NIS tables
A constant expression
A function: exclude, getrdn, split, instances2string, string2instances, or trim. A variable can contain just one function. If you want to use several functions on the same information, you must create intermediate variables.
Variables in the Condense section can be made up of several alternative rules. The conversion process applies the first rule that matches the input information. The rules must be separated by two pipe symbols, and must all be part of the same expression. For example, the following expression is permitted:
fifi=$parameter1 - $parameter2 || $parameter1 || juju |
whereas, the following expression is not:
fifi=$parameter1 - $parameter2 fifi=$parameter1 fifi=juju |
You can define any number of variables in the Condense section. The order in which they are listed is important if you create dependencies between them. For instance, you can have:
fifi=$parameter1 - $parameter2 || $parameter1 || juju riri=$fifi - $parameterA loulou=$fifi - $parameterB |
The syntax of the split function is as follows:
variableA=split(what, "separator", "add_prefix", "add_suffix", order) |
where:
variableA identifies the variable
what identifies the unit of information, variable or parameter, to which the operation applies
separator indicates where to split the information. This value must be specified between quotes because it could contain a space.
add_prefix specifies a prefix to add to each item resulting from the split. This value must be specified between quotes because it could contain a space.
add_suffix specifies a suffix to add to each item resulting from the split. This value must be specified between quotes because it could contain a space.
order specifies the order in which the items resulting from the split are to be presented. The possible values for this parameter are left2right or right2left.
For example, in the nis.mapping file, the following variable definition is used to split an NIS domain name into a sequence of LDAP domain component attributes:
DC_NAMING=split($DOMAIN_NAME, ".", "dc=", ",", left2right) |
If the domain name specified is eng.europe.xyz.com, the resulting expression is:
dc=eng, dc=europe, dc=xyz, dc=com.
The string2instances function breaks down a specified string into instances. The syntax for this operation is:
variableA=string2instances("string", "separator") |
where:
variableA identifies the variable
string identifies the unit of information, variable or parameter, to which the operation applies. This value must be specified between quotes because it could contain a space.
separator indicates where to split the information into instances. This value must be specified between quotes because it could contain a space.
For example, in nis.mapping, the following definition in the Condense section of the bootparams file breaks down a string of parameters into separate instances:
bootParameterT=string2instances($parametersT," ") |
The string2instances function is also used to specify the inheritance tree for an object class. For example, if the object class of an entry created using a particular mapping definition is organizationalPerson, the Condense section of the mapping definition must contain the line:
objectClassT=string2instances("top person organizationalPerson", " ") |
The instances2string function combines several instances into a single string. The syntax for this operation is:
variableA=instances2string(what, "separator") |
where:
variableA identifies the variable
what is a variable that has a number of instances
separator marks the separation between the elements of the string. This value must be specified between quotes because it could be a space.
For example, you could use the following variable to find the list of names and alias names for a given machine:
NameList=instances2string($cn, " ") |
If the cn attribute has the values camembert, Cam, Bertie, the resulting string would be:
camembert Cam Bertie
The trim function removes any unnecessary white space surrounding a parameter. The syntax for the trim operation is:
variableA=trim(parameter) |
where:
variableA identifies the variable
parameter is the item from which white space must be removed
For example, if you decompose an alias list into its constituent members, you could define the following variables:
aliasMember=string2instances($aliasList, ",") trimAliasMember=trim($aliasMember) |
Each aliasMember parameter resulting from the string2instances operation is processed to remove any white spaces.
The getrdn function returns the naming attribute of an entry, that is the attribute used in the entry's RDN. The syntax for the getrdn operation is:
variableA=getrdn() |
The getrdn function can only be used in variables in the Condense section.
For example, the cn attribute of a machine has the values camembert, Cam, Bertie, but the actual system name of the machine, used in the RDN is camembert. For example, you could create the following variable:
HostName=getrdn() |
The getrdn function returns the name camembert.
The getrdn function is case-sensitive.
The exclude function removes a value from a list or a string. The syntax for this operation is:
variableA=exclude(string, exclude-value, "separator") |
where:
variableA identifies the variable
string identifies the list or string
exclude-value is the value to exclude
separator marks the separation between the elements of the list or string. This value must be specified between quotes because it could be a space.
For example, to obtain the list of aliases for a machine, you need to exclude the canonical name from the list of names. You could create the following variables:
NameList=instances2string($cn, " ") HostName=getrdn() HostAliases=exclude(NameList, HostName, " ") |
In nis.mapping, the Condense section of the hosts mapping definition contains:
ipHostAliasesLineT=exclude($allIpHostAliasesT,$ipHostNameT, " ") |
This definition excludes the ipHostName from the list of alias names for the host.