示例#1
0
    def build(self, unitaryComputerSystem):
        if unitaryComputerSystem is None:
            raise ValueError("unitaryComputerSystem is None")
    
        hostOsh = modeling.HostBuilder.fromClassName('vmware_esx_server')

        hostOsh.setStringAttribute('host_key', unitaryComputerSystem.name)
        hostOsh.setBoolAttribute('host_iscomplete', 1)
        modeling.setHostBiosUuid(hostOsh, unitaryComputerSystem.name)
        modeling.setHostOsFamily(hostOsh, 'baremetal_hypervisor')


        if unitaryComputerSystem._chassis:
            if unitaryComputerSystem._chassis.model: 
                hostOsh.setStringAttribute('host_model', unitaryComputerSystem._chassis.model)
            
            if unitaryComputerSystem._chassis.manufacturer:
                hostOsh.setStringAttribute('host_vendor', unitaryComputerSystem._chassis.manufacturer)

            if unitaryComputerSystem._chassis.serialNumber:
                hostOsh.setStringAttribute('serial_number', unitaryComputerSystem._chassis.serialNumber)

        if unitaryComputerSystem._hypervisorSoftwareIdentity:
            if unitaryComputerSystem._hypervisorSoftwareIdentity.lastStartTime is not None:
                hostOsh.setDateAttribute('host_last_boot_time', unitaryComputerSystem._hypervisorSoftwareIdentity.lastStartTime)

        hostName, domainName = getHostNameAndDomain(unitaryComputerSystem.elementName)
        if hostName:
            hostOsh.setStringAttribute('name', hostName)
        if domainName:
            hostOsh.setStringAttribute('host_osdomain', domainName)
        
        return hostOsh.build()
示例#2
0
    def setHostAttributes(self):
        if self.hostOsh:
            if self.hostDo.hostName:
                self.hostOsh.setAttribute('host_hostname', self.hostDo.hostName)
            if self.hostDo.hostOsName:
                modeling.setHostOsName(self.hostOsh, self.hostDo.hostOsName)
            if self.hostDo.description:
                self.hostOsh = modeling.HostBuilder(self.hostOsh).setDescription(self.hostDo.description).build()
            if self.hostDo.servicePack:
                self.hostOsh.setAttribute('nt_servicepack', self.hostDo.servicePack)
            if self.hostDo.buildNumber:
                self.hostOsh.setAttribute('host_osrelease', self.hostDo.buildNumber)
            if self.hostDo.ntVersion:
                self.hostOsh.setAttribute('host_osversion', self.hostDo.ntVersion)
            if self.hostDo.installType:
                self.hostOsh.setAttribute('host_osinstalltype', self.hostDo.installType)
            if self.hostDo.vendor:
                self.hostOsh.setAttribute('host_vendor', self.hostDo.vendor)
            if self.hostDo.registeredOwner:
                self.hostOsh.setAttribute('nt_registeredowner', self.hostDo.registeredOwner)
            if self.hostDo.organization:
                self.hostOsh.setStringAttribute('nt_registrationorg', self.hostDo.organization)
            if self.hostDo.physicalMemory:
                self.hostOsh.setAttribute('nt_physicalmemory', self.hostDo.physicalMemory)
            if self.hostDo.biosAssetTag:
                self.hostOsh.setStringAttribute('bios_asset_tag', self.hostDo.biosAssetTag)
            if self.hostDo.osDomain:
                self.hostOsh.setStringAttribute('host_osdomain', self.hostDo.osDomain)
            if self.hostDo.winProcessorsNumber:
                self.hostOsh.setIntegerAttribute('nt_processorsnumber', self.hostDo.winProcessorsNumber)

            if self.hostDo.serialNumber:
                modeling.setHostSerialNumberAttribute(self.hostOsh, self.hostDo.serialNumber)
            if self.hostDo.hostModel:
                modeling.setHostModelAttribute(self.hostOsh, self.hostDo.hostModel)
            if self.hostDo.hostManufacturer:
                modeling.setHostManufacturerAttribute(self.hostOsh, self.hostDo.hostManufacturer)
            if self.hostDo.udUniqueId:
                self.hostOsh.setAttribute("ud_unique_id", self.hostDo.udUniqueId)
            if self.hostDo.paeEnabled and self.hostDo.paeEnabled.lower() in ['1', 'true']:
                self.hostOsh.setBoolAttribute("pae_enabled", 1)
            elif self.hostDo.paeEnabled and self.hostDo.paeEnabled.lower() in ['0', 'false']:
                self.hostOsh.setBoolAttribute("pae_enabled", 0)
            if self.hostDo.installType and self.hostDo.installType.encode('ascii','ignore').lower().find('ia64') != -1:
                self.hostDo.osArchitecture = 'ia64'
            elif self.hostDo.installType and self.hostDo.installType.encode('ascii','ignore').find('64') != -1:
                self.hostDo.osArchitecture = '64-bit'
            if self.hostDo.osArchitecture:
                self.hostOsh.setStringAttribute('os_architecture', self.hostDo.osArchitecture)

            modeling.setHostBiosUuid(self.hostOsh, self.hostDo.biosUUID)
            modeling.setHostDefaultGateway(self.hostOsh, self.hostDo.defaultGateway)
            modeling.setHostOsFamily(self.hostOsh, self.hostDo.osFamily)
            # fill in list of DNS servers
            if self.dnsServerIpList:
                list_ = StringVector(map(str, self.dnsServerIpList))
                attr = AttributeStateHolder('dns_servers', list_)
                self.hostOsh.setListAttribute(attr)
            self.resultVector.add(self.hostOsh)
