# Path: wiremaps/collector/exception.py
# class CollectorException(RuntimeError):
# class NoCommunity(CollectorException):
# class UnknownEquipment(CollectorException):
# class NoLLDP(CollectorException):
# class CollectorAlreadyRunning(CollectorException):
# 
# Path: wiremaps/collector/datastore.py
# class Cdp:
#     implements(ICdp)
# 
#     def __init__(self, sysname, port, ip, platform):
#         self.sysname = ascii(sysname)
#         self.port = port
#         self.ip = ip
#         self.platform = ascii(platform)


from wiremaps.collector import exception
from wiremaps.collector.datastore import Cdp

    def __init__(self, equipment, proxy):
        """Create a collector using CDP entries in SNMP.

        @param proxy: proxy to use to query SNMP
        @param equipment: equipment to complete with data from CDP
        """
        self.proxy = proxy
        self.equipment = equipment

    def gotCdp(self, results, dic):
        """Callback handling reception of CDP

        @param results: result of walking C{CISCO-CDP-MIB::cdpCacheXXXX}
        @param dic: dictionary where to store the result
        """
        for oid in results:
            port = int(oid[len(self.cdpCacheDeviceId):].split(".")[1])
            desc = results[oid]
            if desc and port is not None:
                dic[port] = desc

    def completeEquipment(self):
        """Add collected data to equipment."""
        for port in self.cdpDeviceId:
            if self.cdpAddressType[port] != 1:
                ip = "0.0.0.0"
            else:
                ip = ".".join(str(ord(i)) for i in self.cdpAddress[port])
            self.equipment.ports[port].cdp = \

# Path: wiremaps/collector/exception.py
# class CollectorException(RuntimeError):
# class NoCommunity(CollectorException):
# class UnknownEquipment(CollectorException):
# class NoLLDP(CollectorException):
# class CollectorAlreadyRunning(CollectorException):
# 
# Path: wiremaps/collector/datastore.py
# class Cdp:
#     implements(ICdp)
# 
#     def __init__(self, sysname, port, ip, platform):
#         self.sysname = ascii(sysname)
#         self.port = port
#         self.ip = ip
#         self.platform = ascii(platform)


# Path: wiremaps/collector/helpers/cdp.py
from wiremaps.collector import exception
from wiremaps.collector.datastore import Cdp


    def __init__(self, equipment, proxy):
        """Create a collector using CDP entries in SNMP.

        @param proxy: proxy to use to query SNMP
        @param equipment: equipment to complete with data from CDP
        """
        self.proxy = proxy
        self.equipment = equipment

    def gotCdp(self, results, dic):
        """Callback handling reception of CDP

        @param results: result of walking C{CISCO-CDP-MIB::cdpCacheXXXX}
        @param dic: dictionary where to store the result
        """
        for oid in results:
            port = int(oid[len(self.cdpCacheDeviceId):].split(".")[1])
            desc = results[oid]
            if desc and port is not None:
                dic[port] = desc

    def completeEquipment(self):
        """Add collected data to equipment."""
        for port in self.cdpDeviceId:
            if self.cdpAddressType[port] != 1:
                ip = "0.0.0.0"
            else:
                ip = ".".join(str(ord(i)) for i in self.cdpAddress[port])
            self.equipment.ports[port].cdp = \

                Cdp(self.cdpDeviceId[port],