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)))
评论列表
文章目录