示例#3
0
    def build(self, unitaryComputerSystem):
        if unitaryComputerSystem is None:
            raise ValueError("unitaryComputerSystem is None")

        hostOsh = modeling.HostBuilder.fromClassName('vmware_esx_server')

        hostOsh.setStringAttribute('host_key', unitaryComputerSystem.name)
        hostOsh.setBoolAttribute('host_iscomplete', 1)
        modeling.setHostBiosUuid(hostOsh, unitaryComputerSystem.name)
        modeling.setHostOsFamily(hostOsh, 'baremetal_hypervisor')

        if unitaryComputerSystem._chassis:
            if unitaryComputerSystem._chassis.model:
                hostOsh.setStringAttribute(
                    'host_model', unitaryComputerSystem._chassis.model)

            if unitaryComputerSystem._chassis.manufacturer:
                hostOsh.setStringAttribute(
                    'host_vendor', unitaryComputerSystem._chassis.manufacturer)

            if unitaryComputerSystem._chassis.serialNumber:
                hostOsh.setStringAttribute(
                    'serial_number',
                    unitaryComputerSystem._chassis.serialNumber)

        if unitaryComputerSystem._hypervisorSoftwareIdentity:
            if unitaryComputerSystem._hypervisorSoftwareIdentity.lastStartTime is not None:
                hostOsh.setDateAttribute(
                    'host_last_boot_time', unitaryComputerSystem.
                    _hypervisorSoftwareIdentity.lastStartTime)

        hostName, domainName = getHostNameAndDomain(
            unitaryComputerSystem.elementName)
        if hostName:
            hostOsh.setStringAttribute('name', hostName)
        if domainName:
            hostOsh.setStringAttribute('host_osdomain', domainName)

        return hostOsh.build()
def DiscoveryMain(Framework):
    OSHVResult = ObjectStateHolderVector()

    DISCOVERED_IP = Framework.getDestinationAttribute('ip_address')
    DISCOVERED_IP_ID = Framework.getDestinationAttribute('ip_id')    
#    ip = modeling.createOshByCmdbIdString('ip_address', DISCOVERED_IP_ID)
    ucmdbVersion = modeling.CmdbClassModel().version()
    if ucmdbVersion >= 9:
        ipClass = 'ip_address'
    else:
        ipClass = 'ip'

    protocols = Framework.getAvailableProtocols(DISCOVERED_IP, ClientsConsts.SNMP_PROTOCOL_NAME)

    if protocols.__len__() == 0:
        errStr = 'No credentials defined for the triggered ip'
        logger.debug(errStr)
        Framework.reportWarning(errStr)
    else:
        for protocol in protocols:
            sysplexNameList = None
            lparIpList = None
            
            snmpOSH = modeling.createSnmpOSH(DISCOVERED_IP, None)

            client = None
            try:
                client = Framework.createClient(protocol)
                logger.debug('got snmp agent for: ', DISCOVERED_IP)
                isMultiOid = client.supportMultiOid()
                
                sysplexNameList = client.executeQuery( '1.3.6.1.4.1.2.6.19.2.2.2.41,1.3.6.1.4.1.2.6.19.2.2.2.41,string,1.3.6.1.4.1.2.6.19.2.2.2.40,string' )#@@CMD_PERMISION snmp protocol execution
                sysplexNameList = sysplexNameList.asTable()

                lparIpList = client.executeQuery( '1.3.6.1.2.1.4.20.1.1,1.3.6.1.2.1.4.20.1.2,string' )#@@CMD_PERMISION snmp protocol execution
                lparIpList = lparIpList.asTable()

                mainframeMacList = client.executeQuery( '1.3.6.1.2.1.2.2.1.6,1.3.6.1.2.1.2.2.1.7,hexa' )#@@CMD_PERMISION snmp protocol execution
                mainframeMacList = mainframeMacList.asTable()
                snmpOSH.setAttribute('application_port', 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())
                if isMultiOid == 1:
                    snmpOSH.setBoolAttribute('snmp_supportmultioid', 1)
                else:
                    snmpOSH.setBoolAttribute('snmp_supportmultioid', 0)
            except:
                logger.debugException('Unexpected SNMP_AGENT Exception:')
                continue

            if client != None:
                client.close()

            mainframeKey = getMainframeKey(mainframeMacList)
            if mainframeKey:
                mainframeOSH = modeling.createCompleteHostOSH('mainframe', mainframeKey, machineName = mainframeKey)
                modeling.setHostOsFamily(mainframeOSH, 'mainframe')
                OSHVResult.add(mainframeOSH)

                for currSysplex in sysplexNameList:
                    if logger.isDebugEnabled():
                        logger.debug( 'SYSPLEX : ', currSysplex[1] )
                        logger.debug( 'LPAR : ', currSysplex[2] )
                        logger.debug( 'MainframeKEY : ', mainframeKey )

                    lparKey = mainframeKey + ':' + currSysplex[2]
                    lparOSH = modeling.createCompleteHostOSH('lpar', lparKey, machineName = currSysplex[2])
                    OSHVResult.add(lparOSH)
                    
                    snmpOSH.setContainer(lparOSH)
                    OSHVResult.add(snmpOSH)

                    # Create contained link between discovered IP and lpar
                    OSHVResult.add(modeling.createLinkOSH('contained', lparOSH, modeling.createOshByCmdbIdString(ipClass, DISCOVERED_IP_ID)))

                    # Create member link between lpar and Mainframe
                    OSHVResult.add(modeling.createLinkOSH('member', mainframeOSH, lparOSH))

                    # Create sysplex
                    sysplexOSH = ObjectStateHolder('sysplex')
                    sysplexOSH.setAttribute('data_name', currSysplex[1])
                    OSHVResult.add(sysplexOSH)

                    # Create member link between lpar and sysplex
                    OSHVResult.add(modeling.createLinkOSH('member', sysplexOSH, lparOSH))

                    # Create member link between mainframe and sysplex
                    OSHVResult.add(modeling.createLinkOSH('member', mainframeOSH, sysplexOSH))

                    # connect all ips to lpar
                    for currLparIp in lparIpList:
                        if netutils.isLocalIp(currLparIp[1]):
                            continue

                        currIpOSH = modeling.createIpOSH(currLparIp[1])
                        OSHVResult.add(currIpOSH)
                        OSHVResult.add(modeling.createLinkOSH('contained', lparOSH, currIpOSH))
                break
            else:
                logger.debug("Failed to get Mainframe key.")
        else:
            errormessages.resolveAndReport("Could not perform snmp connection to %s" % DISCOVERED_IP, ClientsConsts.SNMP_PROTOCOL_NAME, Framework)

    return OSHVResult
