예제 #1
0
    def gotVlanMembers(self, results):
        """Callback handling reception of VLAN members

        @param results: C{EXTREME-VLAN-MIB::ExtremeVlanOpaqueEntry}
        """
        for oid in results:
            slot = int(oid.split(".")[-1])
            vlan = int(oid.split(".")[-2])
            ports = results[oid]
            l = self.vlanPorts.get(vlan, [])
            for i in range(0, len(ports)):
                if ord(ports[i]) == 0:
                    continue
                for j in range(0, 8):
                    if ord(ports[i]) & (1 << j):
                        if self.slots:
                            l.append(8 - j + 8 * i + 1000 * slot)
                        else:
                            l.append(8 - j + 8 * i)
            self.vlanPorts[vlan] = l

        # Add all this to C{self.equipment}
        for vid in self.vlanDescr:
            if vid in self.vlanId and vid in self.vlanPorts:
                for port in self.vlanPorts[vid]:
                    self.equipment.ports[port].vlan.append(
                        LocalVlan(self.vlanId[vid], self.vlanDescr[vid]))
예제 #2
0
 def completeEquipment(self):
     # Interfaces
     names = {}
     status = {}
     mac = {}
     speed = {}
     duplex = {}
     interfaces = []
     for p in self.data["status"]:
         interfaces.append(
             [x.isdigit() and int(x) or x for x in p.split(".")])
     interfaces.sort()
     interfaces = [".".join([str(y) for y in x]) for x in interfaces]
     for p in self.data["status"]:
         index = interfaces.index(p) + 1
         self.equipment.ports[index] = \
             Port(p,
                  self.data["status"][p] == 0 and 'up' or 'down',
                  mac=(self.data["mac"].get(p, None) and \
                           ":".join([("%02x" % ord(m))
                                     for m in self.data["mac"][p]])),
                  speed=self.data["speed"].get(p, None),
                  duplex={0: None,
                          1: 'half',
                          2: 'full'}[self.data["duplex"].get(p, 0)])
     for trunk, port in self.association["trunk"]:
         if port not in interfaces: continue
         self.equipment.ports[interfaces.index(port) + 1].trunk = \
             Trunk(interfaces.index(trunk) + 1)
     for vlan, port in self.association["vlan"]:
         if vlan not in self.data["vid"]: continue
         if port not in interfaces: continue
         self.equipment.ports[interfaces.index(port) + 1].vlan.append(
             LocalVlan(self.data["vid"][vlan], vlan))
예제 #3
0
파일: 3com.py 프로젝트: xakraz/wiremaps
    def gotStackStatus(self, results):
        """Handle reception of C{IF-MIB::ifStackStatus}.

        We also complete C{self.equipment}
        """
        vlanPorts = {}
        for oid in results:
            if results[oid] == 1:  # active
                port = int(oid.split(".")[-1])
                if port > 10000:
                    # Those are logical ports
                    continue
                y = int(oid.split(".")[-2])
                if y not in self.vlanEncapsType:
                    # This VLAN can be untagged
                    if y not in self.vlanVid:
                        continue
                    vid = self.vlanVid[y]
                elif self.vlanEncapsType[y] == 2:  # vlanEncaps8021q
                    vid = self.vlanEncapsTag[y]
                if vid not in vlanPorts:
                    vlanPorts[vid] = []
                vlanPorts[vid].append(port)

        # Add all those information in C{self.equipment}
        for x in self.vlanVid:
            if self.vlanVid[x] in vlanPorts:
                for port in vlanPorts[self.vlanVid[x]]:
                    self.equipment.ports[port].vlan.append(
                        LocalVlan(self.vlanVid[x], self.vlanNames[x]))
예제 #4
0
파일: juniper.py 프로젝트: xakraz/wiremaps
 def gotPorts(self, results):
     for oid in results:
         port = int(oid.split(".")[-1])
         port = self.normport(self.realifId[port])
         vid = int(oid.split(".")[-2])
         vid = self.vlanVid[vid]
         if port is not None:
             self.equipment.ports[port].vlan.append(
                 LocalVlan(vid, self.names[vid]))
예제 #5
0
 def completeEquipment(self):
     """Use collected data to populate C{self.equipments}"""
     for port in self.vlans:
         if port not in self.ports.portNames:
             continue
         for vid in self.vlans[port]:
             if vid not in self.names:
                 continue
             self.equipment.ports[port].vlan.append(
                 LocalVlan(vid, self.names[vid]))
예제 #6
0
 def completeEquipment(self):
     """Complete C{self.equipment} with collected data."""
     for id in self.vids:
         if id not in self.vlans:
             continue
         for port in self.vlans[id]:
             if self.normPort is not None:
                 port = self.normPort(port)
             if port is not None:
                 self.equipment.ports[port].vlan.append(
                     LocalVlan(id, "VLAN %d" % id))
예제 #7
0
    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]))
예제 #8
0
 def completeEquipment(self):
     """Complete C{self.equipment} with collected data"""
     for vid in self.vlanNames:
         if vid in self.vlanPorts:
             for i in range(0, len(self.vlanPorts[vid])):
                 if ord(self.vlanPorts[vid][i]) == 0:
                     continue
                 for j in range(0, 8):
                     if ord(self.vlanPorts[vid][i]) & (1 << j):
                         port = 8 - j + 8 * i
                         if self.normPort is not None:
                             port = self.normPort(port)
                         if port is not None:
                             self.equipment.ports[port].vlan.append(
                                 LocalVlan(vid, self.vlanNames[vid]))