import ci to ucmdb from xml file

Hello, I'm developing a custom discovery pattern which reads from xml a list of ci and import them into ucmdb.
Do you know how to query ucmdb from jython to get the ucmdbID of already inserted cis? (this is useful to create link between ci in ucmdb and ci to be inserted)

thanks,
Diego

 

 

P.S. This thread has been moevd from Application Perf Mgmt (BAC / BSM) Support and News Forum to CMS and Discovery Support and News Forum. - Hp Forum Moderator

  • Diego,
    I don't have a solution for you but a question/favor. I'm looking to do the same for my company, that is to import CIs into the uCMDB from a CSV or XML file. Can you share your custom pattern when finished?
  • Ask your HP rep. for the Service center 6.2/Service Manager 7.0 discovery pattern.

    This pattern works with data import from a SC generated XML file.

    Jan Hansen
  • Code for creating HOSTS:
    #####
    import logger
    import modeling
    import EMS_modeling

    # Java imports
    from java.lang import *
    from java.util import *
    from appilog.common.system.types.vectors import ObjectStateHolderVector
    from appilog.common.system.types import ObjectStateHolder
    from appilog.common.system.types import AttributeStateHolder
    from appilog.common.system.types import ObjectStateHolder
    from appilog.common.system.types import AttributeStateHolder
    from appilog.collectors.util import DomainScopeManager

    ####
    ####
    #### Main Body Here
    ####
    ####

    def DiscoveryMain(Framework):
    global OSHVResult
    OSHVResult = ObjectStateHolderVector()

    hostOSH = EMS_modeling.createHostOSH(Framework)
    OSHVResult.add(hostOSH)

    monitorId = String.valueOf(hostOSH.getAttribute("host_dnsname").getValue())
    monitorSource = Framework.getDestinationAttribute("data_source")
    monitorOSH = EMS_modeling.createMonitorOSH(monitorId, monitorSource, "host")
    OSHVResult.add(monitorOSH)

    linkMonitorHostOSH = modeling.createLinkOSH("monitored_by",hostOSH,monitorOSH)
    OSHVResult.add(linkMonitorHostOSH)

    ### change it so we set here the monitor OSH.

    monitoredCIType = String.valueOf(monitorOSH.getAttribute("monitored_ci_type").getValue())
    Framework.setUserObject("result_object", monitoredCIType)

    return OSHVResult
    ###

    Code for mapping application to hosts:
    ###import logger
    import modeling
    import EMS_modeling

    # Java imports
    from java.lang import *
    from java.util import *
    from appilog.common.system.types.vectors import ObjectStateHolderVector
    from appilog.common.system.types import ObjectStateHolder
    from appilog.common.system.types import AttributeStateHolder
    from appilog.common.system.types import ObjectStateHolder
    from appilog.common.system.types import AttributeStateHolder


    ####
    ####
    #### Main Body Here
    ####
    ####

    def DiscoveryMain(Framework):
    global OSHVResult
    OSHVResult = ObjectStateHolderVector()

    monitorSource = Framework.getDestinationAttribute("data_source")

    hostOSH = EMS_modeling.createHostOSH(Framework)
    OSHVResult.add(hostOSH)

    subject = Framework.getDestinationAttribute("subject")

    ### EDIT THIS: Application CIs are created for all applications except "system"
    if (subject != "system"):
    appOSH = EMS_modeling.createAppOSH(Framework)
    OSHVResult.add(appOSH)

    appName = String.valueOf(appOSH.getAttribute("data_name").getValue())
    monitorAppOSH = EMS_modeling.createMonitorOSH(appName, monitorSource, "logical_application")
    OSHVResult.add(monitorAppOSH)

    linkAppMonitorOSH = modeling.createLinkOSH("monitored_by", appOSH, monitorAppOSH)
    linkAppHostOSH = modeling.createLinkOSH("depends_on", appOSH, hostOSH)

    OSHVResult.add(linkAppMonitorOSH)
    OSHVResult.add(linkAppHostOSH)

    monitoredCIType = String.valueOf(monitorAppOSH.getAttribute("monitored_ci_type").getValue())
    else:
    monitorId = String.valueOf(hostOSH.getAttribute("host_dnsname").getValue())
    monitorHostOSH = EMS_modeling.createMonitorOSH(monitorId, monitorSource, "host")
    OSHVResult.add(monitorHostOSH)

    linkHostMonitorOSH = modeling.createLinkOSH("monitored_by", hostOSH, monitorHostOSH)
    OSHVResult.add(linkHostMonitorOSH)

    monitoredCIType = String.valueOf(monitorHostOSH.getAttribute("monitored_ci_type").getValue())

    Framework.setUserObject("result_object", monitoredCIType)
    return OSHVResult
    ###
  • please share your custom discovery zip file

    thx
  • Hellow all,

    I would like to know if this file xls must have an special format.

    Thanks.
  • Tomer, Can you share more information about your script? I think that there is about 4 pelple in this thread alone that would like more information. Can you post the Package Zip file and a sample of your XML file?
  • I've been able to create a py script that will read in a CSV file but I can't get it to work w/ the uCMDB because the uCMDB's version of jython does not include the "minidom" class. Does anyone know how to upgrade jython or install the minidom class in the uCMDB?
  • Has anybody got working pattern and script for getting data from files?
    For UCMDB newbie to customize?
    Thanks
    Libor
  • Hi all,

    I have the same problem of other guys. I'd like to import in my uCMDB data from an existing csv file or from an excel file. I'd like to learn how to do this. Could someone explain me the basic step and suggest me how to write the discovery pattern?
    Thanks a lot in advance

    Elena
  • Well, we are using the uCMDB API to read form both a database table and "|" delimited csv file. The API is being used via a java jar file and is running very smoothly on our Sun Solaris box. It uses an XML file as a config file, to point what it reads from the database and CSV file to the correct attribute in the uCMDB. I'll see if I can get a copy of our JAR file and post it here.