Example: EntityFromIfString.stch
Use this topic to understand how entity retrieval stitchers work.
The EntityFromIfString.stch stitcher looks up an interface based on a main node entityName and a
string, which is expected to be the ifName, ifDescr or ifAlias of the interface. This returns the
interface entity, if found in NCIM cache.
Line numbers | Description |
---|---|
3-7 | This stitcher is invoked by another stitcher, usually a topology lookup stitcher. |
11-12 | Read the input arguments from the invoking stitcher. |
16-27 | Set up an SQL query to retrieve an entity data record for an interface based on a main node entityName and a string, which is expected to be the ifName, ifDescr or ifAlias of the interface. |
30 | Use the RetrieveSingleOQL() stitcher rule to run the query and retrieve the entity data record for the interface. |
32 | Pass the result of the entity lookup back to the invoking stitcher. |
UserDefinedStitcher
{
StitcherTrigger
{
// There is no trigger, as this is explicitly called from
// other stitchers.
}
StitcherRules
{
text mainNodeEntityName = ARG_1;
text ifString = ARG_2;
Record entity;
text ifStringQuery =
"select * from ncimCache.entityData
where
ENTITYTYPE = 2
and
BASENAME = eval(text, '$mainNodeEntityName')
and
( interface->IFNAME = eval(text, '$ifString')
or
interface->IFDESCR = eval(text, '$ifString')
or
interface->IFALIAS = eval(text, '$ifString') );";
entity = RetrieveSingleOQL( ifStringQuery );
SetReturnValue( entity );
}
}