Exemplo n.º 1
0
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
Exemplo n.º 2
0
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
Exemplo n.º 3
0
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
Exemplo n.º 4
0
def DiscoveryMain(Framework):
    OSHVResult = ObjectStateHolderVector()
    businessElementId = Framework.getDestinationAttribute('id')
    urlString = Framework.getDestinationAttribute('url')
    jobId = Framework.getDiscoveryJobId()
    dnsServers = Framework.getParameter('dnsServers') or None
    shell = None

    if dnsServers:
        dnsServers = [
            dnsServer for dnsServer in dnsServers.split(',')
            if dnsServer and dnsServer.strip()
        ] or None
    if dnsServers:
        logger.debug('Using dns servers: ', dnsServers)

    if not urlString:
        msg = "There is no specified URL in the input BusinessElement CI"
        errormessages.resolveAndReport(msg, jobId, Framework)
        return OSHVResult

    try:
        bizOSH = modeling.createOshByCmdbIdString('business_element',
                                                  businessElementId)
        OSHVResult.add(bizOSH)
        urlString = urlString[1:len(urlString) - 1]

        if netutils.isValidIp(urlString):
            productName = Framework.getDestinationAttribute('product')
            OSHVResult.add(
                scp.createScpOsh(bizOSH, 'tcp', urlString, 0, productName))
        else:
            protocol, hostname, port, context = parseUrl(urlString)
            if not hostname:
                raise ValueError("Hostname is not defined in URL '%s'" %
                                 urlString)

            if not protocol:
                raise ValueError(
                    "Failed to resolve the protocol from specified URL")

            shell = shellutils.ShellUtils(
                Framework.createClient(
                    ClientsConsts.LOCAL_SHELL_PROTOCOL_NAME))
            OSHVResult.addAll(
                scp.createScpOSHV(bizOSH,
                                  protocol,
                                  hostname,
                                  port,
                                  context,
                                  shell,
                                  dnsServers=dnsServers))

    except ValueError, e:
        errormessages.resolveAndReport(e.message, jobId, Framework)
def DiscoveryMain(Framework):
    OSHVResult = ObjectStateHolderVector()
    businessElementId = Framework.getDestinationAttribute('id')
    urlString = Framework.getDestinationAttribute('url')
    jobId = Framework.getDiscoveryJobId()
    dnsServers = Framework.getParameter('dnsServers') or None
    shell = None

    if dnsServers:
        dnsServers = [dnsServer for dnsServer in dnsServers.split(',') if dnsServer and dnsServer.strip()] or None
    if dnsServers:
        logger.debug('Using dns servers: ', dnsServers)

    if not urlString:
        msg = "There is no specified URL in the input BusinessElement CI"
        errormessages.resolveAndReport(msg, jobId, Framework)
        return OSHVResult

    try:
        bizOSH = modeling.createOshByCmdbIdString('business_element', businessElementId)
        OSHVResult.add(bizOSH)
        urlString = urlString[1:len(urlString) - 1]

        if netutils.isValidIp(urlString):
            productName = Framework.getDestinationAttribute('product')
            OSHVResult.add(scp.createScpOsh(bizOSH, 'tcp', urlString, 0, productName))
        else:
            protocol, hostname, port, context = parseUrl(urlString)
            if not hostname:
                raise ValueError("Hostname is not defined in URL '%s'" % urlString)

            if not protocol:
                raise ValueError("Failed to resolve the protocol from specified URL")

            shell = shellutils.ShellUtils(Framework.createClient(ClientsConsts.LOCAL_SHELL_PROTOCOL_NAME))
            OSHVResult.addAll(scp.createScpOSHV(bizOSH, protocol, hostname, port, context, shell, dnsServers=dnsServers))

    except ValueError, e:
        errormessages.resolveAndReport(e.message, jobId, Framework)