# 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 Lldp:
#     implements(ILldp)
# 
#     def __init__(self, sysname, sysdesc, portdesc, ip=None):
#         self.sysname = ascii(sysname)
#         self.sysdesc = ascii(sysdesc)
#         self.portdesc = ascii(portdesc)
#         self.ip = ip
# 
# class LocalVlan(Vlan):
#     implements(ILocalVlan)
# 
# class RemoteVlan(Vlan):
#     implements(IRemoteVlan)
# 
# Path: wiremaps/collector/helpers/speed.py
# class SpeedCollector:
#     """Collect speed/duplex/autoneg from 3 OID.
# 
#     Methods C{gotSpeed}, C{gotDuplex} and C{gotAutoneg} should be
#     implemented. c{oidDuplex}, c{oidSpeed} and c{oidAutoneg}
#     attributes should be defined.
#     """
# 
#     def gotSpeed(self, results):
#         raise NotImplementedError
#     def gotAutoneg(self, results):
#         raise NotImplementedError
#     def gotDuplex(self, results):
#         raise NotImplementedError
# 
#     def __init__(self, equipment, proxy, normPort=None):
#         self.proxy = proxy
#         self.equipment = equipment
#         self.normport = normPort
# 
#     def completeEquipment(self):
#         """Complete the equipment with data collected"""
#         for port in self.speed:
#             if self.normport and self.normport(port) is not None:
#                 nport = self.equipment.ports[self.normport(port)]
#             else:
#                 nport = self.equipment.ports[port]
#             nport.speed = self.speed[port]
#             nport.autoneg = self.autoneg.get(port, None)
#             nport.duplex = self.duplex.get(port, None)
# 
#     def collectData(self):
#         print "Collecting port speed/duplex for %s" % self.proxy.ip
#         self.speed = {}
#         self.duplex = {}
#         self.autoneg = {}
#         d = self.proxy.walk(self.oidDuplex)
#         d.addCallback(self.gotDuplex)
#         if hasattr(self, "oidSpeed"):
#             # Sometimes, speed comes with duplex
#             d.addCallback(lambda x: self.proxy.walk(self.oidSpeed))
#             d.addCallback(self.gotSpeed)
#         d.addCallback(lambda x: self.proxy.walk(self.oidAutoneg))
#         d.addCallback(self.gotAutoneg)
#         d.addCallback(lambda _: self.completeEquipment())
#         return d


from wiremaps.collector import exception
from wiremaps.collector.datastore import Lldp, LocalVlan, RemoteVlan
from wiremaps.collector.helpers.speed import SpeedCollector
                port = self.normport(port)
            if port is not None:
                self.lldpMgmtIp[port] = ip

    def gotLldpLocalVlan(self, results):
        """Callback handling reception of LLDP local vlan

        @param results: result of walking C{LLDP-EXT-DOT1-MIB::lldpXdot1LocVlanName}
        """
        for oid in results:
            vid = int(oid.split(".")[-1])
            port = int(oid.split(".")[-2])
            if self.normport is not None:
                port = self.normport(port)
            if port is not None:
                self.equipment.ports[port].vlan.append(
                    LocalVlan(vid, results[oid]))

    def gotLldpRemoteVlan(self, results):
        """Callback handling reception of LLDP remote vlan

        @param results: result of walking C{LLDP-EXT-DOT1-MIB::lldpXdot1RemVlanName}
        """
        for oid in results:
            vid = int(oid.split(".")[-1])
            port = int(oid.split(".")[-3])
            if self.normport is not None:
                port = self.normport(port)
            if port is not None:
                self.equipment.ports[port].vlan.append(

# 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 Lldp:
#     implements(ILldp)
# 
#     def __init__(self, sysname, sysdesc, portdesc, ip=None):
#         self.sysname = ascii(sysname)
#         self.sysdesc = ascii(sysdesc)
#         self.portdesc = ascii(portdesc)
#         self.ip = ip
# 
# class LocalVlan(Vlan):
#     implements(ILocalVlan)
# 
# class RemoteVlan(Vlan):
#     implements(IRemoteVlan)
# 
# Path: wiremaps/collector/helpers/speed.py
# class SpeedCollector:
#     """Collect speed/duplex/autoneg from 3 OID.
# 
#     Methods C{gotSpeed}, C{gotDuplex} and C{gotAutoneg} should be
#     implemented. c{oidDuplex}, c{oidSpeed} and c{oidAutoneg}
#     attributes should be defined.
#     """
# 
#     def gotSpeed(self, results):
#         raise NotImplementedError
#     def gotAutoneg(self, results):
#         raise NotImplementedError
#     def gotDuplex(self, results):
#         raise NotImplementedError
# 
#     def __init__(self, equipment, proxy, normPort=None):
#         self.proxy = proxy
#         self.equipment = equipment
#         self.normport = normPort
# 
#     def completeEquipment(self):
#         """Complete the equipment with data collected"""
#         for port in self.speed:
#             if self.normport and self.normport(port) is not None:
#                 nport = self.equipment.ports[self.normport(port)]
#             else:
#                 nport = self.equipment.ports[port]
#             nport.speed = self.speed[port]
#             nport.autoneg = self.autoneg.get(port, None)
#             nport.duplex = self.duplex.get(port, None)
# 
#     def collectData(self):
#         print "Collecting port speed/duplex for %s" % self.proxy.ip
#         self.speed = {}
#         self.duplex = {}
#         self.autoneg = {}
#         d = self.proxy.walk(self.oidDuplex)
#         d.addCallback(self.gotDuplex)
#         if hasattr(self, "oidSpeed"):
#             # Sometimes, speed comes with duplex
#             d.addCallback(lambda x: self.proxy.walk(self.oidSpeed))
#             d.addCallback(self.gotSpeed)
#         d.addCallback(lambda x: self.proxy.walk(self.oidAutoneg))
#         d.addCallback(self.gotAutoneg)
#         d.addCallback(lambda _: self.completeEquipment())
#         return d


# Path: wiremaps/collector/helpers/lldp.py
from wiremaps.collector import exception
from wiremaps.collector.datastore import Lldp, LocalVlan, RemoteVlan
from wiremaps.collector.helpers.speed import SpeedCollector

                port = self.normport(port)
            if port is not None:
                self.lldpMgmtIp[port] = ip

    def gotLldpLocalVlan(self, results):
        """Callback handling reception of LLDP local vlan

        @param results: result of walking C{LLDP-EXT-DOT1-MIB::lldpXdot1LocVlanName}
        """
        for oid in results:
            vid = int(oid.split(".")[-1])
            port = int(oid.split(".")[-2])
            if self.normport is not None:
                port = self.normport(port)
            if port is not None:
                self.equipment.ports[port].vlan.append(
                    LocalVlan(vid, results[oid]))

    def gotLldpRemoteVlan(self, results):
        """Callback handling reception of LLDP remote vlan

        @param results: result of walking C{LLDP-EXT-DOT1-MIB::lldpXdot1RemVlanName}
        """
        for oid in results:
            vid = int(oid.split(".")[-1])
            port = int(oid.split(".")[-3])
            if self.normport is not None:
                port = self.normport(port)
            if port is not None:
                self.equipment.ports[port].vlan.append(

                    RemoteVlan(vid, results[oid]))