cli.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:bgpfu 作者: bgpfu 项目源码 文件源码
def prefixlist(ctx, as_set, output, output_format, proto, **kwargs):
    """ get prefix list for specified as-sets """
    if kwargs.get('debug', False):
        logging.basicConfig(level=logging.DEBUG)

    if kwargs.get('fancy', 0):
        prefixes = PrefixSet(aggregate=kwargs['aggregate'])
    else:
        prefixes = PrefixList()
    bgpfuc = bgpfu.client.IRRClient()
    with bgpfuc as c:
        if kwargs.get('sources', False):
            c.set_sources(kwargs['sources'])
#        prefixes = c.get_prefixes(as_set, proto)

        for chunk in c.iter_prefixes(as_set, proto):
            prefixes.iter_add(chunk)

        if not kwargs['fancy'] and kwargs['aggregate']:
            prefixes = prefixes.aggregate()

        with click.open_file(output, 'w') as fobj:
            outfmt.write(output_format, fobj, prefixes.str_list())

        print("LEN {}".format(len(prefixes)))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号