Ejemplo n.º 1
0
def _isIPInCurrentDomain(ipAddress):
    if ipAddress:
        currentDomainName = DomainScopeManager.getCurrentDomainName()
        ipBelongsDomainName = DomainScopeManager.getDomainByIp(ipAddress)
        return (currentDomainName and ipBelongsDomainName
                and currentDomainName == ipBelongsDomainName)
    else:
        return 0
Ejemplo n.º 2
0
def _isIPInCurrentDomain(ipAddress):
    if ipAddress:
        currentDomainName = DomainScopeManager.getCurrentDomainName()
        ipBelongsDomainName = DomainScopeManager.getDomainByIp(ipAddress)
        return (currentDomainName
            and ipBelongsDomainName
            and currentDomainName == ipBelongsDomainName)
    else:
        return 0
Ejemplo n.º 3
0
def getProbeName(ipaddr):
    if ipaddr and netutils.isValidIp(ipaddr):
        try:
            from com.hp.ucmdb.discovery.library.scope import DomainScopeManager
            domainName = DomainScopeManager.getDomainByIp(ipaddr)
            if not domainName:
                domainName = 'DefaultDomain'

            return DomainScopeManager.getProbeName(ipaddr, domainName)
        except:
            pass
    return None
Ejemplo n.º 4
0
def getProbeName(ipaddr):
    if ipaddr and netutils.isValidIp(ipaddr):       
        try:
            from com.hp.ucmdb.discovery.library.scope import DomainScopeManager
            domainName = DomainScopeManager.getDomainByIp(ipaddr)
            if not domainName:
                domainName = 'DefaultDomain'
            
            return DomainScopeManager.getProbeName(ipaddr, domainName)
        except:
            pass
    return None
Ejemplo n.º 5
0
 def _buildVirtualServerOsh(self):
     domainName = DomainScopeManager.getDomainByIp(self.ipAddress.strip())
     name = '%s:%s %s' % (self.ipAddress, self.port, domainName)
     virtualServerOsh = modeling.createCompleteHostOSH('clusteredservice', name, None, self.name)
     self.ipOSH = modeling.createIpOSH(self.ipAddress)
     self.linkIpOSH = modeling.createLinkOSH('contained', virtualServerOsh, self.ipOSH)
     self.osh = virtualServerOsh
Ejemplo n.º 6
0
 def _buildVirtualServerOsh(self):
     domainName = DomainScopeManager.getDomainByIp(self.ipAddress.strip())
     name = '%s:%s %s' % (self.ipAddress, self.port, domainName)
     virtualServerOsh = modeling.createCompleteHostOSH('clusteredservice', name, None, self.name)
     self.ipOSH = modeling.createIpOSH(self.ipAddress)
     self.linkIpOSH = modeling.createLinkOSH('contained', virtualServerOsh, self.ipOSH)
     self.osh = virtualServerOsh
Ejemplo n.º 7
0
def discoverIPData(client, ip_address):
    ipList = []
    try:
        discoveredIpDomain = DomainScopeManager.getDomainByIp(ip_address)
    except Exception, ex:
        strException  = str(ex.getMessage())
        logger.debugException('problem with domain search, Wrong ip definition' + strException)
        return ipList
Ejemplo n.º 8
0
 def build(self):
     domainName = DomainScopeManager.getDomainByIp(self.vServer.ip)
     name = '%s:%s %s' % (self.vServer.ip, self.vServer.port, domainName)
     vServerOsh = modeling.createCompleteHostOSH('cluster_resource_group', name, None, self.vServer.name)
     ipOSH = modeling.createIpOSH(self.vServer.ip)
     linkIpOSH = modeling.createLinkOSH('contained', vServerOsh, ipOSH)
     ownership_link = modeling.createLinkOSH('ownership', self.netscaler_software_osh, vServerOsh)
     vipServiceOsh = modeling.createServiceAddressOsh(vServerOsh, self.vServer.ip, self.vServer.port,
                                                      modeling.SERVICEADDRESS_TYPE_TCP, self.vServer.server_type)
     self.osh = vServerOsh
     return self.newVector(vServerOsh, ipOSH, ownership_link, linkIpOSH, vipServiceOsh)
