Enumerating the ITNM device class hierarchy for network views
MattDuggan 270001YJP0 Comments (2) Visits (6674)
A short but sweet one... (I hope)
ITNM categorizes devices into an 'Active Object Class', or AOC', hierarchy that helps classify devices in terms of vendor, role and model family. For example, the tree root is called 'Core' and under the root are sub-classes such as "EndNode" and "NetworkDevice" and then the various vendors under network device and so-o
This is great, but what if you want the tree hierarchy captured for that bit of additional context? i.e. you want the GUI to show that all Cisco26xx family devices are classified as follows in the AOC hierarchy:- Core -> NetworkDevice -> Cisco -> Cisco26xx.
So, we need a query that does two things:-
1. Traverses the ITNM AOC hierarchy recursively and somehow enumerates the parent-child relationships into something we can use in the GUIs.
2. Gets the ITNM NCIM database entityId's of the things considered to be members of the leaf-nodes of that particular part of the tree, i.e. if the tree is Core->NetworkDevice we want just members of NetworkDevice, not Core as well.
Luckily, this is pretty easy to do as you can use a cool tree traversal capability that the databases used by ITNM typically support. Note that there are various ways of doing this depending on your database platform and so check out the relevant docs. In this example I'm using Informix and its hierarchical query capability. Check out the following link for more info
In one of my previous blog entries, I used a database view to help categorize VLANs discovered by ITNM and I'll use a similar approach here. Check out the following link for more info:- htt
1. CREATE VIEW ncim
6. AS SELECT hierarchy.path,
8. FROM (SELECT ec.classId,
10. FROM entityClass ec
11. START WITH ec.className = 'Core'
12. CONNECT BY PRIOR ec.classId = ec.superclassId) AS hierarchy
13. INNER JOIN classMembers c ON c.classId = hier
Lines 1-5 create a view called classHierarchy in the ncim schema with 'path' and 'entityId' columns, i.e. the enumerated class hierarchy and the entityId's considered to be members of the last class in the path.
Lines 6-13 define the query that drives the content of the view and it's broken down like this:-
Lines 6 & 7 pull the columns we're interested in putting into the view from the query body, in this case we're pulling 'path' from the subquery aliased as 'hierarcy' and the entityId from the classMembers table aliased as 'c'.
Lines 8-12 define the sub-query that recursively traverses the ITNM class hiearchy. In this case want the classId from the entityClass table aliases as 'ec' (for later...) and we want to create a UNIX-like directory 'path' for the tree hierarchy such as "/Co
Lines 11 & 12 is where the action happens regarding traversing the tree in the right order. Here's we're using START WITH to start traversal from the entityClass called 'Core' (i.e. the root node of the AOC hierarchy). We then use CONNECT BY PRIOR to step through the hierarchy, i.e. the next superclassId becomes the previous classId. We then alias this as 'hierarchy'.
Line 13 gets the associated records fro the classMembers table for each classId in the previous query aliased as 'hierarchy'.
Here's some examples of creating the view and running a test query using ncp_oql within ITNM:-
I hope you find this useful,