The community will be in read-only from Tuesday 11:59pm (PST) to Wednesday noon (PST)
The community will be in read-only from Tuesday 11:59pm (PST) to Wednesday noon (PST)
UCMDB and UD Practitioners Forum (Previously CMS)
Showing results for 
Search instead for 
Did you mean: 

HP uCMDB : Need help with ObjectStateHolder Syntax for a custom Jython script


HP uCMDB : Need help with ObjectStateHolder Syntax for a custom Jython script

Hello experts,


I have a discovery script that determines custom attribute values using external resources and updates the CMDB.

One such attribute is of data type, string_list. I'd like to know what the syntax is, for sending the results as a string list and not as a string. Page 48 on UCMDB9.05_DevelopersRef.pdf didn't give me the answer I was looking for.


Error thrown when result is sent as;
1: hostOSH.setAttributeToList('custom_host_test_6',"")

2: hostOSH.setString_listAttribute('custom_host_test_6',"")

3: hostOSH.setStringAttributeAsList('custom_host_test_6',"")

<< Progress message, Severity: Error>>
Failed executing script, details: Traceback (innermost last):
  File "<string>", line 2, in ?
  File "XYZ_NodeAttributes_Network", line 82, in DiscoveryMain
AttributeError: setAttributeToList


When I use String, it obviously doesn't work either.
<< Progress message, Severity: Error>>
Error processing results of discovery adapter, details Attribute custom_host_test_6 of object <?xml version="1.0" encoding="UTF-8"?><object id="47748b831aa231c8c424024d327585c3" id_type="CmdbObjectID" class="wireless_ap" isReference="false" anchor_id="null" is_anchor="false"><attribute name="custom_host_test_3" type="String"></attribute><attribute name="custom_host_test_2" type="String"></attribute><attribute name="custom_host_test_1" type="String"></attribute><attribute name="custom_host_test_6" type="String"></attribute><attribute name="custom_host_test_5" type="String"></attribute><attribute name="custom_host_test_4" type="String"></attribute></object> of wrong type;should be string_list but reported String
    at com.hp.ucmdb.discovery.library.results.resultprocess.ResultProcessDataValidator.checkAttributeType(
    at com.hp.ucmdb.discovery.library.results.resultprocess.ResultProcessDataValidator.checkAttributes(
    at com.hp.ucmdb.discovery.library.results.resultprocess.ResultProcessDataValidator.filterInvalidObjects(
    at com.hp.ucmdb.discovery.library.results.resultprocess.ResultProcessDataValidator.doProcess(
    at com.hp.ucmdb.discovery.library.results.resultprocess.ResultProcess.process(
    at com.hp.ucmdb.discovery.library.results.resultprocess.ResultProcessChain.doProcess(
    at com.hp.ucmdb.discovery.probe.agents.probemgr.discoveryscheduler.ResultSenderImpl.processResult(
    at com.hp.ucmdb.discovery.probe.agents.probemgr.discoveryscheduler.ResultSenderImpl.processResults(
    at com.hp.ucmdb.discovery.probe.agents.probemgr.taskexecuter.JobExecuter.launchTask(
    at com.hp.ucmdb.discovery.probe.agents.probemgr.taskexecuter.JobExecuter$JobExecuterWorker.launch(
    at com.hp.ucmdb.discovery.probe.agents.probemgr.taskexecuter.JobExecuter$JobExecuterWorker.executeTask(
    at com.hp.ucmdb.discovery.probe.agents.probemgr.taskexecuter.JobExecuter$
This is the piece of code I'm working on. The first few attributes are of data type, string and they work fine.
# To Clear out all the test Attributes Set Clear_Out to Y
    Clear_Out = "Y"
    if Clear_Out == "Y":
       hostOSH.setStringAttribute('custom_host_test_6',"")"All Test Attributes Cleared")     
       return OSHVResult

Please see attached screenshot.





Re: HP uCMDB : Need help with ObjectStateHolder Syntax for a custom Jython script

I figured a couple ways to do it:

The easiest is probably to create a list of the values in a list variable, then use the OSH method setListAttribute(name, list_of_values)
Please note that when using setListAttribute, the existing list values will be blown away, i.e. the list you build will replace the old list, not add to it.

Another way would be to also use AttributeStateHolder objects,. AttributeStateHolder is more flexible, but more baggage then generally needed.




//Add this to "OnDomLoad" event