Ejemplo n.º 9
0
def disHSRP(client, vector, hostOSH):
    snmpQuery = '1.3.6.1.4.1.9.9.106.1.2.1.1.11,1.3.6.1.4.1.9.9.106.1.2.1.2.12,string'
    table = client.executeQuery(snmpQuery)#@@CMD_PERMISION snmp protocol execution
    ilist = table.asTable()

    for ips in ilist:
        ipOSH = ObjectStateHolder('ip', 6)
        ipOSH.setAttribute(AttributeStateHolder('ip_address', ips[1]))
        domain = DomainScopeManager.getDomainByIp(ips[1], None)
        logger.debug('vip [' + ips[1] + '] domain [' + domain + ']')
        ipOSH.setAttribute(AttributeStateHolder('ip_domain', domain))
        ipOSH.setAttribute(AttributeStateHolder('data_note', 'HSRP VIP'))
        contained = HostKeyUtil.getLink('contained', hostOSH, ipOSH)
        vector.add(ipOSH)
        vector.add(contained)

    return vector
Ejemplo n.º 10
0
 def build(self):
     domainName = DomainScopeManager.getDomainByIp(self.vServer.ip)
     name = '%s:%s %s' % (self.vServer.ip, self.vServer.port, domainName)
     vServerOsh = modeling.createCompleteHostOSH('cluster_resource_group',
                                                 name, None,
                                                 self.vServer.name)
     ipOSH = modeling.createIpOSH(self.vServer.ip)
     linkIpOSH = modeling.createLinkOSH('contained', vServerOsh, ipOSH)
     ownership_link = modeling.createLinkOSH('ownership',
                                             self.netscaler_software_osh,
                                             vServerOsh)
     vipServiceOsh = modeling.createServiceAddressOsh(
         vServerOsh, self.vServer.ip, self.vServer.port,
         modeling.SERVICEADDRESS_TYPE_TCP, self.vServer.server_type)
     self.osh = vServerOsh
     return self.newVector(vServerOsh, ipOSH, ownership_link, linkIpOSH,
                           vipServiceOsh)
Ejemplo n.º 11
0
def buildVirtualHostOsh(oshv, f5, virtualHost):
    """
    @type oshv:         ObjectStateHolderVector
    @type f5:           ObjectStateHolder
    @type virtualHost:  VirtualHost
    @rtype: ObjectStateHolder
    """
    domainName = DomainScopeManager.getDomainByIp(virtualHost.getIp().strip())
    name = '%s:%s %s' % (virtualHost.getIp(), virtualHost.getPort(), domainName)
    virtualHostOsh = modeling.createCompleteHostOSH('cluster_resource_group', name, None, virtualHost.getName())
    #virtualHostOsh.setAttribute('name', virtualHost.getName())
    ipOsh = modeling.createIpOSH(virtualHost.getIp())
    oshv.add(modeling.createLinkOSH('containment', virtualHostOsh, ipOsh))

    ipPortOSH = buildIpServiceEndPointOsh(virtualHostOsh, virtualHost)
    # ipPortOSH.setContainer(virtualHostOsh)
    oshv.add(virtualHostOsh)
    oshv.add(ipOsh)
    oshv.add(ipPortOSH)
    oshv.add(modeling.createLinkOSH('owner', f5, virtualHostOsh))
    return virtualHostOsh
Ejemplo n.º 12
0
def buildVirtualHostOsh(oshv, f5, virtualHost):
    """
    @type oshv:         ObjectStateHolderVector
    @type f5:           ObjectStateHolder
    @type virtualHost:  VirtualHost
    @rtype: ObjectStateHolder
    """
    domainName = DomainScopeManager.getDomainByIp(virtualHost.getIp().strip())
    name = '%s:%s %s' % (virtualHost.getIp(), virtualHost.getPort(),
                         domainName)
    virtualHostOsh = modeling.createCompleteHostOSH('cluster_resource_group',
                                                    name, None,
                                                    virtualHost.getName())
    #virtualHostOsh.setAttribute('name', virtualHost.getName())
    ipOsh = modeling.createIpOSH(virtualHost.getIp())
    oshv.add(modeling.createLinkOSH('containment', virtualHostOsh, ipOsh))

    ipPortOSH = buildIpServiceEndPointOsh(virtualHostOsh, virtualHost)
    # ipPortOSH.setContainer(virtualHostOsh)
    oshv.add(virtualHostOsh)
    oshv.add(ipOsh)
    oshv.add(ipPortOSH)
    oshv.add(modeling.createLinkOSH('owner', f5, virtualHostOsh))
    return virtualHostOsh
