示例#1
0
def get_fpc_list(dev):
    """
    Will fetch the list of FPCs installed in the box along with the PFE numbers.
    """
    fpc_list = []
    logging.log(
        25, 'Looking for FPCs installed in [{}]'.format(dev.facts['hostname']))
    fpc_list_raw = JU.get_cli_cmd(dev, 'show chassis fpc',
                                  pipe=['Online']).split('\n')[:-1]
    for entry in fpc_list_raw:
        fpc = MPC()
        fpc.slot = [x for x in entry.split(' ') if x != ''][0]
        fpc.pfe_list = []
        logging.log(
            25, 'Detecting PFEs for FPCs installed in [{}]'.format(
                dev.facts['hostname']))
        cmd = 'request pfe execute command "sh jspec client" target fpc{}'.format(
            fpc.slot)
        pfe_list_raw = JU.get_cli_cmd(dev, cmd,
                                      pipe=['MQCHIP',
                                            'XMCHIP']).split('\n')[:-1]
        for entry in pfe_list_raw:
            pfe = [x for x in entry.split(' ') if x != ''][2][-2:-1]
            fpc.pfe_list.append(pfe)
        fpc_list.append(fpc)
    return fpc_list
示例#2
0
def get_vpls_broken(dev, mac_count=20):
    """
    Checks for any instances where not all macs are learned on RE side.
    """
    stats = JU.get_cli_cmd(dev, 'show vpls mac-table count',
                           pipe=['MAC address learned in routing instance VPLS_BASIC_11']).split('\n')[:-1]
    broken_instances = []
    for entry in stats:
        shards = entry.split(' ')
        if int(shards[0]) == 0:
            inst = vpls_instance()
            inst.name = shards[7]
            logging.error('Found no MACs in instance: [].'.format(inst.name))
        elif int(shards[0]) < mac_count:
            inst = vpls_instance()
            inst.name = shards[7]
            inst.re_mac = shards[0]
            logging.error('Found broken instance [{}]: MAC Count [{}] out of [{}].'.format(
                inst.name, inst.re_mac, mac_count))
            broken_instances.append(inst)
        elif int(shards[0]) > mac_count:
            inst = vpls_instance()
            inst.name = shards[7]
            inst.re_mac = shards[0]
            logging.error('To many MACs in instance [{}]: MAC Count [{}] out of [{}].'.format(
                inst.name, inst.re_mac, mac_count))
            broken_instances.append(inst)
    return broken_instances
示例#3
0
def get_bd_index(dev, broken_instances):
    """
    Screen scrape to get BD_INDEX on PFE.
    """
    bd_index_list = JU.get_cli_cmd(dev, 'request pfe execute command "sh bridge-domain" target fpc1')
    for entry in bd_index_list.split('\n'):
        for instance in broken_instances:
            if instance.name in entry:
                entry = [x for x in entry.split(' ') if x != '']
                instance.bd_index = str(int(entry[2], 16))
示例#4
0
def get_re_mac_list(dev, broken_instances):
    """
    Will fetch the list of MACs learned on RE.
    """
    for instance in broken_instances:
        mac_list_raw = JU.get_cli_cmd(dev, 'show vpls mac-table instance {}'.format(instance.name),
                                      pipe=['lsi.']).split('\n')[:-1]
        instance.re_mac_list = []
        for entry in mac_list_raw:
            mac = [x for x in entry.split(' ') if x != ''][0]
            instance.re_mac_list.append(mac)
示例#5
0
def get_mac_data(dev, fpc_list, log_name):
    logging.log(25, 'Starting log collection ......')
    mac_logs = ("#" * 80) + '\n' + "show vpls connections" + '\n' + ("#" *
                                                                     80) + '\n'
    mac_logs += JU.get_cli_cmd(dev, "show vpls connections")
    mac_logs += ("#" * 80) + '\n' + "show vpls mac-table" + '\n' + ("#" *
                                                                    80) + '\n'
    mac_logs += JU.get_cli_cmd(dev, "show vpls mac-table")
    for fpc in fpc_list:
        cmd_ukern_mac = 'request pfe execute command "show l2 manager mac-table" target fpc{0}'.format(
            fpc.slot)
        mac_logs += ("#" * 80) + '\n' + cmd_ukern_mac + '\n' + ("#" *
                                                                80) + '\n'
        mac_logs += JU.get_cli_cmd(dev, cmd_ukern_mac)
        for pfe in fpc.pfe_list:
            cmd_hw_mac = 'request pfe execute command "sh l2metro {1} mac hw" target fpc{0}'.format(
                fpc.slot, pfe)
            mac_logs += ("#" * 80) + '\n' + cmd_hw_mac + '\n' + ("#" *
                                                                 80) + '\n'
            mac_logs += JU.get_cli_cmd(dev, cmd_hw_mac)
    mac_logs += ("=" * 80 + '\n') * 3 + '\n'
    with open(log_name, 'a+') as f:
        f.write(mac_logs)
示例#6
0
def get_hw_mac_list(dev, fpc_list, broken_instances):
    for fpc in fpc_list:
        for pfe in fpc.pfe_list:
            hw_mac_list = []
            cmd = 'request pfe execute command "sh l2metro {1} mac hw" target fpc{0}'.format(fpc.slot, pfe)
            hw_mac_raw = JU.get_cli_cmd(dev, cmd).split('\n')
            for entry in hw_mac_raw:
                mac = [x for x in entry.split(' ') if x != '']
                if len(mac) > 3:
                    hw_mac_list.append(mac)
            for instance in broken_instances:
                for mac in hw_mac_list:
                    if instance.bd_index == mac[1]:
                        if mac[3] not in instance.re_mac_list:
                            logging.error('Found stale MAC: [{0}] for instance [{1}] bd_index [{2}] on FPC: [{3}] PFE: [{4}]'.format(
                                mac[3], instance.name, instance.bd_index, fpc.slot, pfe))