def DiscoveryMain(Framework): OSHVResult = ObjectStateHolderVector() # # Write implementation to return new result CIs here... ipList = Framework.getTriggerCIDataAsList('PHYSICAL_IP_ADDRESS') portList = Framework.getTriggerCIDataAsList('PHYSICAL_PORT') service_context = Framework.getDestinationAttribute('SERVICE_CONTEXT') service_type = Framework.getDestinationAttribute('SERVICE_TYPE') cluster_id = Framework.getDestinationAttribute('CLUSTER_ID') application_resource_id = Framework.getDestinationAttribute( 'APPLICATION_RESOURCE_ID') cluster_root_class = Framework.getDestinationAttribute('CLUSTER_CLASS') application_resource_class = Framework.getDestinationAttribute( 'APPLICATION_RESOURCE_CLASS') SCPId = Framework.getDestinationAttribute('id') clusterOsh = modeling.createOshByCmdbIdString(cluster_root_class, cluster_id) OSHVResult.addAll( scp.createCPLink(application_resource_id, application_resource_class, cluster_id, cluster_root_class, SCPId, service_context)) for index in range(len(ipList)): scpOsh = scp.createScpOsh(clusterOsh, service_type, ip=ipList[index], port=portList[index], context=service_context) ipOsh = modeling.createIpOSH(ipList[index]) OSHVResult.add(scpOsh) OSHVResult.add(ipOsh) return OSHVResult
def DiscoveryMain(Framework): OSHVResult = ObjectStateHolderVector() # # Write implementation to return new result CIs here... ipList = Framework.getTriggerCIDataAsList('PHYSICAL_IP_ADDRESS') portList = Framework.getTriggerCIDataAsList('PHYSICAL_PORT') service_context = Framework.getDestinationAttribute('SERVICE_CONTEXT') service_type = Framework.getDestinationAttribute('SERVICE_TYPE') application_resource_id = Framework.getDestinationAttribute('APPLICATION_RESOURCE_ID') application_resource_class = Framework.getDestinationAttribute('APPLICATION_RESOURCE_CLASS') junction_id = Framework.getDestinationAttribute('JUNCTION_ID') junction_root_class = Framework.getDestinationAttribute('JUNCTION_CLASS') junction_name = Framework.getDestinationAttribute('JUNCTION_NAME') SCPId = Framework.getDestinationAttribute('id') junctionOsh = modeling.createOshByCmdbIdString(junction_root_class, junction_id) url = urlparse(service_context) if url: # get context root path from url path = url.path if path.startswith(junction_name + '/'): logger.info('Create one consumer-provider link between application and junction') OSHVResult.addAll(scp.createCPLink(application_resource_id, application_resource_class, junction_id, junction_root_class, SCPId, service_context)) for index in range(len(ipList)): scpOsh = scp.createScpOsh(junctionOsh, service_type, ip=ipList[index], port=portList[index], context=service_context) logger.info('Create scp with ip %s and port %s' % (ipList[index], portList[index])) ipOsh = modeling.createIpOSH(ipList[index]) OSHVResult.add(scpOsh) OSHVResult.add(ipOsh) return OSHVResult
def DiscoveryMain(Framework): OSHVResult = ObjectStateHolderVector() # # Write implementation to return new result CIs here... ipList = Framework.getTriggerCIDataAsList('PHYSICAL_IP_ADDRESS') portList = Framework.getTriggerCIDataAsList('PHYSICAL_PORT') service_context = Framework.getDestinationAttribute('SERVICE_CONTEXT') service_type = Framework.getDestinationAttribute('SERVICE_TYPE') cluster_id = Framework.getDestinationAttribute('CLUSTER_ID') application_resource_id = Framework.getDestinationAttribute('APPLICATION_RESOURCE_ID') cluster_root_class = Framework.getDestinationAttribute('CLUSTER_CLASS') application_resource_class = Framework.getDestinationAttribute('APPLICATION_RESOURCE_CLASS') SCPId = Framework.getDestinationAttribute('id') clusterOsh = modeling.createOshByCmdbIdString(cluster_root_class, cluster_id) OSHVResult.addAll(scp.createCPLink(application_resource_id, application_resource_class, cluster_id, cluster_root_class, SCPId, service_context)) for index in range(len(ipList)): scpOsh = scp.createScpOsh(clusterOsh, service_type, ip=ipList[index], port=portList[index], context=service_context) ipOsh = modeling.createIpOSH(ipList[index]) OSHVResult.add(scpOsh) OSHVResult.add(ipOsh) return OSHVResult
def DiscoveryMain(Framework): OSHVResult = ObjectStateHolderVector() clientId = Framework.getDestinationAttribute('CLIENT_ID') clientClass = Framework.getDestinationAttribute('CLIENT_CLASS') accDatabaseIds = Framework.getTriggerCIDataAsList('ACC_DB_ID') accDatabaseClasses = Framework.getTriggerCIDataAsList('ACC_DB_CLASS') serverIds = Framework.getTriggerCIDataAsList('SERVER_ID') context = Framework.getDestinationAttribute('CONTEXT') SCPId = Framework.getDestinationAttribute('id') serverIdsHaveLink = Framework.getTriggerCIDataAsList('SERVER_ID_HAVE_LINK') serverIdsShouldHaveLink = Framework.getTriggerCIDataAsList( 'SERVER_ID_SHOULD_HAVE_LINK') serverClassesHaveLink = Framework.getTriggerCIDataAsList( 'SERVER_CLASS_HAVE_LINK') acclinks = 0 index = 0 logger.debug("Try to create dependency using database name: ", context) for accDatabaseId in accDatabaseIds: if accDatabaseId and accDatabaseId != clientId: accDatabaseClass = accDatabaseClasses[index] logger.debug("Creating CP link to database: ", accDatabaseId) OSHVResult.addAll( scp.createCPLink(clientId, clientClass, accDatabaseId, accDatabaseClass, SCPId, context)) acclinks += 1 index += 1 if acclinks == 0: logger.debug( "No accurate dependency found, using port to do dependency") for serverId in serverIds: if serverId and serverId != clientId: logger.debug("creating cp-link for ci:", serverId) OSHVResult.addAll( scp.createCPLink(clientId, clientClass, serverId, 'running_software', SCPId, context)) logger.debug("check if there is cp link need to be deleted") clientOsh = ObjectStateHolder( clientClass, CmdbObjectID.Factory.restoreObjectID(clientId)) scp.deleteDependencies(Framework, clientOsh, serverIdsHaveLink, serverIdsShouldHaveLink, serverClassesHaveLink) return OSHVResult
def DiscoveryMain(Framework): OSHVResult = ObjectStateHolderVector() clientId = Framework.getDestinationAttribute('CLIENT_ID') clientClass = Framework.getDestinationAttribute('CLIENT_CLASS') accDatabaseIds = Framework.getTriggerCIDataAsList('ACC_DB_ID') accDatabaseClasses = Framework.getTriggerCIDataAsList('ACC_DB_CLASS') serverIds = Framework.getTriggerCIDataAsList('SERVER_ID') context = Framework.getDestinationAttribute('CONTEXT') SCPId = Framework.getDestinationAttribute('id') serverIdsHaveLink = Framework.getTriggerCIDataAsList('SERVER_ID_HAVE_LINK') serverIdsShouldHaveLink = Framework.getTriggerCIDataAsList('SERVER_ID_SHOULD_HAVE_LINK') serverClassesHaveLink = Framework.getTriggerCIDataAsList('SERVER_CLASS_HAVE_LINK') acclinks = 0 index = 0 logger.debug("Try to create dependency using database name: ", context) for accDatabaseId in accDatabaseIds: if accDatabaseId and accDatabaseId != clientId: accDatabaseClass = accDatabaseClasses[index] logger.debug("Creating CP link to database: ", accDatabaseId) OSHVResult.addAll(scp.createCPLink(clientId, clientClass, accDatabaseId, accDatabaseClass, SCPId, context)) acclinks += 1 index += 1 if acclinks == 0: logger.debug("No accurate dependency found, using port to do dependency") for serverId in serverIds: if serverId and serverId != clientId: logger.debug("creating cp-link for ci:", serverId) OSHVResult.addAll(scp.createCPLink(clientId, clientClass, serverId, 'running_software', SCPId, context)) logger.debug("check if there is cp link need to be deleted") clientOsh = ObjectStateHolder(clientClass, CmdbObjectID.Factory.restoreObjectID(clientId)) scp.deleteDependencies(Framework, clientOsh, serverIdsHaveLink, serverIdsShouldHaveLink, serverClassesHaveLink) return OSHVResult