No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

roa-export 957B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. # This file is part of dnmgmt, a number resource management system
  4. # Licensed under GNU General Public License v3 or later
  5. # Written by Sebastian Lohff (seba@someserver.de)
  6. import argparse
  7. import json
  8. import sys
  9. import os
  10. import django
  11. os.environ.setdefault("DJANGO_SETTINGS_MODULE", "dnmgmt.settings")
  12. BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
  13. sys.path.append(BASE_DIR)
  14. django.setup()
  15. from whoisdb.models import ASNumber
  16. __VERSION__ = '0.1'
  17. def _parser():
  18. parser = argparse.ArgumentParser()
  19. parser.add_argument("--version", action="version", version="%(prog)s " + __VERSION__)
  20. return parser
  21. def main():
  22. parser = _parser()
  23. parser.parse_args()
  24. roa = {}
  25. for asn in ASNumber.objects.all():
  26. nets = []
  27. for net in asn.inetnum_set.all():
  28. nets.append(net.prefix())
  29. if nets:
  30. roa[asn.number] = nets
  31. print(json.dumps(roa))
  32. if __name__ == '__main__':
  33. main()