Ejemplo n.º 13
0
def DiscoveryMain(Framework):

    OSHVResult = ObjectStateHolderVector()
    ms_domain_name = Framework.getDestinationAttribute('ms_domain_name')
    if not ms_domain_name:
        ms_domain_name = 'NULL'

    try:
        netUtil = MsNetworkUtil()
        hostsOutput = netUtil.doNetServerEnum('NULL', SV_TYPE_SERVER,
                                              ms_domain_name)
        if hostsOutput != None:
            discoverUnknownIPs = 1
            try:
                strDiscoverUnknownIPs = Framework.getParameter(
                    'discoverUnknownIPs')
                discoverUnknownIPs = Boolean.parseBoolean(
                    strDiscoverUnknownIPs)
            except:
                pass

            oshMsDomain = ObjectStateHolder('msdomain')
            oshMsDomain.setStringAttribute('data_name', ms_domain_name)
            alreadyDiscoveredIps = HashMap()
            for hostInfo in hostsOutput:
                hostType = Long(hostInfo[1]).longValue()
                hostName = (str(hostInfo[0])).lower()
                try:
                    ip = InetAddress.getByName(hostInfo[0]).getHostAddress()
                    if netutils.isLocalIp(ip):
                        continue
                    cachedHostName = alreadyDiscoveredIps.get(ip)
                    if cachedHostName != None:
                        logger.debug(
                            'IP ', ip,
                            ' already reported for host ' + cachedHostName,
                            ' current host ', hostName, ' - skipping')
                        continue
                    else:
                        logger.debug('Discovered IP ' + ip + ' for host ' +
                                     hostName)
                        alreadyDiscoveredIps.put(ip, hostName)
                    ipDomain = DomainScopeManager.getDomainByIp(ip)
                    if not discoverUnknownIPs and ipDomain == 'unknown':
                        logger.debug(
                            'ip: ' + ip +
                            ' is out of probe range and will be excluded')
                        continue
                    if SV_TYPE_CLUSTER_NT & hostType:
                        logger.debug(
                            'Not reporting the entry %s because it is a Cluster'
                            % hostName)
                        continue
                    hostOsType = 'nt'
                    if SV_TYPE_SERVER_UNIX & hostType:
                        hostOsType = 'unix'
                    oshHost = modeling.createHostOSH(ip, hostOsType)
                    oshHost.setStringAttribute("host_hostname", hostName)
                    OSHVResult.add(oshHost)

                    link = modeling.createLinkOSH('member', oshMsDomain,
                                                  oshHost)
                    OSHVResult.add(link)
                    ipOSH = modeling.createIpOSH(ip)
                    OSHVResult.add(ipOSH)
                    contained = modeling.createLinkOSH('contained', oshHost,
                                                       ipOSH)
                    OSHVResult.add(contained)
                except:
                    errorMsg = str(sys.exc_info()[1]).strip()
                    logger.warn('Failed to resolve host ', hostInfo[0], ' : ',
                                errorMsg)
        else:
            message = 'Failed to discover hosts on MS Domain'
            logger.warn(message)
            logger.reportWarning(message)
    except:
        errorMsg = str(sys.exc_info()[1]).strip()
        logger.errorException('Failed to discovery MS Domains')
        errorMessage = errormessages.makeErrorMessage(
            "msdomain", errorMsg,
            errormessages.ERROR_FAILED_DISCOVERING_MSDOMAIN_HOSTS)
        errobj = errorobject.createError(
            errorcodes.FAILED_DISCOVERIING_MSDOMAIN_HOST,
            ["msdomain", errorMsg], errorMessage)
        logger.reportErrorObject(errobj)
    return OSHVResult
