Highlighted
Trusted Contributor.. Trusted Contributor..
Trusted Contributor..
155 views

jython script to load CIs with root container as key attribute

Jump to solution

Hello,

Currently I am trying to load CIs of CI Type PowerDistributionUnit for which the reconciliation rule is the combination of key attributes - 'name' and 'root_container'. As root_container is the key attribute, I have also added CI of type 'datacenter' and tried creating composition relationship in between those two. My code looks something like this.

dataCenterOsh = None
dataCenterOsh = ObjectStateHolder('datacenter')
dataCenterOsh.setAttribute('name','testDataCenter')
vector.add(dataCenterOsh)
vectorCounter+=1
pduOsh = None
pduOsh = ObjectStateHolder('power_distribution_unit')
pduOsh.setAttribute('name','testPDU')
endHostCompositionRel = modeling.createLinkOSH('composition', dataCenterOsh, pduOsh)
vector.add(pduOsh)
vectorCounter+=1
vector.add(endHostCompositionRel)
vectorCounter+=1
if vectorCounter >= 10:
logger.debug("Sending Chunk to UCMDB of ", str(vectorCounter))
localFramework.sendObjects(vector)
localFramework.flushObjects()
vector.clear()
vectorCounter=0

I get the following error while executing the integration job that executes this script.

received object of class 'power_distribution_unit' has no required attribute 'root_container'
at com.hp.ucmdb.discovery.common.results.RequiredAttributesValidator.checkObligatoryAttributes(RequiredAttributesValidator.java:76)
at com.hp.ucmdb.discovery.common.results.RequiredAttributesValidator.checkForIDAttributes(RequiredAttributesValidator.java:41)
at com.hp.ucmdb.discovery.library.results.resultprocess.ResultProcessDataValidator.filterInvalidObjects(ResultProcessDataValidator.java:109)
at com.hp.ucmdb.discovery.library.results.resultprocess.ResultProcessDataValidator.doProcess(ResultProcessDataValidator.java:83)
at com.hp.ucmdb.discovery.library.results.resultprocess.ResultProcess.process(ResultProcess.java:23)
at com.hp.ucmdb.discovery.library.results.resultprocess.ResultProcessChain.doProcess(ResultProcessChain.java:53)
at com.hp.ucmdb.discovery.probe.agents.probemgr.discoveryscheduler.ResultSenderImpl.processResult(ResultSenderImpl.java:191)
at com.hp.ucmdb.discovery.probe.agents.probemgr.discoveryscheduler.ResultSenderImpl.processResults(ResultSenderImpl.java:141)
at com.hp.ucmdb.discovery.probe.agents.probemgr.discoveryscheduler.ResultSenderImpl.processResults(ResultSenderImpl.java:119)
at com.hp.ucmdb.discovery.probe.services.dynamic.core.DynamicService.discover(DynamicService.java:98)
at com.hp.ucmdb.discovery.probe.agents.probemgr.taskexecuter.JobExecuter.launchTask(JobExecuter.java:1270)
at com.hp.ucmdb.discovery.probe.agents.probemgr.taskexecuter.JobExecuter$JobExecuterWorker.launchAndIsProbeRestarting(JobExecuter.java:995)
at com.hp.ucmdb.discovery.probe.agents.probemgr.taskexecuter.JobExecuter$JobExecuterWorker.executeTask(JobExecuter.java:908)
at com.hp.ucmdb.discovery.probe.agents.probemgr.taskexecuter.JobExecuter$JobExecuterWorker.run(JobExecuter.java:754)

 

How to populate PDU CIs incase for which the CI Class has reconciliation rule with key attributes - name and root_container?

Thank you,

Kartik

0 Likes
1 Solution

Accepted Solutions
Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

No. GetIDMapping is for something else.

Now that I looked on that documentation page, it's not that accurate.

You need to set the container

dataCenterOsh = None
dataCenterOsh = ObjectStateHolder('datacenter')
dataCenterOsh.setAttribute('name','testDataCenter')
vector.add(dataCenterOsh)
vectorCounter+=1
pduOsh = None
pduOsh = ObjectStateHolder('power_distribution_unit')
pduOsh.setAttribute('name','testPDU')

pduOsh.setContainer(dataCenterOsh)
endHostCompositionRel = modeling.createLinkOSH('composition', dataCenterOsh, pduOsh)
vector.add(pduOsh)
vectorCounter+=1
vector.add(endHostCompositionRel)
vectorCounter+=1
if vectorCounter >= 10:
logger.debug("Sending Chunk to UCMDB of ", str(vectorCounter))
localFramework.sendObjects(vector)
localFramework.flushObjects()

 

 

Kind regards,
Bogdan Mureșan
EMEA CMS Technical Success

View solution in original post

5 Replies
Highlighted
Acclaimed Contributor.
Acclaimed Contributor.
Hello Kartik,

so I don't see in your code where do you set the container for the pdu...
Kind regards,
Bogdan Mureșan
EMEA CMS Technical Success
0 Likes
Highlighted
Trusted Contributor.. Trusted Contributor..
Trusted Contributor..

Hi John,

Thanks for the reply.

I understood that root_container can be set through getIdMapping 

https://docs.microfocus.com/UCMDB/11.0/ucmdb-docs/docs/eng/doc_lib/Content/devref/JythonAdaps_t_ScriptResults.htm

Here, I see that a method 'getIdMapping' can be used to set root_container attribute but I don't see clear documentation.

Would be a great help if you can provide me some reference/example so I can proceed.

 

Thank you in advance,

Kartik

0 Likes
Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

No. GetIDMapping is for something else.

Now that I looked on that documentation page, it's not that accurate.

You need to set the container

dataCenterOsh = None
dataCenterOsh = ObjectStateHolder('datacenter')
dataCenterOsh.setAttribute('name','testDataCenter')
vector.add(dataCenterOsh)
vectorCounter+=1
pduOsh = None
pduOsh = ObjectStateHolder('power_distribution_unit')
pduOsh.setAttribute('name','testPDU')

pduOsh.setContainer(dataCenterOsh)
endHostCompositionRel = modeling.createLinkOSH('composition', dataCenterOsh, pduOsh)
vector.add(pduOsh)
vectorCounter+=1
vector.add(endHostCompositionRel)
vectorCounter+=1
if vectorCounter >= 10:
logger.debug("Sending Chunk to UCMDB of ", str(vectorCounter))
localFramework.sendObjects(vector)
localFramework.flushObjects()

 

 

Kind regards,
Bogdan Mureșan
EMEA CMS Technical Success

View solution in original post

Highlighted
Trusted Contributor.. Trusted Contributor..
Trusted Contributor..
Thank you Bogdan. It worked. Is there any documentation available online related to these kind of APIs?
Highlighted
Acclaimed Contributor.
Acclaimed Contributor.
Glad that it worked.
But this is not API related. This is pure Jython scripting that we do for integrations and discovery.
I know that we have documentation for Jython scripting and we do offer UDC on Marketplace in order to work a little bit eaiser.
Kind regards,
Bogdan Mureșan
EMEA CMS Technical Success
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.