def processNetDeviceInfo(ipAddress, netDeviceName, ipAddressList, netDeviceOSHV, allowDnsLookup):
    try:
        netDeviceOSH = ipOSH = None
        ciscoworks_utils.debugPrint(3, '[' + SCRIPT_NAME + ':processNetDeviceInfo] Got Net Device <%s>' % netDeviceName)

        ## Check if this NetDevice is already in the OSHV
        netDeviceOSH = ciscoworks_utils.getCiByAttributesFromOSHV(netDeviceOSHV, 'netdevice', {'data_externalid':netDeviceName})
        if netDeviceOSH:
            ciscoworks_utils.debugPrint(2, '[' + SCRIPT_NAME + ':processNetDeviceInfo] CI for Net Device <%s> exists in UCMDB' % netDeviceName)
        else:
            ## Try and get a DNS name for this node
            netDeviceDnsName = None
            if allowDnsLookup and ipAddress and netutils.isValidIp(ipAddress):
                netDeviceDnsName = netutils.getHostName(ipAddress)
                ciscoworks_utils.debugPrint(4, '[' + SCRIPT_NAME + ':processNetDeviceInfo] Got DNS name <%s> for Net Device <%s> using IP <%s>' % (netDeviceDnsName, netDeviceName, ipAddress))

            ## Discard IP if this is a duplicate
            if ipAddress and netutils.isValidIp(ipAddress) and ipAddress in ipAddressList:
                logger.debug('Ignoring duplicate IP <%s> on Net Device <%s>...' % (ipAddress, netDeviceName))
            else:
                ipAddressList.append(ipAddress)

            ## Check for a valid IP
            if ipAddress and netutils.isValidIp(ipAddress):
                ipOSH = modeling.createIpOSH(ipAddress, None, netDeviceDnsName, None)
            else:
                logger.debug('Ignoring duplicate IP <%s>...' % netDeviceName)
            ## If an IP is available, build a Net Device CI
            if ipOSH:
                ciscoworks_utils.debugPrint(3, '[' + SCRIPT_NAME + ':processNetDeviceInfo] Creating CI for Net Device <%s> with <%s> as key' % (netDeviceName, ipAddress))
                netDeviceOSH = modeling.createHostOSH(ipAddress, 'netdevice')
                netDeviceOSH.setAttribute('data_externalid', netDeviceName)
                if netDeviceName and not netutils.isValidIp(netDeviceName):
                    netDeviceOSH.setAttribute('name', netDeviceName)
                if netDeviceDnsName:
                    netDeviceOSH.setAttribute('primary_dns_name', netDeviceDnsName)
                netDeviceOSHV.add(netDeviceOSH)
        return (netDeviceOSH, ipOSH)
    except:
        excInfo = logger.prepareJythonStackTrace('')
        logger.warn('[' + SCRIPT_NAME + ':processNetDeviceInfo] Exception: <%s>' % excInfo)
        pass
def processPortInfo(portName, portDesc, vlanName, vlanID, portOSHV, portNextMac, netDeviceCmdbID, netDeviceName, netDeviceOSH):
    try:
        portOSH = None
        ciscoworks_utils.debugPrint(3, '[' + SCRIPT_NAME + ':processPortInfo] Got Physical Port <%s> for Net Device <%s>' % (portName, netDeviceName))

        if netDeviceCmdbID:
            portOSH = ciscoworks_utils.getCiByAttributesFromOSHV(portOSHV, 'physical_port', {'name':portName, 'root_container':netDeviceCmdbID, 'port_vlan':vlanID})
        if portOSH:
            ciscoworks_utils.debugPrint(2, '[' + SCRIPT_NAME + ':processPortInfo] CI for Physical Port <%s> exists on Net Device <%s> in UCMDB' % (portName, netDeviceName))
            portOSH.setAttribute('port_nextmac', portNextMac)
            portOSH.setContainer(netDeviceOSH)
        else:
            return None
            ## Build PHYSICAL PORT OSH
            #ciscoworks_utils.debugPrint(4, '[' + SCRIPT_NAME + ':processPortInfo] Creating CI for Physical Port <%s> on Net Device <%s>' % (portName, netDeviceName))
            #portOSH = ObjectStateHolder('physical_port')
            #ciscoworks_utils.populateOSH(portOSH, {'name':portName, 'port_displayName':portName, 'description':portDesc, 'port_vlan':vlanID})
            #portOSH.setContainer(netDeviceOSH)
            #portOSH.setAttribute('port_nextmac', portNextMac)
        return portOSH
    except:
        excInfo = logger.prepareJythonStackTrace('')
        logger.warn('[' + SCRIPT_NAME + ':processPortInfo] Exception: <%s>' % excInfo)
        pass