Configuration Examples

This section gives examples of configurations.

Use Case

A TQL query is:

node > (composition) > card

where:

  • node is the CMDB entity
  • card is the federated database source entity

  • composition is the relationship between them

The example is run against the ED database. ED nodes are stored in the Device table and card is stored in the hwCards table. In the following examples, card is always mapped in the same manner.

Single Node Reconciliation

In this example the reconciliation is run against the name property.

Simplified Definition

The reconciliation is done by node and it is emphasized by the special tag CMDB-class.

<?xml version="1.0" encoding="UTF-8"?>
<generic-DB-adapter-config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../META-CONF/simplifiedConfiguration.xsd">
    <CMDB-class CMDB-class-name="node" default-table-name="Device">
        <primary-key column-name="Device_ID" />
        <reconciliation-by-single-node>
            <or>
                <attribute CMDB-attribute-name="name" column-name="Device_Name" />
            </or>
        </reconciliation-by-single-node>
    </CMDB-class>
    <class CMDB-class-name="card" default-table-name="hwCards" connected-CMDB-class-name="node" link-class-name="composition">
        <foreign-primary-key column-name="Device_ID" CMDB-class-primary-key-column="Device_ID 
        <primary-key column-name="hwCards_Seq" />
        <attribute CMDB-attribute-name="card_class" column-name="hwCardClass" />
        <attribute CMDB-attribute-name="card_vendor" column-name="hwCardVendor" />
        <attribute CMDB-attribute-name="card_name" column-name="hwCardName" />
    </class>
</generic-DB-adapter-config>

Advanced Definition

The orm.xml File

Pay attention to the addition of the relationship mapping. For details, see the definition section in The orm.xml File.

Example of the orm.xml File:

<?xml version="1.0" encoding="UTF-8"?> <entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm" xmlns:xsi="http:// www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/ persistence/orm http://java.sun.com/xml/ns/persistence/orm_1_0.xsd" version="1.0"> <description>Generic DB adapter orm</description> <package>generic_db_adapter</package> <entity class="generic_db_adapter.node" > <table name="Device"/> <attributes> <id name="id1"> <column name="Device_ID" insertable="false" updatable="false"/> <generated-value strategy="TABLE"/> </id> <basic name="name"> <column name="Device_Name"/> </basic> </attributes> </entity> <entity class="generic_db_adapter.card" > <table name="hwCards"/> <attributes> <id name="id1"> <column name="hwCards_Seq" insertable="false" updatable="false"/> <generated-value strategy="TABLE"/> </id> <basic name="card_class"> <column name="hwCardClass" insertable="false" updatable="false"/> </basic> <basic name="card_vendor"> <column name="hwCardVendor" insertable="false" updatable="false"/> </basic> <basic name="card_name"> <column name="hwCardName" insertable="false" updatable="false"/> </basic> </attributes> </entity> <entity class="generic_db_adapter.node_composition_card" > <table name="hwCards"/> <attributes> <id name="id1"> <column name="hwCards_Seq" insertable="false" updatable="false"/> <generated-value strategy="TABLE"/> </id> <many-to-one name="end1" target-entity="node"> <join-column name="Device_ID" insertable="false" updatable="false"/> </many-to-one> <one-to-one name="end2" target-entity="card" > <join-column name="hwCards_Seq" referenced-column-name="hwCards_Seq" insertable= "false" updatable="false"/> </one-to-one> </attributes> </entity> </entity-mappings>

The reconciliation_rules.txt File

For details, see The reconciliation_rules.txt File (for backwards compatibility).

multinode[node] expression[node.name]

The transformation.txt File

This file remains empty as no values need to be converted in this example.

Two Node Reconciliation

In this example, reconciliation is calculated according to the name property of node and of ip_address with different variations.

The reconciliation TQL query is node > (containment) > ip_address.

Simplified Definition

The reconciliation is by name of node OR of ip_address:

<?xml version="1.0" encoding="UTF-8"?>
<generic-DB-adapter-config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../META-CONF/simplifiedConfiguration.xsd">
    <CMDB-class CMDB-class-name="node" default-table-name="Device">
        <primary-key column-name="Device_ID" />
        <reconciliation-by-two-nodes connected-node-CMDB-class-name="ip_address" CMDB-link-type="containment">
            <or>
                <attribute CMDB-attribute-name="name" column-name="Device_Name" />
                <connected-node-attribute CMDB-attribute-name="name" column-name="Device_PreferredIPAddress" />
            </or>
        </reconciliation-by-two-nodes>
    </CMDB-class>
    <class CMDB-class-name="card" default-table-name="hwCards" connected-CMDB-class-name="node" link-class-name="containment">
        <foreign-primary-key column-name="Device_ID" CMDB-class-primary-key-column="Device_ID" />
        <primary-key column-name="hwCards_Seq" />
        <attribute CMDB-attribute-name="card_class" column-name="hwCardClass" />
        <attribute CMDB-attribute-name="card_vendor" column-name="hwCardVendor" />
        <attribute CMDB-attribute-name="card_name" column-name="hwCardName" />
    </class>
</generic-DB-adapter-config>

The reconciliation is name of node AND of ip_address:

<?xml version="1.0" encoding="UTF-8"?>
<generic-DB-adapter-config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../META-CONF/simplifiedConfiguration.xsd">
    <CMDB-class CMDB-class-name="node" default-table-name="Device">
        <primary-key column-name="Device_ID" />
        <reconciliation-by-two-nodes connected-node-CMDB-class-name="ip_address" CMDB-link-type="containment">
            <and>
                <attribute CMDB-attribute-name="name" column-name="Device_Name" />
                <connected-node-attribute CMDB-attribute-name="name" column-name="Device_PreferredIPAddress" />
            </and>
        </reconciliation-by-two-nodes>
    </CMDB-class>
    <class CMDB-class-name="card" default-table-name="hwCards" connected-CMDB-class-name="node" link-class-name="containment">
        <foreign-primary-key column-name="Device_ID" CMDB-class-primary-key-column="Device_ID" />
        <primary-key column-name="hwCards_Seq" />
        <attribute CMDB-attribute-name="card_class" column-name="hwCardClass" />
        <attribute CMDB-attribute-name="card_vendor" column-name="hwCardVendor" />
        <attribute CMDB-attribute-name="card_name" column-name="hwCardName" />
    </class>
</generic-DB-adapter-config>

The reconciliation is by name of ip_address:

<?xml version="1.0" encoding="UTF-8"?>
<generic-DB-adapter-config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../META-CONF/simplifiedConfiguration.xsd">
    <CMDB-class CMDB-class-name="node" default-table-name="Device">
        <primary-key column-name="Device_ID" />
        <reconciliation-by-two-nodes connected-node-CMDB-class-name="ip_address" CMDB-link-type="containment">
            <or>
                <connected-node-attribute CMDB-attribute-name="name" column-name="Device_PreferredIPAddress" />
            </or>
        </reconciliation-by-two-nodes>
    </CMDB-class>
    <class CMDB-class-name="card" default-table-name="hwCards" connected-CMDB-class-name="node" link-class-name="containment">
        <foreign-primary-key column-name="Device_ID" CMDB-class-primary-key-column="Device_ID" />
        <primary-key column-name="hwCards_Seq" />
        <attribute CMDB-attribute-name="card_class" column-name="hwCardClass" />
        <attribute CMDB-attribute-name="card_vendor" column-name="hwCardVendor" />
        <attribute CMDB-attribute-name="card_name" column-name="hwCardName" />
    </class>
</generic-DB-adapter-config>

Advanced Definition

The orm.xml File

Since the reconciliation expression is not defined in this file, the same version should be used for any reconciliation expression.

The reconciliation_rules.txt File

For details, see The reconciliation_rules.txt File (for backwards compatibility).

multinode[node] expression[ip_address.name OR node.name] end1_type[node] end2_type[ip_address] link_type[containment]
multinode[node] expression[ip_address.name AND node.name] end1_type[node] end2_type[ip_address] link_type[containment]
multinode[node] expression[ip_address.name] end1_type[node] end2_type[ip_address] link_type[containment]

The transformation.txt File

This file remains empty as no values need to be converted in this example.

Using a Primary Key that Contains More Than One Column

If the primary key is composed of more than one column, the following code is added to the XML definitions:

Simplified Definition