Ejemplo n.º 14
0
    queryBuilder = snmputils.SnmpQueryBuilder(BASE_IP_OID)
    queryBuilder.addQueryElement(1, 'ipAddr')
    queryBuilder.addQueryElement(2, 'ipIfIndex')
    queryBuilder.addQueryElement(3, 'ipNetMask')
    
    ipListResult = snmpAgent.getSnmpData(queryBuilder)
    if (ipListResult == None) or (len(ipListResult) == 0):
        logger.warn('no data returned on query ', str(BASE_IP_OID))
    else: 
        for ip in ipListResult:
            if not isValidNetMask(str(ip.ipNetMask)):
                logger.warn('Received invalid netmask [', str(ip.ipNetMask),'] for ip ['+ ip.ipAddr +'], skipping')
            elif ip.ipAddr == None or len(ip.ipAddr) == 0:
                logger.warn('Received invalid ip: ' + ip.ipAddr + ', skipping')
            else:
                setattr(ip, 'domain',  DomainScopeManager.getDomainByIp(ip.ipAddr, discoveredIpDomain))
                setattr(ip, 'netaddr', str(IPv4(ip.ipAddr, ip.ipNetMask).getFirstIp()))
                ipv4 = IPv4("1.1.1.1", ip.ipNetMask)
                setattr(ip, 'netclass', ipv4.getIpClassName())
                ipList.append(ip)
    return ipList

def getInterfaceNameAndAlias(client, indx2if):
    logger.debug('Running ifname and ifalias')
    resultSet = client.executeQuery('1.3.6.1.2.1.31.1.1.1.1,1.3.6.1.2.1.31.1.1.1.2,string,1.3.6.1.2.1.31.1.1.1.18,string')

    table = resultSet.asTable()
    
    for rowIndex in range(len(table)):
        ifIndex = table[rowIndex][0]
        ifName = table[rowIndex][1]
Ejemplo n.º 15
0
def isIPNotInRange(ip):
    tag = DomainScopeManager.getRangeTypeByIp(ip)
    return not tag
Ejemplo n.º 16
0
def isClientTypeIP(ip):
    from com.hp.ucmdb.discovery.library.scope import DomainScopeManager
    from appilog.common.utils import RangeType

    tag = DomainScopeManager.getRangeTypeByIp(ip)
    return RangeType.CLIENT == tag
Ejemplo n.º 17
0
 def isIpOutOfScope(self, addr):
     return DomainScopeManager.isIpOutOfScope(addr)
