Highlighted
Absent Member.. Absent Member..
Absent Member..
423 views

How to query UCMDB by CIT in Jython discovery script

Jump to solution

Hey Guys,

 

I feel rather nooberly, but how would I go about querying UCMDB from within my Jython script? I am discovering the ID of a logical partition on a Linux server. I have my trigger query pulling in Linux servers and I am pull back an ID that would connect to CIT LogicalVolume. How do I query the UCMDB so that I can create a relationship between the Linux Server and the LogicalVolume?

 

I need to either search by a specific attribute and pull back a specific CI UCMDB id or pull back all CIs of a specific CIT in my case Logical Volume . Then search for the correct CI and relate it to the Linux server. I don't personally think this should be a difficult task but I haven't been able to find a clear solution.

 

Pseudo Code:

Trigger Linux CIs

 

Use powermt cmd on Linux server to get a logical partition ID that also exists in a Logical Volume CI

 

Logical Partition ID -> use this ID to query UCMDB and return the UCMDB id for a single Logical Volume CI

 

Relate Linux CI to Logical Volume CI

 

So I either need to be able to get all CIs of type Logical Volume and search them locally or I need to know a command to search the UCMDB using CIT and a specific (unique) attribute.

 

I hope someone can help me out here, I'm really in a pickle.

 

Thanks!

 

 

0 Likes
1 Solution

Accepted Solutions
Highlighted
Established Member..
Established Member..

Re: How to query UCMDB by CIT in Jython discovery script

Jump to solution

Say you have your server CI type in your input query and name it Servers.

 

In the Triggered CI data grab the following:-

 

serverName 

${Servers.name}

 

serverId

${Servers.global_id}

 

Then in your script create a keyed array with the serverName as the key and the global_id as the value. 

 

Then you can check if the server name from your host/linux command line query, is found in the input TQL list like:

 

if serverList.has_key(server):

 

and if so create an OSH based on the global_id of the found host....

 

serverOSH = modeling.createOshByCmdbIdString('nt', serverList[server]['global_id'])

 

You can then link your CI you create (the logical volume one) to the created CI from global_id of the inputTQL server. 

 

This is the technique we use, with good effect. 

 

Hope this helps you.

 

View solution in original post

0 Likes
5 Replies
Highlighted
Absent Member.
Absent Member.

Re: How to query UCMDB by CIT in Jython discovery script

Jump to solution

Hello,

 

My first question is:

 

The existing Logical Volume CIs in uCMDB to what Nodes are they related, because they have to be related to a root container? One particular Logical Volume is not allready related to your trigger Linux CI?

 

There is no way to query the ucmdb from the jythin scripts except for the information that you define inside the input TQL. So you have access only to the attributes of the CIT which compose the input TQL

 

Regards,

Adrian

0 Likes
Highlighted
Established Member..
Established Member..

Re: How to query UCMDB by CIT in Jython discovery script

Jump to solution

Say you have your server CI type in your input query and name it Servers.

 

In the Triggered CI data grab the following:-

 

serverName 

${Servers.name}

 

serverId

${Servers.global_id}

 

Then in your script create a keyed array with the serverName as the key and the global_id as the value. 

 

Then you can check if the server name from your host/linux command line query, is found in the input TQL list like:

 

if serverList.has_key(server):

 

and if so create an OSH based on the global_id of the found host....

 

serverOSH = modeling.createOshByCmdbIdString('nt', serverList[server]['global_id'])

 

You can then link your CI you create (the logical volume one) to the created CI from global_id of the inputTQL server. 

 

This is the technique we use, with good effect. 

 

Hope this helps you.

 

View solution in original post

0 Likes
Highlighted
Absent Member.. Absent Member..
Absent Member..

Re: How to query UCMDB by CIT in Jython discovery script

Jump to solution

Thank you so much, I'll modify my script to model your suggestion and go from there. Thanks for the help towards a solution.

 

I was thinking the secret may be in the trigger TQL but I was not sure how to utilize it.

0 Likes
Highlighted
Established Member..
Established Member..

Re: How to query UCMDB by CIT in Jython discovery script

Jump to solution
No problem
0 Likes
Highlighted
Micro Focus Frequent Contributor
Micro Focus Frequent Contributor

Re: How to query UCMDB by CIT in Jython discovery script

Jump to solution

Hi,

Can you please share a code sample how the array of servers returned by the input TQL?

Thanks and Regards
Jimmy

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.