Example #1
0
def reportStatus(severity, action, externalId, updateStatus, e):
    errorParams = ArrayList()
    errorParams.add(action)
    errorParams.add(externalId.toString())
    errorParams.add(e.toString())
    actionEnum = getActionEnumFromString(action)
    if(isinstance(externalId,ExternalCiId)):
        status = ReplicationActionDataFactory.createStatus(severity, 'Failed', ERROR_CODE_CI, errorParams,actionEnum);
        updateStatus.reportCIStatus(externalId, status)
    else:
        status = ReplicationActionDataFactory.createStatus(severity, 'Failed', ERROR_CODE_LINK, errorParams,actionEnum);
        updateStatus.reportRelationStatus(externalId, status);
Example #2
0
def reportStatus(severity, action, externalId, updateStatus, e):
    errorParams = ArrayList()
    errorParams.add(action)
    errorParams.add(externalId.toString())
    errorParams.add(e.toString())
    actionEnum = getActionEnumFromString(action)
    if isinstance(externalId, ExternalCiId):
        status = ReplicationActionDataFactory.createStatus(severity, "Failed", ERROR_CODE_CI, errorParams, actionEnum)
        updateStatus.reportCIStatus(externalId, status)
    else:
        status = ReplicationActionDataFactory.createStatus(severity, "Failed", ERROR_CODE_LINK, errorParams, actionEnum)
        updateStatus.reportRelationStatus(externalId, status)
Example #3
0
def DiscoveryMain(Framework):

    addResult = Framework.getTriggerCIData('addResult')
    updateResult = Framework.getTriggerCIData('updateResult')
    deleteResult = Framework.getTriggerCIData('deleteResult')
    addRefResult = Framework.getTriggerCIData('referencedAddResult')
    updateRefResult = Framework.getTriggerCIData('referencedUpdateResult')
    deleteRefResult = Framework.getTriggerCIData('referencedDeleteResult')


    logger.info('addResult: ')
    logger.info(addResult)
    logger.info('updateResult: ')
    logger.info(updateResult)
    logger.info('deleteResult: ')
    logger.info(deleteResult)
    saxBuilder = SAXBuilder()
    addXml = saxBuilder.build(StringReader(addResult))
    updateXml = saxBuilder.build(StringReader(updateResult))
    deleteXml = saxBuilder.build(StringReader(deleteResult))
    addRefXml = saxBuilder.build(StringReader(addRefResult))
    updateRefXml = saxBuilder.build(StringReader(updateRefResult))
    deleteRefXml = saxBuilder.build(StringReader(deleteRefResult))

    objectMappings = HashMap()
    linkMappings = HashMap()

    #The update status is used to report status of CIs and Links.
    updateStatus = ReplicationActionDataFactory.createUpdateStatus();

    credentialsId = str(Framework.getTriggerCIData('credentialsId'))
    serverName = Framework.getTriggerCIData('ip_address')
    port = Integer.valueOf(Framework.getTriggerCIData('port'))
    customerId = Framework.getTriggerCIData('customerId')
    isTestConnection = Framework.getTriggerCIData('testConnection')
    protocol = ProtocolDictionaryManager.getProtocolById(credentialsId)
    userName = protocol.getProtocolAttribute('protocol_username')
    password = protocol.getProtocolAttribute('protocol_password')
    dbType = Framework.getTriggerCIData('dbtype')

    conn = None
    if(dbType == 'Oracle'):
        #The SID is under Schema Name / SID in the integration point parameters.
        sid = Framework.getTriggerCIData('schemaName')
        conn = createOracleConnection(serverName, port, sid, userName, password)
    elif(dbType == 'SQLServer'):
        schemaName = Framework.getTriggerCIData('schemaName')
        conn = createSQLServerConnection(serverName, port, schemaName,userName, password)

    client = SQLClient(conn)

    allChildren = addXml.getRootElement().getChild('data')
    doAction(client, allChildren, objectMappings, linkMappings, addRefXml, ADD, updateStatus)

    allChildren = updateXml.getRootElement().getChild('data')
    doAction(client, allChildren, objectMappings, linkMappings, updateRefXml, UPDATE, updateStatus)

    allChildren = deleteXml.getRootElement().getChild('data')
    doAction(client, allChildren, objectMappings, linkMappings, deleteRefXml, DELETE, updateStatus)

    client.closeConnection()

    result = DataPushResultsFactory.createDataPushResults(objectMappings, linkMappings, updateStatus);
    return result
Example #4
0
def DiscoveryMain(Framework):

    addResult = Framework.getTriggerCIData("addResult")
    updateResult = Framework.getTriggerCIData("updateResult")
    deleteResult = Framework.getTriggerCIData("deleteResult")
    addRefResult = Framework.getTriggerCIData("referencedAddResult")
    updateRefResult = Framework.getTriggerCIData("referencedUpdateResult")
    deleteRefResult = Framework.getTriggerCIData("referencedDeleteResult")

    logger.info("addResult: ")
    logger.info(addResult)
    logger.info("updateResult: ")
    logger.info(updateResult)
    logger.info("deleteResult: ")
    logger.info(deleteResult)
    saxBuilder = SAXBuilder()
    addXml = saxBuilder.build(StringReader(addResult))
    updateXml = saxBuilder.build(StringReader(updateResult))
    deleteXml = saxBuilder.build(StringReader(deleteResult))
    addRefXml = saxBuilder.build(StringReader(addRefResult))
    updateRefXml = saxBuilder.build(StringReader(updateRefResult))
    deleteRefXml = saxBuilder.build(StringReader(deleteRefResult))

    objectMappings = HashMap()
    linkMappings = HashMap()

    # The update status is used to report status of CIs and Links.
    updateStatus = ReplicationActionDataFactory.createUpdateStatus()

    credentialsId = str(Framework.getTriggerCIData("credentialsId"))
    serverName = Framework.getTriggerCIData("ip_address")
    port = Integer.valueOf(Framework.getTriggerCIData("port"))
    customerId = Framework.getTriggerCIData("customerId")
    isTestConnection = Framework.getTriggerCIData("testConnection")
    protocol = ProtocolDictionaryManager.getProtocolById(credentialsId)
    userName = protocol.getProtocolAttribute("protocol_username")
    password = protocol.getProtocolAttribute("protocol_password")
    dbType = Framework.getTriggerCIData("dbtype")

    conn = None
    if dbType == "Oracle":
        # The SID is under Schema Name / SID in the integration point parameters.
        sid = Framework.getTriggerCIData("schemaName")
        conn = createOracleConnection(serverName, port, sid, userName, password)
    elif dbType == "SQLServer":
        schemaName = Framework.getTriggerCIData("schemaName")
        conn = createSQLServerConnection(serverName, port, schemaName, userName, password)

    client = SQLClient(conn)

    allChildren = addXml.getRootElement().getChild("data")
    doAction(client, allChildren, objectMappings, linkMappings, addRefXml, ADD, updateStatus)

    allChildren = updateXml.getRootElement().getChild("data")
    doAction(client, allChildren, objectMappings, linkMappings, updateRefXml, UPDATE, updateStatus)

    allChildren = deleteXml.getRootElement().getChild("data")
    doAction(client, allChildren, objectMappings, linkMappings, deleteRefXml, DELETE, updateStatus)

    client.closeConnection()

    result = DataPushResultsFactory.createDataPushResults(objectMappings, linkMappings, updateStatus)
    return result