Ejemplo n.º 18
0
def createRouteObjects(routeList, ifList, ip_address, host_id):
    routeArrayList = []
    routeObjects = ObjectStateHolderVector()
    
    for route in routeList:
        if route.ipRouteType and int(route.ipRouteType) != 4:
            continue
        if str(route.ipRouteNextHop).startswith('0.') or str(route.ipRouteNextHop).startswith('127.'):
            continue  
        if route.ipRouteIfIndex == 0:
            #Host (next hop)
            nextHopHostOSH = __createRouterIncompleteHostByIp(route.ipRouteNextHop)
            #Ip (next hop)
            nextHopIpOSH = modeling.createIpOSH(route.ipRouteNextHop)
            routeObjects.add(nextHopHostOSH)
            routeObjects.add(nextHopIpOSH)
            
        currIf = getInterfaceByIndex(ifList, route.ipRouteIfIndex)
            
        if not currIf:
            continue
        if len(currIf.ipList) == 0 or currIf.ipList[0].netaddr == None:
            #Host (next hop)
            nextHopHostOSH = __createRouterIncompleteHostByIp(route.ipRouteNextHop)
            #Ip (next hop)
            nextHopIpOSH = modeling.createIpOSH(route.ipRouteNextHop)
            discoveredHostOSH = modeling.createOshByCmdbId("host", host_id)
                
            unnumberedLinkOSHHostHost = modeling.createLinkOSH("unnumbered", discoveredHostOSH, nextHopHostOSH)
            #Add the next hop and the link
            routeObjects.add(nextHopHostOSH)
            routeObjects.add(nextHopIpOSH)
            routeObjects.add(unnumberedLinkOSHHostHost)
        else:
            for ip in currIf.ipList:
                nextHopNetAddress = IPv4(route.ipRouteNextHop, ip.ipNetMask).getFirstIp().toString()
                if nextHopNetAddress != ip.netaddr:
                    continue
                    
                nextHopIpDomain =  DomainScopeManager.getDomainByIp(route.ipRouteNextHop, ip.domain)
                routeFound = 0
                for currRoute in routeArrayList:
                    if currRoute['localIpAddress'] == ip.ipAddr and currRoute['localIpDomain'] == ip.domain and currRoute['nextHopIp'] == route.ipRouteNextHop and currRoute['nextHopIpDomain'] == nextHopIpDomain:
                        currRoute['destinationList'].append(route.ipRouteDest)
                        break
                    routeFound += 1
                if routeFound >= len(routeArrayList):
                    currRoute = {}
                    currRoute['destAddress'] = route.ipRouteDest
                    currRoute['destinationList'] = []
                    currRoute['destinationList'].append(route.ipRouteDest)
                    currRoute['ifIndex'] = route.ipRouteIfIndex
                    currRoute['localIpAddress'] = ip.ipAddr
                    currRoute['localIpDomain'] = ip.domain
                    currRoute['localIpMask'] = ip.ipNetMask
                    currRoute['localIpNetClass'] = ip.netclass
                    currRoute['nextHopNetAddr'] = nextHopNetAddress
                    currRoute['nextHopIp'] = route.ipRouteNextHop
                    currRoute['nextHopIpDomain'] = DomainScopeManager.getDomainByIp(currRoute['nextHopIp'], currRoute['localIpDomain'])
                    currRoute['type'] = route.ipRouteType
                    currRoute['ifAdminStatus'] = currIf.ifAdminStatus
                    routeArrayList.append(currRoute)
                        
    for currRouteData in routeArrayList:
        #Ip (next hop)
        nextHopIpOSH = modeling.createIpOSH(currRouteData['nextHopIp'], currRouteData['localIpMask'])
            
        routeObjects.add(nextHopIpOSH)
        # Ip (local for link)
        localIpOSHForLink = modeling.createIpOSH(currRouteData['localIpAddress'])
            
        routeLinkOSHIpIp = modeling.createLinkOSH('route', localIpOSHForLink, nextHopIpOSH) 
            
        for ipDest in currRouteData['destinationList']:
            routeLinkOSHIpIp.addAttributeToList(AttributeStateHolder("route_netaddress", ipDest))
            
        # Network (for link)
        nextHopNetworkOSH = modeling.createNetworkOSH(currRouteData['nextHopNetAddr'], currRouteData['localIpMask'])
            
        nextHopHostOSH = __createRouterIncompleteHostByIp(currRouteData['nextHopIp'])
        #Member (Connecting the next hop host to the next hop network)
        memberLinkOSHHostNetwork = modeling.createLinkOSH('member', nextHopNetworkOSH, nextHopHostOSH)
        #Member (Connecting the next hop ip to the next hop network)
        memberLinkOSHIpNetwork = modeling.createLinkOSH('member', nextHopNetworkOSH, nextHopIpOSH)
            
        routeObjects.add(nextHopHostOSH)
        routeObjects.add(memberLinkOSHHostNetwork)
        routeObjects.add(memberLinkOSHIpNetwork)
        routeObjects.add(routeLinkOSHIpIp)
    
    return routeObjects
