How to use the capirca.lib.nacaddr.CollapseAddrList function in capirca

To help you get started, we’ve selected a few capirca examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github google / capirca / capirca / lib / policy.py View on Github external
def cleanup(addresses, complement_addresses):
      if not optimize:
        return nacaddr.SortAddrList(addresses)
      if addressbook:
        return nacaddr.CollapseAddrListPreserveTokens(addresses)
      else:
        return nacaddr.CollapseAddrList(addresses, complement_addresses)
github google / capirca / capirca / lib / summarizer.py View on Github external
def Summarize(nets):
  """Summarizes networks while allowing for discontinuous subnet mask.

  Args:
    nets: list of nacaddr.IPv4 or nacaddr.IPv6 objects.
        Address family can be mixed, however there is no support for rendering
        anything other than IPv4.

  Returns:
    sorted list of DSMIPNet objects.
  """

  result = []
  optimized_nets = nacaddr.CollapseAddrList(nets)
  nets_by_netmask = collections.defaultdict(list)
  # group nets by subnet mask
  for net in optimized_nets:
    nets_by_netmask[net.prefixlen].append(_NacaddrNetToDSMNet(net))
  for nets in nets_by_netmask.values():
    result.extend(_SummarizeSameMask(nets))
  return sorted(result)
github google / capirca / capirca / lib / policy.py View on Github external
def cleanup(addresses, complement_addresses):
      if not optimize:
        return nacaddr.SortAddrList(addresses)
      if addressbook:
        return nacaddr.CollapseAddrListPreserveTokens(addresses)
      else:
        return nacaddr.CollapseAddrList(addresses, complement_addresses)