def doWMI(client, wmiOSH, ip_address, ip_domain, hostForLinkOSH, host_cmdbid=None, host_key=None, host_macs=None, ucmdb_version=None):
    '''@types: WmiClient, ObjectStateHolder, IPAddress, str, ObjectStateHolder, str, str, list[str], int -> ObjectStateHolderVector
    @param ip_address: Destination IP address
    '''
    wmiProvider = wmiutils.getWmiProvider(client)
    hostDiscoverer = host_win_wmi.WmiHostDiscoverer(wmiProvider)
    hostInfo = hostDiscoverer.discoverHostInfo()
    machineName = hostInfo.hostName

    interfacesDiscover = networking_win_wmi.WmiInterfaceDiscoverer(wmiProvider,
                                                ip_address)

    vector = ObjectStateHolderVector()
    interfaceList = interfacesDiscover.getInterfaces()
    parentLinkList = ObjectStateHolderVector()

    isVirtual = 1
    resultEmpty = 1
    interfacesToUpdateList = []
    for interface in interfaceList:
        ips = interface.ips
        MACAddress = interface.macAddress
        masks = interface.masks
        Description = interface.description
        dhcpEnabled = interface.dhcpEnabled

        resultEmpty = 0
        for ipIndex, ipAddress in enumerate(__iterate_valid_ips(ips)):
            IPSubnet = (masks and masks[ipIndex]) or None
            if str(ip_address) == str(ipAddress):
                isVirtual = 0

            ipOSH = modeling.createIpOSH(ipAddress)

            # Test if the same ip and interface are in the list allready

            logger.debug('Found ip address: ', ipAddress, ', MACAddress: ', MACAddress, ', IPSubnet: ', IPSubnet, ', Description: ', Description)
                # create OSH for IP and add it to the list
                # create OSH for Network and add it to the list
            __vector = getIPNetworkMemebrList(ipAddress, IPSubnet, '', dhcpEnabled, Description)
            if __vector.size() > 0:
                vector.addAll(__vector)

            if netutils.isValidMac(MACAddress):
                # create link interface to its ip only it has an ip defined
                interfaceOSH = modeling.createInterfaceOSH(MACAddress, hostForLinkOSH, Description)
                parentLinkList.add(modeling.createLinkOSH('containment', interfaceOSH, ipOSH))
                interfacesToUpdateList.append(interfaceOSH)

    # Check if the Input IP is virtual, we do not want to return the WMI
    if isVirtual == 1:
        logger.warn('Destination is not among discovered IPs assuming virtual. WMI object will not be reported.')
        vIPOSH = modeling.createIpOSH(ip_address)
        vIPOSH.setBoolAttribute('isvirtual', 1)
        vector.add(vIPOSH)

    if resultEmpty == 1:
        logger.warn('WMI was able to connect, but WMI Query returns no results')
        vector.clear()
        return vector

    # create the host and all the objects
    if len(interfaceList) > 0:
        hostOSH = None
        try:
            hostOSH = modeling.createCompleteHostOSHByInterfaceList('nt',
                            interfaceList, 'Windows', machineName, None,
                            host_cmdbid, host_key, host_macs, ucmdb_version)
        except:
            hostOSH = modeling.createHostOSH(str(ip_address), 'nt')
            logger.debugException('Could not find a valid MAC address for key on ip : %s. Creating incomplete host\n' % ip_address)
            logger.warn('Could not find a valid MAC address for key on ip : %s. Creating incomplete host\n' % ip_address)

        # select from Win32_OperatingSystem
        _wmiQuery = 'select Caption,Version,ServicePackMajorVersion,ServicePackMinorVersion,BuildNumber,Organization,RegisteredUser,TotalVisibleMemorySize,LastBootUpTime,OtherTypeDescription,description from Win32_OperatingSystem'
        resultSet = client.executeQuery(_wmiQuery)  # @@CMD_PERMISION wmi protocol execution
        osinstalltype = None
        if resultSet.next():
            Caption = resultSet.getString(1)
            Version = resultSet.getString(2)
            ServicePackMajorVersion = resultSet.getString(3)
            ServicePackMinorVersion = resultSet.getString(4)
            BuildNumber = resultSet.getString(5)
            Organization = resultSet.getString(6)
            RegisteredUser = resultSet.getString(7)
            TotalVisibleMemorySize = resultSet.getString(8)
            LastBootUpTime = resultSet.getString(9)
            OtherTypeDescription = resultSet.getString(10)
            description = resultSet.getString(11)

            (vendor, osName, osinstalltype) = separateCaption(Caption, OtherTypeDescription)
            hostOSH.setAttribute('host_vendor', vendor)
            modeling.setHostOsName(hostOSH, osName)
            hostOSH.setAttribute('host_osinstalltype', osinstalltype)

            setLastBootUpTime(hostOSH, LastBootUpTime)
            biosUUID = getBIOSUUID(client)
            defaultGateway = getDefaultGateway(client)

            hostOSH.setAttribute('host_osversion', Version)
            sp = ServicePackMajorVersion + '.' + ServicePackMinorVersion
            if checkSpVersion(sp):
                hostOSH.setAttribute('nt_servicepack', sp)
            hostOSH.setAttribute('host_osrelease', str(BuildNumber))
            hostOSH.setAttribute('nt_registrationorg', Organization)
            hostOSH.setAttribute('nt_registeredowner', RegisteredUser)
            hostOSH.setAttribute('nt_physicalmemory', TotalVisibleMemorySize)
            hostOSH.setAttribute('host_hostname', machineName)
            modeling.setHostBiosUuid(hostOSH, biosUUID)
            modeling.setHostDefaultGateway(hostOSH, defaultGateway)
            modeling.setHostOsFamily(hostOSH, 'windows')

            hostOSH = HostBuilder(hostOSH).setDescription(description).build()

        _wmiQuery2 = 'select Manufacturer,NumberOfProcessors,Model,Domain from Win32_ComputerSystem'
        resultSet = client.executeQuery(_wmiQuery2)  # @@CMD_PERMISION wmi protocol execution

        if resultSet.next():
            Manufacturer = resultSet.getString(1)
            if ((Manufacturer != None) and (Manufacturer.find('system manufacturer') == -1)):
                modeling.setHostManufacturerAttribute(hostOSH, Manufacturer.strip())
            NumberOfProcessors = resultSet.getString(2)
            hostOSH.setAttribute('nt_processorsnumber', int(NumberOfProcessors))
            Model = resultSet.getString(3)
            modeling.setHostModelAttribute(hostOSH, Model)
            osDomain = resultSet.getString(4)
            hostOSH.setAttribute('host_osdomain', osDomain.strip())

        biosAssetTag = hostDiscoverer.getBiosAssetTag()
        if biosAssetTag:
            hostOSH.setAttribute('bios_asset_tag', biosAssetTag)

        _wmiQuery4 = 'SELECT SerialNumber FROM Win32_BIOS'
        resultSet = client.executeQuery(_wmiQuery4)  # @@CMD_PERMISSION wmi protocol execution
        if resultSet.next():
            serialNumber = processSerialNumber(resultSet.getString(1))
            if not serialNumber:
                wmiBaseBoardSerialNumber = 'SELECT SerialNumber FROM Win32_BaseBoard'
                resultSet = client.executeQuery(wmiBaseBoardSerialNumber)  # @@CMD_PERMISION wmi protocol execution
                serialNumber = processSerialNumber(str(resultSet))
            modeling.setHostSerialNumberAttribute(hostOSH, serialNumber)

        try:
            paeEnabled = getPAEState(client)
            if paeEnabled and paeEnabled.lower() in ['1', 'true']:
                hostOSH.setBoolAttribute('pae_enabled', 1)
            elif paeEnabled and paeEnabled.lower() in ['0', 'false']:
                hostOSH.setBoolAttribute('pae_enabled', 0)
        except Exception, ex:
            logger.warn('Failed getting PAE state. %s' % ex)

        try:
            osArchitecture = getOsArchitecture(client)
            if osinstalltype and osinstalltype.find('64') != -1:
                osArchitecture = '64-bit'
            if osArchitecture:
                hostOSH.setStringAttribute('os_architecture', osArchitecture)
        except Exception, ex:
            logger.warn('Failed getting OS Architecture value. %s' % ex)