Ejemplo n.º 19
0
def DiscoveryMain(Framework):

    OSHVResult = ObjectStateHolderVector()
    ms_domain_name = Framework.getDestinationAttribute('ms_domain_name')
    if not ms_domain_name:
        ms_domain_name = 'NULL'

    try:
        netUtil = MsNetworkUtil()
        hostsOutput = netUtil.doNetServerEnum('NULL',SV_TYPE_SERVER, ms_domain_name)
        if hostsOutput != None:
            discoverUnknownIPs = 1
            try:
                strDiscoverUnknownIPs = Framework.getParameter('discoverUnknownIPs');
                discoverUnknownIPs = Boolean.parseBoolean(strDiscoverUnknownIPs);
            except:
                pass

            oshMsDomain = ObjectStateHolder('msdomain')
            oshMsDomain.setStringAttribute('data_name', ms_domain_name)
            alreadyDiscoveredIps = HashMap()
            for hostInfo in hostsOutput:
                hostType = Long(hostInfo[1]).longValue()
                hostName = (str(hostInfo[0])).lower()
                try:
                    ip = InetAddress.getByName(hostInfo[0]).getHostAddress()
                    if netutils.isLocalIp(ip):
                        continue
                    cachedHostName = alreadyDiscoveredIps.get(ip)
                    if cachedHostName != None:
                        logger.debug('IP ', ip, ' already reported for host ' + cachedHostName, ' current host ', hostName, ' - skipping')
                        continue
                    else:
                        logger.debug('Discovered IP ' + ip + ' for host ' + hostName)
                        alreadyDiscoveredIps.put(ip, hostName)
                    ipDomain  = DomainScopeManager.getDomainByIp(ip)
                    if not discoverUnknownIPs and ipDomain == 'unknown':
                        logger.debug('ip: ' + ip + ' is out of probe range and will be excluded')
                        continue
                    if SV_TYPE_CLUSTER_NT & hostType:
                        logger.debug('Not reporting the entry %s because it is a Cluster' % hostName)
                        continue
                    hostOsType = 'nt'
                    if SV_TYPE_SERVER_UNIX & hostType:
                        hostOsType = 'unix'
                    oshHost = modeling.createHostOSH(ip, hostOsType)
                    oshHost.setStringAttribute("host_hostname", hostName)
                    OSHVResult.add(oshHost)

                    link = modeling.createLinkOSH('member', oshMsDomain, oshHost)
                    OSHVResult.add(link)
                    ipOSH = modeling.createIpOSH(ip)
                    OSHVResult.add(ipOSH)
                    contained = modeling.createLinkOSH('contained', oshHost, ipOSH)
                    OSHVResult.add(contained)
                except:
                    errorMsg = str(sys.exc_info()[1]).strip()
                    logger.warn('Failed to resolve host ', hostInfo[0], ' : ', errorMsg)
        else:
            message = 'Failed to discover hosts on MS Domain'
            logger.warn(message)
            logger.reportWarning(message)
    except:
        errorMsg = str(sys.exc_info()[1]).strip()
        logger.errorException('Failed to discovery MS Domains')
        errorMessage = errormessages.makeErrorMessage("msdomain", errorMsg, errormessages.ERROR_FAILED_DISCOVERING_MSDOMAIN_HOSTS)
        errobj = errorobject.createError(errorcodes.FAILED_DISCOVERIING_MSDOMAIN_HOST, ["msdomain", errorMsg], errorMessage)
        logger.reportErrorObject(errobj)
    return OSHVResult
def getProbeRanges(probeName):
    return DomainScopeManager.getProbeRanges(probeName, None)
