ulagen.py 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/usr/bin/env python
  2. # Attribution: This script is copied and modified from one published by github user andrewlkho.
  3. # Repository: https://github.com/andrewlkho/ulagen
  4. import hashlib
  5. import time
  6. import uuid
  7. def get_eui64():
  8. mac = uuid.getnode()
  9. eui64 = mac >> 24 << 48 | 0xfffe000000 | mac & 0xffffff
  10. eui64_canon = "-".join([format(eui64, "02X")[i:i+2] for i in range(0, 18, 2)])
  11. return eui64_canon
  12. def time_ntpformat():
  13. # Seconds relative to 1900-01-01 00:00
  14. return time.time() - time.mktime((1900, 1, 1, 0, 0, 0, 0, 1, -1))
  15. def main():
  16. h = hashlib.sha1()
  17. h.update(get_eui64() + str(time_ntpformat()))
  18. globalid = h.hexdigest()[0:10]
  19. prefix = ":".join(("fd" + globalid[0:2], globalid[2:6], globalid[6:10]))
  20. print "# /path/to/dn42/registry/" + " - " + "data/inet6num/" + prefix + "::_48" + "\n"
  21. print "inet6num: " + prefix + ":0000:0000:0000:0000:0000" + " - " + prefix + ":ffff:ffff:ffff:ffff:ffff"
  22. print "cidr: " + prefix + "::/48"
  23. print "netname: " + "EXAMPLE-NET-1"
  24. print "admin-c: " + "EXAMPLE-DN42"
  25. print "tech-c: " + "EXAMPLE-DN42"
  26. print "mnt-by: " + "EXAMPLE-MNT"
  27. print "status: " + "ASSIGNED"
  28. print "source: " + "DN42"
  29. print "\n# /path/to/dn42/registry/" + " - " + "data/route6/" + prefix + "::_48" + "\n"
  30. print "route6: " + prefix + "::/48"
  31. print "origin: " + "AS<INSERT_NUMERIC_AUT_NUM_VALUE>"
  32. print "max-length: " + "48"
  33. print "mnt-by: " + "EXAMPLE-MNT"
  34. print "source: " + "DN42"
  35. print "\n" + "# Replace EXAMPLE with something else. E.g. OCEAN-{NET-1,DN42,MNT}"
  36. print "#"
  37. print "# Please remember this an examle object. It can be used as is if you replace EXAMPLE in the above lines."
  38. print "# To find out more about required and optional keys for the inet6num object. Please see data/schema/{INET6NUM,ROUTE6}-SCHEMA"
  39. if __name__ == "__main__":
  40. main()