示例#6
0
def doQueryMainframeTCP(client, OSHVResult, Framework):
    ip_address = client.getIpAddress()
    hostOSH = modeling.createHostOSH(client.getIpAddress())
    modeling.setHostOsFamily(hostOSH, 'mainframe')
    ################     Query and data    ################################
    resultSetList = client.executeQuery(
        '1.3.6.1.4.1.2.6.19.2.2.7.1.1.37,1.3.6.1.4.1.2.6.19.2.2.7.1.1.38,string'
    )  #@@CMD_PERMISION snmp protocol execution
    resultSetList = resultSetList.asTable()

    tcpUtil = tcpdbutils.TcpDbUtils(Framework)

    regExp = '(\d+\.\d+\.\d+\.\d+)\.(\d+)\.(\d+\.\d+\.\d+\.\d+)\.(\d+)'
    for resultSet in resultSetList:
        try:
            currRowData = string.strip(resultSet[0])
            processName = string.strip(resultSet[1])

            processOSH = modeling.createProcessOSH(processName, hostOSH)
            OSHVResult.add(processOSH)

            resArray = re.search(regExp, currRowData)
            if resArray:
                ip1 = resArray.group(1)
                port1 = resArray.group(2)
                ip2 = resArray.group(3)
                port2 = resArray.group(4)
                processName = resultSet[1]

                # Create

                # Discard invalid lines (No port#)
                if port1 == '0':
                    continue

                # Loop back and listen
                if netutils.isLocalIp(ip1):
                    prot = 6  #tcp protocol
                    tcpUtil.addPortToProcess(ip_address, int(port1), -1, 1,
                                             prot)
                    continue

                tcpUtil.addTcpConnection(ip1, int(port1), ip2, int(port2))
                tcpUtil.addTcpConnection(ip2, int(port2), ip1, int(port1))

#				print '--------------------------------'
#				print 'ip1 :' , ip1
#				print 'port1 :' , port1
#				print 'ip2 :' , ip2
#				print 'port2 :' , port2
#				print 'processName :' , processName
#				print '--------------------------------'

        except:
            logger.warnException('Failed ip: %s' % (ip_address))
        try:
            tcpUtil.flushPortToProcesses()
        except:
            pass
        try:
            tcpUtil.flushTcpConnection()
        except:
            pass
        tcpUtil.close()
    logger.debug('Finished to process results')
示例#7
0
    def setHostAttributes(self):
        if self.hostOsh:
            if self.hostDo.hostName:
                self.hostOsh.setAttribute('host_hostname',
                                          self.hostDo.hostName)
            if self.hostDo.hostOsName:
                modeling.setHostOsName(self.hostOsh, self.hostDo.hostOsName)
            if self.hostDo.description:
                self.hostOsh = modeling.HostBuilder(
                    self.hostOsh).setDescription(
                        self.hostDo.description).build()
            if self.hostDo.servicePack:
                self.hostOsh.setAttribute('nt_servicepack',
                                          self.hostDo.servicePack)
            if self.hostDo.buildNumber:
                self.hostOsh.setAttribute('host_osrelease',
                                          self.hostDo.buildNumber)
            if self.hostDo.ntVersion:
                self.hostOsh.setAttribute('host_osversion',
                                          self.hostDo.ntVersion)
            if self.hostDo.installType:
                self.hostOsh.setAttribute('host_osinstalltype',
                                          self.hostDo.installType)
            if self.hostDo.vendor:
                self.hostOsh.setAttribute('host_vendor', self.hostDo.vendor)
            if self.hostDo.registeredOwner:
                self.hostOsh.setAttribute('nt_registeredowner',
                                          self.hostDo.registeredOwner)
            if self.hostDo.organization:
                self.hostOsh.setStringAttribute('nt_registrationorg',
                                                self.hostDo.organization)
            if self.hostDo.physicalMemory:
                self.hostOsh.setAttribute('nt_physicalmemory',
                                          self.hostDo.physicalMemory)
            if self.hostDo.biosAssetTag:
                self.hostOsh.setStringAttribute('bios_asset_tag',
                                                self.hostDo.biosAssetTag)
            if self.hostDo.osDomain:
                self.hostOsh.setStringAttribute('host_osdomain',
                                                self.hostDo.osDomain)
            if self.hostDo.winProcessorsNumber:
                self.hostOsh.setIntegerAttribute(
                    'nt_processorsnumber', self.hostDo.winProcessorsNumber)

            if self.hostDo.serialNumber:
                modeling.setHostSerialNumberAttribute(self.hostOsh,
                                                      self.hostDo.serialNumber)
            if self.hostDo.hostModel:
                modeling.setHostModelAttribute(self.hostOsh,
                                               self.hostDo.hostModel)
            if self.hostDo.hostManufacturer:
                modeling.setHostManufacturerAttribute(
                    self.hostOsh, self.hostDo.hostManufacturer)
            if self.hostDo.udUniqueId:
                self.hostOsh.setAttribute("ud_unique_id",
                                          self.hostDo.udUniqueId)
            if self.hostDo.paeEnabled and self.hostDo.paeEnabled.lower() in [
                    '1', 'true'
            ]:
                self.hostOsh.setBoolAttribute("pae_enabled", 1)
            elif self.hostDo.paeEnabled and self.hostDo.paeEnabled.lower() in [
                    '0', 'false'
            ]:
                self.hostOsh.setBoolAttribute("pae_enabled", 0)
            if self.hostDo.installType and self.hostDo.installType.encode(
                    'ascii', 'ignore').lower().find('ia64') != -1:
                self.hostDo.osArchitecture = 'ia64'
            elif self.hostDo.installType and self.hostDo.installType.encode(
                    'ascii', 'ignore').find('64') != -1:
                self.hostDo.osArchitecture = '64-bit'
            if self.hostDo.osArchitecture:
                self.hostOsh.setStringAttribute('os_architecture',
                                                self.hostDo.osArchitecture)

            modeling.setHostBiosUuid(self.hostOsh, self.hostDo.biosUUID)
            modeling.setHostDefaultGateway(self.hostOsh,
                                           self.hostDo.defaultGateway)
            modeling.setHostOsFamily(self.hostOsh, self.hostDo.osFamily)
            # fill in list of DNS servers
            if self.dnsServerIpList:
                list_ = StringVector(map(str, self.dnsServerIpList))
                attr = AttributeStateHolder('dns_servers', list_)
                self.hostOsh.setListAttribute(attr)
            self.resultVector.add(self.hostOsh)