Ejemplo n.º 21
0
def mainFunction(Framework, isClient, ip_address = None):
    _vector = ObjectStateHolderVector()
    errStr = ''
    ip_domain  = Framework.getDestinationAttribute('ip_domain')
    host_cmdbid = Framework.getDestinationAttribute('host_cmdbid')
    host_key = Framework.getDestinationAttribute('host_key')
    host_macs = Framework.getTriggerCIDataAsList('mac_addrs')
    ip_arp_mac = Framework.getDestinationAttribute('ip_mac')

    # try to get ip address by mac address from ARP Cache
    foundIp = clientdiscoveryutils.getIPAddressOnlyFromMacAddress(ip_arp_mac)
    if foundIp:
        ip_address = foundIp

    if (ip_address == None):
        ip_address = Framework.getDestinationAttribute('ip_address')
    if (ip_domain == None):
        ip_domain = DomainScopeManager.getDomainByIp(ip_address, None)

    protocols = netutils.getAvailableProtocols(Framework, ClientsConsts.SNMP_PROTOCOL_NAME, ip_address, ip_domain)
    if len(protocols) == 0:
        errStr = 'No credentials defined for the triggered ip'
        logger.debug(errStr)
        errObj = errorobject.createError(errorcodes.NO_CREDENTIALS_FOR_TRIGGERED_IP, [ClientsConsts.SNMP_PROTOCOL_NAME], errStr)
        return (_vector, errObj)

    connected = 0
    for protocol in protocols:
        client = None
        try:
            try:
                logger.debug('try to get snmp agent for: %s:%s' % (ip_address, ip_domain))
                if (isClient == TRUE):
                    properties = Properties()
                    properties.setProperty(CollectorsConstants.DESTINATION_DATA_IP_ADDRESS, ip_address)
                    properties.setProperty(CollectorsConstants.DESTINATION_DATA_IP_DOMAIN, ip_domain)
                    client = Framework.createClient(protocol, properties)
                else:
                    properties = Properties()
                    properties.setProperty(CollectorsConstants.DESTINATION_DATA_IP_ADDRESS, ip_address)
                    client = Framework.createClient(protocol, properties)
                logger.debug('Running test connection queries')
                testConnection(client)
                Framework.saveState(protocol)
                logger.debug('got snmp agent for: %s:%s' % (ip_address, ip_domain))
                isMultiOid = client.supportMultiOid()
                logger.debug('snmp server isMultiOid state=%s' %isMultiOid)
                # create snmp OSH
                snmpOSH = modeling.createSnmpOSH(ip_address, client.getPort())
                snmpOSH.setAttribute('application_timeout', client.getTimeout())
                snmpOSH.setAttribute('snmp_port', client.getPort())
                snmpOSH.setAttribute('credentials_id', client.getCredentialId())
                snmpOSH.setAttribute('snmp_retry', client.getRetries())
                snmpOSH.setAttribute('snmp_timeout', client.getTimeout())
                #obtain SNMP protocol version
                snmpVersion = definedSnmpProtocolVersion(protocol, Framework)
                snmpOSH.setAttribute('application_version_number', snmpVersion)
                if ip_arp_mac and ip_arp_mac != 'NA':
                    snmpOSH.setAttribute('arp_mac', ip_arp_mac)

                if isMultiOid == 1:
                    snmpOSH.setBoolAttribute('snmp_supportmultioid', 1)
                else:
                    snmpOSH.setBoolAttribute('snmp_supportmultioid', 0)

                _vector = doSnmp(client, isClient, snmpOSH, ip_address, ip_domain, Framework, host_cmdbid, host_key, host_macs)
                client.close()
                client = None

                if _vector.size() > 0:
                    connected = 1

                    break
            except BroadcastIpDiscoveryException:
                msg = "Job has been triggered on broadcast IP, no results will be reported"
                errObj = errorobject.createError(errorcodes.NO_RESULTS_WILL_BE_REPORTED, ["Job has been triggered on broadcast IP"], msg)
                if client != None:
                    client.close()
                    client = None
                return (_vector, errObj)
            except:
                if client != None:
                    client.close()
                    client = None
                logger.debugException('Unexpected SNMP_AGENT Exception:')
                lastExceptionStr = str(sys.exc_info()[1]).strip()
        finally:
            if client != None:
                client.close()
                client = None

    error = errorobject.INTERNAL_ERROR
    if (not connected):
        errStr = errormessages.makeErrorMessage('SNMP', pattern=errormessages.ERROR_CONNECTION_FAILED)
        error = errorobject.createError(errorcodes.CONNECTION_FAILED, ['SNMP'], errStr)
        logger.debug(errStr)
        Framework.clearState()
    elif (_vector.size() == 0):
        error = errormessages.resolveError(lastExceptionStr, 'SNMP')
    return (_vector, error)
Ejemplo n.º 22
0
def isClientTypeIP(ip):
    from com.hp.ucmdb.discovery.library.scope import DomainScopeManager
    from appilog.common.utils import RangeType

    tag = DomainScopeManager.getRangeTypeByIp(ip)
    return RangeType.CLIENT == tag
Ejemplo n.º 23
0
def isClientTypeIP(ip):
    tag = DomainScopeManager.getRangeTypeByIp(ip)
    return RangeType.CLIENT == tag
Ejemplo n.º 24
0
 def isIpOutOfScope(self, addr):
     return DomainScopeManager.isIpOutOfScope(addr)
Ejemplo n.º 25
0
def isClientTypeIP(ip):
    tag = DomainScopeManager.getRangeTypeByIp(ip)
    return RangeType.CLIENT == tag
def getProbeRanges(probeName):
    return DomainScopeManager.getProbeRanges(probeName, None)