There is more than one primary key tag and for each column there is a tag.

    <class CMDB-class-name="card" default-table-name="hwCards" connected-CMDB-class-name="node" link-class-name="containment">
        <foreign-primary-key column-name="Device_ID" CMDB-class-primary-key-column="Device_ID" />
        <primary-key column-name="Device_ID" />
        <primary-key column-name="hwBusesSupported_Seq" />
        <primary-key column-name="hwCards_Seq" />
        <attribute CMDB-attribute-name="card_class" column-name="hwCardClass" />
        <attribute CMDB-attribute-name="card_vendor" column-name="hwCardVendor" />
        <attribute CMDB-attribute-name="card_name" column-name="hwCardName" />
    </class>

Advanced Definition

The orm.xml File

A new id entity is added that maps to the primary key columns. Entities that use this id entity must add a special tag.

If you use a foreign key (join-column tag) for such a primary key, you must map between each column in the foreign key to a column in the primary key.

For details, see The orm.xml File.

Example of the orm.xml File:

<entity class="generic_db_adapter.card" >     <table name="hwCards" />     <attributes>         <id name="id1">             <column name="Device_ID" insertable="false" updatable="false" />             <generated-value strategy="TABLE" />         </id>         <id name="id2">             <column name="hwBusesSupported_Seq" insertable="false" updatable="false" />             <generated-value strategy="TABLE" />         </id>         <id name="id3">             <column name="hwCards_Seq" insertable="false" updatable="false" />             <generated-value strategy="TABLE" />         </id> <entity class="generic_db_adapter.node_containment_card" >     <table name="hwCards" />     <attributes>        <id name="id1">             <column name="Device_ID" insertable="false" updatable="false" />                 <generated-value strategy="TABLE" />         </id>         <id name="id2">             <column name="hwBusesSupported_Seq" insertable="false" updatable="false" />                 <generated-value strategy="TABLE" />         </id>         <id name="id3">             <column name="hwCards_Seq" insertable="false" updatable="false" />             <generated-value strategy="TABLE" />         </id>     <many-to-one name="end1" target-entity="node">             <join-column name="Device_ID" insertable="false" updatable="false" />             </many-to-one> <one-to-one name="end2" target-entity="card">             <join-column name="Device_ID" referenced-column-name="Device_ID" insertable="false" updatable="false" />             <join-column name="hwBusesSupported_Seq" referenced-column-name="hwBusesSupported_Seq" insertable="false" updatable="false" />             <join-column name="hwCards_Seq" referenced-column-name="hwCards_Seq" insertable="false" updatable="false" />         </one-to-one>     </attributes> </entity></entity-mappings>

Using Transformations

In the following example, the generic enum transformer is converted from values 1, 2, 3 to values a, b, c respectively in the name column.

The mapping file is generic-enum-transformer-example.xml.

<enum-transformer CMDB-type="string" DB-type="string" non-existing-value-action="return-original" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../META-CONF/generic-enum-transformer.xsd">
    <value CMDB-value="1" external-DB-value="a" />
    <value CMDB-value="2" external-DB-value="b" />
    <value CMDB-value="3" external-DB-value="c" />
</enum-transformer>

Simplified Definition

    <CMDB-class CMDB-class-name="node" default-table-name="Device">
        <primary-key column-name="Device_ID" />
        <reconciliation-by-two-nodes connected-node-CMDB-class-name="ip_address" 
          CMDB-link-type="containment">
            <or>
                <attribute CMDB-attribute-name="name" column-name="Device_Name" 
                 from-CMDB-converter="com.mercury.topaz.fcmdb.adapters.dbAdapter.dal.
                 transform.impl.GenericEnumTransformer(generic-enum-transformer-example.
                 xml)" to-CMDB-converter="com.mercury.topaz.fcmdb.adapters.dbAdapter.dal.
                 transform.impl.GenericEnumTransformer(generic-enum-transformer-example.
                 xml)" />
                <connected-node-attribute CMDB-attribute-name="name" 
                 column-name="Device_PreferredIPAddress" />
            </or>
        </reconciliation-by-two-nodes>
    </CMDB-class>

Advanced Definition

There is a change only to the transformation.txt file.

The transformation.txt File

Make sure that the attribute names and entity names are the same as in the orm.xml file.

entity[node] attribute[name] 
to_DB_class[com.mercury.topaz.fcmdb.adapters.dbAdapter.dal.transform.impl.
GenericEnumTransformer(generic-enum-transformer-example.xml)] from_DB_class
[com.mercury.topaz.fcmdb.adapters.dbAdapter.dal.transform.impl.
GenericEnumTransformer(generic-enum-transformer-example.xml)]