def doSnmp(client, isClient, snmpOSH, ip_address, ip_domain, Framework, host_cmdbid, host_key, host_macs):
    '''SnmpClient, osh, str, str, Framework, str, str, list(str) -> ObjectStateHolderVector
    @deprecated
    '''
    networkList = []
    vector = ObjectStateHolderVector()
    ucmdb_version = modeling.CmdbClassModel().version()
    # system table
    snmpQuery = '1.3.6.1.2.1.1.1,1.3.6.1.2.1.1.2,string,1.3.6.1.2.1.1.2,string,1.3.6.1.2.1.1.5,string'
    table = client.executeQuery(snmpQuery)#@@CMD_PERMISION snmp protocol execution

    sysname = None
    oid = None
    description = None
    try:
        if table.next():
            description = table.getString(2)
            oid = table.getString(3)
            sysname = table.getString(4)
    except:
        logger.debugException('')

    node_description = description or ''

    sysObjId = oid
    className, vendorName, hostOsName, hostModel, serialNumberOid, serialNumberSNMPMethod = getNodeDetails(description, oid)
    logger.debug("Node details:%s, %s, %s, %s, %s, %s"%(className, vendorName, hostOsName, hostModel, serialNumberOid, serialNumberSNMPMethod))
    if className == 'netprinter':
        sysname = getNetPrinterName(client) or sysname
    hostVersion, hostRelease = getOsVersionAndBuild(hostOsName, description)

# since sysUpTime returns a time since the snmp was re-initialized, this
# time doesn't provide us correct answer, therefore this code is disabled
#    snmpQuery = '1.3.6.1.2.1.1.3,1.3.6.1.2.1.1.4,string'
#    upTime = client.executeQuery(snmpQuery)

    if oid != None:
        snmpOSH.setAttribute('snmp_oid', oid)
    if((sysname != None) and (sysname != '') and (sysname != 'unknown')):
        snmpOSH.setAttribute('snmp_sysname', sysname)
    if description != None:
        snmpOSH.setAttribute('snmp_description', description)

    logger.debug('ip_address: ', ip_address, ', sysname: ' , sysname, ', className: ', className, ', oid: ', oid, ', description: ', description)

    #dicovery arp cache available
    arp_available = SNMP_Networking_Utils.isArpCacheAvailable(client)
    snmpOSH.setBoolAttribute('arp_cache_available', arp_available)

    # indx, description & mac

    interfaceList = []
    interfaceDictionary = {}

    ifList = SNMP_Networking_Utils.discoverInterfaceData(client, None)

    for nic in ifList:
        if nic.ifType and int(nic.ifType) == 24:
            continue

        macAddress = str(nic.ifMac).upper()
        if nic.ifIndex != None and nic.ifIndex != '':
            inrfcindex = nic.ifIndex
        description = _stripVirtualMiniportInfo(nic.ifDescr)

        if interfaceDictionary.has_key(inrfcindex):
            logger.debug('this mac was already reported, skip it ... : inrfcindex: ', inrfcindex, ', descrition: ', description, ', macAddress: ', macAddress)
            continue

        logger.debug('inrfcindex: ', inrfcindex, ', description: ', description, ', macAddress: ', macAddress)

        interfaceDictionary[inrfcindex] = macAddress
        networkinterface = modeling.NetworkInterface(description, macAddress, None, None, inrfcindex)
        networkinterface.type = nic.ifType
        networkinterface.adminStatus = nic.ifAdminStatus
        networkinterface.operStatus = nic.ifOperStatus
        networkinterface.speed = nic.ifSpeed
        networkinterface.name = nic.ifName
        networkinterface.alias = nic.ifAlias
        if not networkinterface.name:
            m = re.match('(lan[\d\:\.]+)', description)
            if m:
                networkinterface.name = m.group(1)
                networkinterface.description = None
        interfaceList.append(networkinterface)

    # create the host and all the objects
    if len(interfaceList) > 0:
        macToInterfaceListMap = {}
        for interface in interfaceList:
            macToInterfaceListMap.setdefault(interface.macAddress, []).append(interface)

        for ifaceList in macToInterfaceListMap.values():
            if ifaceList and len(ifaceList) < 2:
                continue
            try:
                iface = reduce(lambda x,y: x.interfaceIndex > y.interfaceIndex and x or y, ifaceList)
                iface.role = 'aggregate_interface'
            except:
                logger.debugException('')
        hostOSH = None

        try:
            # Get the host_key - lowest mac address of the valid interface list
            hostOSH = modeling.createCompleteHostOSHByInterfaceList(className, interfaceList, None, None, None, host_cmdbid, host_key, host_macs, ucmdb_version)
            if (className in netDeviceClasses) and (sysname != None) and (sysname != '') and ((host_cmdbid in ['NA','',None]) or (host_key and (host_key.lower() == sysname.lower()))):
                # JEO @ Fidelity: use SNMP system name for host key of network devices unless its null
                hostOSH.setAttribute('host_key', sysname)

        except:
            logger.debug('Could not find a valid MAC address for key on ip : ', ip_address)
            if (className in netDeviceClasses) and (sysname != None) and (sysname != '') and (host_cmdbid in ['NA','',None]):
                logger.debug('Network device, hostkey is sysname...')
                hostOSH = modeling.createCompleteHostOSH(className, sysname)
            else:
                logger.debug('Creating incomplete host...')
                hostOSH = modeling.createHostOSH(ip_address, className)

        logger.debug('Created [' + className + '] strong key=[' + hostOSH.getAttributeValue('host_key') + ']')

        if((sysname != None) and (sysname != '') and (sysname != 'unknown')):
            hostOSH.setAttribute('snmp_sys_name', sysname)
            # set hostname to SNMP system name less domain suffix which is typical of other data sources
            hostname = sysname.split('.')[0].lower()
            hostOSH.setAttribute('name', hostname)
            logger.debug("hostname=" + hostname)

        defaultGateway = getDefaultGateway(client)
        modeling.setHostDefaultGateway(hostOSH, defaultGateway)
        modeling.setHostOsFamily(hostOSH, None, className)
        if sysObjId and sysObjId.startswith('.') != -1:
            sysObjId = "." + sysObjId
        modeling.setSNMPSysObjectId(hostOSH, sysObjId)

        if((hostOsName != None) and (hostOsName != '') and (hostOsName != 'unknown')):
            modeling.setHostOsName(hostOSH, hostOsName)
        if((vendorName != None) and (vendorName != '') and (vendorName != 'unknown')):
            hostOSH.setAttribute('discovered_os_vendor', vendorName)
        if((hostModel != None) and (hostModel != '') and (hostModel != 'unknown')):
            hostOSH.setAttribute('discovered_model', hostModel)
        if hostRelease is not None:
            hostOSH.setAttribute('host_osrelease', hostRelease)
        if hostVersion is not None:
            hostOSH.setAttribute('discovered_os_version', hostVersion)

