Пример #1
0
    def __parseLstcpipInterfacesInfo(self, output):
        'str -> list(_InterfaceInfo)'
        infos = []
        for line in output.split('\n'):
            matchObj = re.match('(e[nt]+\d+)\s+(.*?)\s+(.*?)\s+(.*?)\s(.*)',
                                line.strip())
            if matchObj:
                status = matchObj.group(4)
                name = matchObj.group(1)

                index = self._getDevNameAndIndex(name)[1]
                interface = Interface(name=name, index=index)
                info = _InterfaceInfo(interface)

                if status.lower() == 'up':
                    status = _InterfaceInfo.STATUS_UP
                    mac = matchObj.group(5)
                    interface.mac = mac.strip()
                    netmask = matchObj.group(3)
                    ipAddress = matchObj.group(2)
                    info.ips.append(Ip(ipAddress, netmask))
                else:
                    status = _InterfaceInfo.STATUS_DETACHED
                    interface.mac = index

                info.status = status
                infos.append(info)
        return infos
Пример #2
0
    def __parseLstcpipInterfacesInfo(self, output):
        'str -> list(_InterfaceInfo)'
        infos = []
        for line in output.split('\n'):
            matchObj = re.match('(e[nt]+\d+)\s+(.*?)\s+(.*?)\s+(.*?)\s(.*)', line.strip())
            if matchObj:
                status = matchObj.group(4)
                name = matchObj.group(1)

                index = self._getDevNameAndIndex(name)[1]
                interface = Interface(name = name, index = index)
                info = _InterfaceInfo(interface)

                if status.lower() == 'up':
                    status = _InterfaceInfo.STATUS_UP
                    mac = matchObj.group(5)
                    interface.mac = mac.strip()
                    netmask = matchObj.group(3)
                    ipAddress = matchObj.group(2)
                    info.ips.append( Ip(ipAddress, netmask) )
                else:
                    status = _InterfaceInfo.STATUS_DETACHED
                    interface.mac = index

                info.status = status
                infos.append(info)
        return infos
Пример #3
0
    def discoverLinkAggregations(self, aixNetworking=None):
        ''' Discover networking related to link aggregations topology only
        list(networking.Interfaces) or None -> networking.UnixNetworking'''
        logger.debug("Discover Link Aggregation interfaces")
        aixNetworking = aixNetworking or UnixNetworking()
        nics = self.discoverAvailableInterfaces()
        nameToNic = {}
        map(lambda nic, nameToNic=nameToNic: nameToNic.update({nic.name: nic}),
            nics)
        # filter only link aggregations
        linkAggregations = filter(
            lambda nic: str(nic.description).lower().count("etherchannel"),
            nics)

        for interface in linkAggregations:
            logger.debug("Found LA: %s" % interface)
            nic = aixNetworking.getInterfaceByName(interface.name)
            if not nic:
                nic = interface
                aixNetworking.addInterface(nic)
            aggregationRole = AggregationRole()
            nic._addRole(aggregationRole)
            try:
                names = self._getMemberNamesOfLinkAggr(nic)
                logger.debug(
                    'Gather aggregation information for names %s of %s' %
                    (names, nic))
                for name in names:
                    aggregatedInterface = aixNetworking.getInterfaceByName(
                        name)
                    if not aggregatedInterface:
                        aggregatedInterface = nameToNic.get(name)
                        if not aggregatedInterface:
                            index = self._getDevNameAndIndex(name)[1]
                            aggregatedInterface = Interface(name=name,
                                                            index=index,
                                                            mac=index)
                        aixNetworking.addInterface(aggregatedInterface)
                    aggregatedRole = _AggregatedRole()
                    aggregatedRole.setAggregatingInterface(nic)
                    aggregatedInterface._addRole(aggregatedRole)
                    if not netutils.isValidMac(
                            aggregatedInterface.mac) and netutils.isValidMac(
                                nic.mac):
                        aggregatedInterface.mac = nic.mac
                    logger.debug('aggregated %s' % aggregatedInterface)
                    aggregationRole.addInterface(aggregatedInterface)
            except Exception, e:
                logger.warn(str(e))
            self._gatherIpInformation(nic, aixNetworking)
Пример #4
0
    def discoverLinkAggregations(self, aixNetworking = None):
        ''' Discover networking related to link aggregations topology only
        list(networking.Interfaces) or None -> networking.UnixNetworking'''
        logger.debug("Discover Link Aggregation interfaces")
        aixNetworking = aixNetworking or UnixNetworking()
        nics = self.discoverAvailableInterfaces()
        nameToNic = {}
        map(lambda nic, nameToNic = nameToNic: nameToNic.update({nic.name : nic}), nics)
        # filter only link aggregations
        linkAggregations = filter(lambda nic: str(nic.description).lower().count("etherchannel"), nics)

        for interface in linkAggregations:
            logger.debug("Found LA: %s" % interface)
            nic = aixNetworking.getInterfaceByName(interface.name)
            if not nic:
                nic = interface
                aixNetworking.addInterface(nic)
            aggregationRole = AggregationRole()
            nic._addRole(aggregationRole)
            try:
                names = self._getMemberNamesOfLinkAggr(nic)
                logger.debug('Gather aggregation information for names %s of %s' % (names, nic))
                for name in names:
                    aggregatedInterface = aixNetworking.getInterfaceByName(name)
                    if not aggregatedInterface:
                        aggregatedInterface = nameToNic.get(name)
                        if not aggregatedInterface:
                            index = self._getDevNameAndIndex(name)[1]
                            aggregatedInterface = Interface(name = name, index = index, mac = index)
                        aixNetworking.addInterface(aggregatedInterface)
                    aggregatedRole = _AggregatedRole()
                    aggregatedRole.setAggregatingInterface(nic)
                    aggregatedInterface._addRole(aggregatedRole)
                    if not netutils.isValidMac(aggregatedInterface.mac) and netutils.isValidMac(nic.mac):
                        aggregatedInterface.mac = nic.mac
                    logger.debug('aggregated %s' % aggregatedInterface)
                    aggregationRole.addInterface(aggregatedInterface)
            except Exception, e:
                logger.warn(str(e))
            self._gatherIpInformation(nic, aixNetworking)