Exemplo n.º 1
0
    def __parseAggregatedInterfacesInLanscanOutput(self, lanscanOutput):
        ''' Returns mapping of link aggregation index to aggregated interfaces
        str -> map(int, list(networking.Interface))'''
        indexToInterfaces = {}
        for line in _split(lanscanOutput):
            if re.match(r"[\d\s]+", line):
                indices = line.split()
                linkAggregationIndex = indices[0]
                indices = map(lambda index: int(index), indices[1:])

                if indices:
                    for index in indices:
                        nic = Interface(index = index, mac = index)
                        name = self.__getInterfaceName(nic)
                        nic.name = name
                        indexToInterfaces.setdefault(linkAggregationIndex, []).append(nic)
        return indexToInterfaces
Exemplo n.º 2
0
    def __parseAggregatedInterfacesInLanscanOutput(self, lanscanOutput):
        ''' Returns mapping of link aggregation index to aggregated interfaces
        str -> map(int, list(networking.Interface))'''
        indexToInterfaces = {}
        for line in _split(lanscanOutput):
            if re.match(r"[\d\s]+", line):
                indices = line.split()
                linkAggregationIndex = indices[0]
                indices = map(lambda index: int(index), indices[1:])

                if indices:
                    for index in indices:
                        nic = Interface(index=index, mac=index)
                        name = self.__getInterfaceName(nic)
                        nic.name = name
                        indexToInterfaces.setdefault(linkAggregationIndex,
                                                     []).append(nic)
        return indexToInterfaces
Exemplo n.º 3
0
 def __parseInterfacesInIoscanOutput(self, ioscanOutput):
     'str -> map(str, networking.Interface)'
     nameToInterfaces = {}
     for line in _split(ioscanOutput):
         lanProperties = line.split(":")
         if line.count(":lan:") and len(lanProperties) > 16:
             hardwarePath = lanProperties[10]
             try:
                 interfaceIndex = int(lanProperties[12])
             except:
                 logger.warn('Cannot parse interface index from value: %s' % lanProperties[12])
             else:
                 description = lanProperties[17]
                 nic = Interface(description = description, index = interfaceIndex, mac = interfaceIndex)
                 hpuxRole = _HpuxInterfaceRole(hardwarePath = hardwarePath)
                 nic._addRole(hpuxRole)
                 name = self.__getInterfaceName(nic)
                 nic.name = name
                 nameToInterfaces[name] = nic
     return nameToInterfaces
Exemplo n.º 4
0
 def __parseInterfacesInIoscanOutput(self, ioscanOutput):
     'str -> map(str, networking.Interface)'
     nameToInterfaces = {}
     for line in _split(ioscanOutput):
         lanProperties = line.split(":")
         if line.count(":lan:") and len(lanProperties) > 16:
             hardwarePath = lanProperties[10]
             try:
                 interfaceIndex = int(lanProperties[12])
             except:
                 logger.warn('Cannot parse interface index from value: %s' %
                             lanProperties[12])
             else:
                 description = lanProperties[17]
                 nic = Interface(description=description,
                                 index=interfaceIndex,
                                 mac=interfaceIndex)
                 hpuxRole = _HpuxInterfaceRole(hardwarePath=hardwarePath)
                 nic._addRole(hpuxRole)
                 name = self.__getInterfaceName(nic)
                 nic.name = name
                 nameToInterfaces[name] = nic
     return nameToInterfaces