# since sysUpTime returns a time since the snmp was re-initialized, this
# time doesn't provide us correct answer, therefore this code is disabled
#        if upTime:
#            today = Calendar.getInstance().getTime()
#            setLastBootDate(hostOSH, upTime, today, Framework)

        vector.add(modeling.finalizeHostOsh(hostOSH))
        snmpOSH.setContainer(hostOSH)
        if className == 'mainframe':
            modeling.setHostOsFamily(hostOSH, 'mainframe')

        interfaceOshToIndex = {}
        roleManager = networking_win.InterfaceRoleManager()
        try:
            reportInterfaceName = Boolean.parseBoolean(Framework.getParameter('reportInterfaceName'))
        except:
            logger.warn('Failed to parse reportInterfaceName parameter falue. Not a Boolean type.')
            reportInterfaceName = True
        for nic in interfaceList:
            if netutils.isValidMac(nic.macAddress):
                nic.osh = modeling.createInterfaceOSH(nic.macAddress, hostOSH, nic.description,
                            nic.interfaceIndex, nic.type, nic.adminStatus, nic.operStatus,
                            nic.speed, nic.name, nic.alias, reportInterfaceName)
                roleManager.assignInterfaceRole(nic)
                interfaceOshToIndex[nic.interfaceIndex] = nic.osh
                vector.add(nic.osh)
            else:
                logger.debug('MAC %s is invalid (name: %s, description: %s, index: %s)' %
                             (nic.macAddress, nic.name, nic.description, nic.interfaceIndex))

        # create the ip's
        logger.debug("create the ip's")
        snmpQuery = '1.3.6.1.2.1.4.20.1.1, 1.3.6.1.2.1.4.20.1.2, string'
        table = client.executeQuery(snmpQuery)#@@CMD_PERMISION snmp protocol execution
        ips = table.asTable()
        snmpQuery = '1.3.6.1.2.1.4.20.1.2, 1.3.6.1.2.1.4.20.1.3, string'
        table = client.executeQuery(snmpQuery)#@@CMD_PERMISION snmp protocol execution
        ifindexes = table.asTable()
        snmpQuery = '1.3.6.1.2.1.4.20.1.3, 1.3.6.1.2.1.4.20.1.4, string'
        table = client.executeQuery(snmpQuery)#@@CMD_PERMISION snmp protocol execution
        ipmasks = table.asTable()
        try:
            rfcIpV6Query = '1.3.6.1.2.1.55.1.8.1.1,1.3.6.1.2.1.55.1.8.1.5, string'
            rfcIpV6Result = client.executeQuery(rfcIpV6Query)#@@CMD_PERMISION snmp protocol execution
            results = rfcIpV6Result.asTable()
        except:
            logger.warn('Failed to get or process IPv6 MIB results.')

        #try to collect IPv6 addresses from IPv6 address table and connect them to corresponding interface
        logger.debug("Begin to discovery IPv6 related info")
        try:
            ipv6Map = {}
            ipv6AddressTable = SNMP_Networking_Utils.discoverIPv6AddressTable(client)
            if ipv6AddressTable:
                for row in ipv6AddressTable:
                    if row.ipv6AddrStatus != '1':# 1 means valid ip address in arp cache
                        continue
                    ifIndex, ipAddress = _parseIPv6FromIndex(row.ipv6AddrAddress)
                    if ifIndex and ipAddress:
                        try:
                            formatedIP = getValidIP(ipAddress)
                            if formatedIP:
                                ipv6Map[ifIndex] = formatedIP
                        except:
                            pass
            mixedIPAddressTable = SNMP_Networking_Utils.discoverMixedIPAddressTable(client)
            if mixedIPAddressTable:
                for row in mixedIPAddressTable:
                    if row.ipAddressStatus != '1' or row.ipAddressRowStatus != '1':# 1 means valid ip address in arp cache
                        continue
                    ifIndex = row.ipAddressIfIndex
                    ipAddress = _parseMixedIPFromIndex(row.ipAddressAddr)
                    if ifIndex and ipAddress:
                        try:
                            formatedIP = getValidIP(ipAddress)
                            if formatedIP and formatedIP.version == 6:
                                ipv6Map[ifIndex] = formatedIP
                        except:
                            pass

            if ipv6Map and interfaceOshToIndex:
                for ifIndex in ipv6Map.keys():
                    ipv6 = ipv6Map[ifIndex]
                    logger.debug("Discovered IPv6:", ipv6)
                    ipOSH = modeling.createIpOSH(ipv6)
                    vector.add(ipOSH)
                    interfaceOsh = interfaceOshToIndex.get(str(ifIndex))
                    if not interfaceOsh and isClient:
                        logger.info('client ip is not associated with an interface')
                        msg = "Can not find the related interface for client IP: %s" % ip_address
                        logger.reportWarningObject(errormessages.resolveError(msg, 'SNMP'))
                        continue
                    if interfaceOsh:
                        parent = modeling.createLinkOSH('containment', interfaceOsh, ipOSH)
                        vector.add(parent)
                        interfaceMacAddress = interfaceOsh.getAttributeValue('mac_address')
                        if (isClient == TRUE):
                            ipOSH.setAttribute('arp_mac', interfaceMacAddress)
                            if (
                            ipv6 == ip_addr_util.IPAddress(ip_address)):#compare ipv6 by the formatting to avoid same IPv6 with different format
                                snmpOSH.setAttribute('arp_mac', interfaceMacAddress)

                    isCompleteAttribute = hostOSH.getAttribute('host_iscomplete')
                    if isCompleteAttribute is not None and isCompleteAttribute.getBooleanValue() == 1:
                        contained = modeling.createLinkOSH('contained', hostOSH, ipOSH)
                        vector.add(contained)
        except:
            logger.debug(str(sys.exc_info()))

        index = 0
        if len(ips) > 0 and len(ifindexes) > 0:
            for ip in ips:
                try:
                    ip_addr = ip[1]
                    #logger.debug('candidate ip_addr: ', ip_addr)
                    ifIndex = ifindexes[index][1]
                    mask = ipmasks[index][1]
                    index += 1

                    interfaceOsh = interfaceOshToIndex.get(ifIndex)

                    ''' this commented out block should be removed
                    # no such thing as netmask IPs, there are broadcast IPs which have .255 in them
                    # but we would definitely want to discover and nic which was asssigned
                    # such an address -
                    #if(ip_addr.find('255.') == 0 ):
                        #exclude netmask ip
                        #continue
                    '''

                    if netutils.isValidIp(ip_addr) and (not netutils.isLocalIp(ip_addr)):
                        '''
                        netutils.isLocalIp is not finding all local addresses
                        127.0.0.0 through 127.255.255.255 are local
                        additional if clause can be removed when this is fixed
                        see http://www.tcpipguide.com/free/t_IPReservedPrivateandLoopbackAddresses.htm
                        '''
                        # ip is valid and not local (i.e. 0.0.0.0, 127.0.0.1)
                        ipOSH = modeling.createIpOSH(ip_addr, mask)
                    else:
                        # loopbacks are standard; don't complain about them in the logs
                        continue
                    logger.debug('ip_addr: ', ip_addr, ', mask: ', mask)

                    netOSH = modeling.createNetworkOSH(ip_addr, mask)

                    strNetAddr = str(netOSH.getAttribute('network_netaddr'))
                    strNetMask = str(netOSH.getAttribute('network_netMask'))
                    currNet = strNetAddr + strNetMask

                    broadcastIp = netOSH.getAttributeValue('network_broadcastaddress')
                    if ip_address == broadcastIp:
                        raise BroadcastIpDiscoveryException()
                    if not interfaceOsh and isClient:
                        logger.info('client ip is not associated with an interface')
                        msg = "Can not find the related interface for client IP: " + ip_addr
                        logger.reportWarningObject(errormessages.resolveError(msg, 'SNMP'))
                        continue
                    if interfaceOsh:
                        parent = modeling.createLinkOSH('containment', interfaceOsh, ipOSH)
                        vector.add(parent)
                        interfaceMacAddress = interfaceOsh.getAttributeValue('mac_address')
                        if (isClient == TRUE):
                            ipOSH.setAttribute('arp_mac', interfaceMacAddress)
                            if (ip_addr == ip_address):
                                snmpOSH.setAttribute('arp_mac', interfaceMacAddress)

                    member1 = modeling.createLinkOSH('member', netOSH, ipOSH)
                    member2 = modeling.createLinkOSH('member', netOSH, hostOSH)

                    if currNet in networkList:
                        pass
                    else:
                        networkList.append(currNet)
                        vector.add(netOSH)
                        vector.add(member2)

                    vector.add(ipOSH)
                    vector.add(member1)

                    # link IPs to host only in case host is complete
                    # otherwise reconciliation may fail
                    isCompleteAttribute = hostOSH.getAttribute('host_iscomplete')
                    if isCompleteAttribute is not None and isCompleteAttribute.getBooleanValue() == 1:
                        contained = modeling.createLinkOSH('contained', hostOSH, ipOSH)
                        vector.add(contained)

                    if interfaceOsh:
                        parent = modeling.createLinkOSH('containment', interfaceOsh, ipOSH)
                        vector.add(parent)
                except BroadcastIpDiscoveryException, ex:
                    raise ex
                except:
                    pass
