Extending the CDM mapping
The following example shows how to extend the default CDM mapping for a host to create BMC_PhysicalLocation CIs from location information determined in BMC Discovery and relate these to BMC_ComputerSystem CIs.
The first pattern is used to determine the location of the host. Taken from Using TPL to enrich discovered data:
Using a table in a pattern to relate subnets to locations
Subnets can be used to identify locations of hosts. You can extend the
template_host_location pattern to map subnets to locations. The following TPL snippet shows how you could use a table to map the subnet to hosts. You could also hard code a mapping of hostnames to locations if that information is available. See TPL Guide for more information on tables.
The following TPL snippet shows the search from the host to associated subnet or subnets.
Now you can create or update the relationship between the host and location node. The following code snippet uses the
model.uniquerel function to create or update the relationship.
The host is now related to the location node which represents its physical location.
The second pattern is the
template_cmdb_location template which is available in the Pattern Templates section of the Pattern Management page. See Pattern templates for more information on the template patterns supplied with BMC Discovery. The syncmapping is described in the TPL Guide.
template_cmdb_location syncmapping extends the root mapping for Host nodes. The mapping section specifies the extension to the root mapping using the from keyword. The traversal finds related location nodes, and the mapping from
BMC_PhysicalLocation is defined.
The name defined by the traversal can only be used in a for each expression; it cannot be used in any other context.
The body of the
template_cmdb_location pattern loops through each location reached by the traversal, and transforms the subgraph of data in the Discovery model into a subgraph of CIs in the target CMDB model. This is copied across and then the relationship is created between the
BMC_ComputerSystem and the new
BMC_PhysicalLocation in the CMDB.