def doQueryMainframeTCP(client, OSHVResult, Framework):
	ip_address = client.getIpAddress()
	hostOSH = modeling.createHostOSH(client.getIpAddress())
	modeling.setHostOsFamily(hostOSH, 'mainframe')
	################     Query and data    ################################
	resultSetList = client.executeQuery('1.3.6.1.4.1.2.6.19.2.2.7.1.1.37,1.3.6.1.4.1.2.6.19.2.2.7.1.1.38,string')#@@CMD_PERMISION snmp protocol execution
	resultSetList = resultSetList.asTable()

	tcpUtil = tcpdbutils.TcpDbUtils(Framework)
	
	regExp = '(\d+\.\d+\.\d+\.\d+)\.(\d+)\.(\d+\.\d+\.\d+\.\d+)\.(\d+)'
	for resultSet in resultSetList:
		try:
			currRowData = string.strip( resultSet[0] )
			processName = string.strip( resultSet[1] )

			processOSH = modeling.createProcessOSH(processName, hostOSH)
			OSHVResult.add(processOSH)
			
			resArray = re.search(regExp, currRowData)
			if resArray:
				ip1 = resArray.group(1)
				port1 = resArray.group(2)
				ip2 = resArray.group(3)
				port2 = resArray.group(4)
				processName = resultSet[1]
				
				# Create

				# Discard invalid lines (No port#)
				if port1 == '0':
					continue

				# Loop back and listen
				if netutils.isLocalIp(ip1):
					prot = 6 #tcp protocol
					tcpUtil.addPortToProcess(ip_address, int(port1), -1, 1, prot)
					continue
				
				tcpUtil.addTcpConnection(ip1, int(port1), ip2, int(port2))
				tcpUtil.addTcpConnection(ip2, int(port2), ip1, int(port1))

#				print '--------------------------------'
#				print 'ip1 :' , ip1
#				print 'port1 :' , port1
#				print 'ip2 :' , ip2
#				print 'port2 :' , port2
#				print 'processName :' , processName
#				print '--------------------------------'

		except:
			logger.warnException('Failed ip: %s' % (ip_address))
		try:
			tcpUtil.flushPortToProcesses()
		except:
			pass
		try:
			tcpUtil.flushTcpConnection()
		except:
			pass
		tcpUtil.close()
	logger.debug('Finished to process results')
def DiscoveryMain(Framework):
    OSHVResult = ObjectStateHolderVector()

    DISCOVERED_IP = Framework.getDestinationAttribute('ip_address')
    DISCOVERED_IP_ID = Framework.getDestinationAttribute('ip_id')
    #    ip = modeling.createOshByCmdbIdString('ip_address', DISCOVERED_IP_ID)
    ucmdbVersion = modeling.CmdbClassModel().version()
    if ucmdbVersion >= 9:
        ipClass = 'ip_address'
    else:
        ipClass = 'ip'

    protocols = Framework.getAvailableProtocols(
        DISCOVERED_IP, ClientsConsts.SNMP_PROTOCOL_NAME)

    if protocols.__len__() == 0:
        errStr = 'No credentials defined for the triggered ip'
        logger.debug(errStr)
        Framework.reportWarning(errStr)
    else:
        for protocol in protocols:
            sysplexNameList = None
            lparIpList = None

            snmpOSH = modeling.createSnmpOSH(DISCOVERED_IP, None)

            client = None
            try:
                client = Framework.createClient(protocol)
                logger.debug('got snmp agent for: ', DISCOVERED_IP)
                isMultiOid = client.supportMultiOid()

                sysplexNameList = client.executeQuery(
                    '1.3.6.1.4.1.2.6.19.2.2.2.41,1.3.6.1.4.1.2.6.19.2.2.2.41,string,1.3.6.1.4.1.2.6.19.2.2.2.40,string'
                )  #@@CMD_PERMISION snmp protocol execution
                sysplexNameList = sysplexNameList.asTable()

                lparIpList = client.executeQuery(
                    '1.3.6.1.2.1.4.20.1.1,1.3.6.1.2.1.4.20.1.2,string'
                )  #@@CMD_PERMISION snmp protocol execution
                lparIpList = lparIpList.asTable()

                mainframeMacList = client.executeQuery(
                    '1.3.6.1.2.1.2.2.1.6,1.3.6.1.2.1.2.2.1.7,hexa'
                )  #@@CMD_PERMISION snmp protocol execution
                mainframeMacList = mainframeMacList.asTable()
                snmpOSH.setAttribute('application_port', 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())
                if isMultiOid == 1:
                    snmpOSH.setBoolAttribute('snmp_supportmultioid', 1)
                else:
                    snmpOSH.setBoolAttribute('snmp_supportmultioid', 0)
            except:
                logger.debugException('Unexpected SNMP_AGENT Exception:')
                continue

            if client != None:
                client.close()

            mainframeKey = getMainframeKey(mainframeMacList)
            if mainframeKey:
                mainframeOSH = modeling.createCompleteHostOSH(
                    'mainframe', mainframeKey, machineName=mainframeKey)
                modeling.setHostOsFamily(mainframeOSH, 'mainframe')
                OSHVResult.add(mainframeOSH)

                for currSysplex in sysplexNameList:
                    if logger.isDebugEnabled():
                        logger.debug('SYSPLEX : ', currSysplex[1])
                        logger.debug('LPAR : ', currSysplex[2])
                        logger.debug('MainframeKEY : ', mainframeKey)

                    lparKey = mainframeKey + ':' + currSysplex[2]
                    lparOSH = modeling.createCompleteHostOSH(
                        'lpar', lparKey, machineName=currSysplex[2])
                    OSHVResult.add(lparOSH)

                    snmpOSH.setContainer(lparOSH)
                    OSHVResult.add(snmpOSH)

                    # Create contained link between discovered IP and lpar
                    OSHVResult.add(
                        modeling.createLinkOSH(
                            'contained', lparOSH,
                            modeling.createOshByCmdbIdString(
                                ipClass, DISCOVERED_IP_ID)))

                    # Create member link between lpar and Mainframe
                    OSHVResult.add(
                        modeling.createLinkOSH('member', mainframeOSH,
                                               lparOSH))

                    # Create sysplex
                    sysplexOSH = ObjectStateHolder('sysplex')
                    sysplexOSH.setAttribute('data_name', currSysplex[1])
                    OSHVResult.add(sysplexOSH)

                    # Create member link between lpar and sysplex
                    OSHVResult.add(
                        modeling.createLinkOSH('member', sysplexOSH, lparOSH))

                    # Create member link between mainframe and sysplex
                    OSHVResult.add(
                        modeling.createLinkOSH('member', mainframeOSH,
                                               sysplexOSH))

                    # connect all ips to lpar
                    for currLparIp in lparIpList:
                        if netutils.isLocalIp(currLparIp[1]):
                            continue

                        currIpOSH = modeling.createIpOSH(currLparIp[1])
                        OSHVResult.add(currIpOSH)
                        OSHVResult.add(
                            modeling.createLinkOSH('contained', lparOSH,
                                                   currIpOSH))
                break
            else:
                logger.debug("Failed to get Mainframe key.")
        else:
            errormessages.resolveAndReport(
                "Could not perform snmp connection to %s" % DISCOVERED_IP,
                ClientsConsts.SNMP_PROTOCOL_NAME, Framework)

    return OSHVResult