constants.py 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. from core.events import *
  2. from extras.choices import LogLevelChoices
  3. # Custom fields
  4. CUSTOMFIELD_EMPTY_VALUES = (None, '', [])
  5. # Webhooks
  6. HTTP_CONTENT_TYPE_JSON = 'application/json'
  7. WEBHOOK_EVENT_TYPES = {
  8. # Map registered event types to public webhook "event" equivalents
  9. OBJECT_CREATED: 'created',
  10. OBJECT_UPDATED: 'updated',
  11. OBJECT_DELETED: 'deleted',
  12. JOB_STARTED: 'job_started',
  13. JOB_COMPLETED: 'job_ended',
  14. JOB_FAILED: 'job_ended',
  15. JOB_ERRORED: 'job_ended',
  16. }
  17. # Dashboard
  18. DEFAULT_DASHBOARD = [
  19. {
  20. 'widget': 'extras.BookmarksWidget',
  21. 'width': 4,
  22. 'height': 5,
  23. 'title': 'Bookmarks',
  24. 'color': 'orange',
  25. },
  26. {
  27. 'widget': 'extras.ObjectCountsWidget',
  28. 'width': 4,
  29. 'height': 2,
  30. 'title': 'Organization',
  31. 'config': {
  32. 'models': [
  33. 'dcim.site',
  34. 'tenancy.tenant',
  35. 'tenancy.contact',
  36. ]
  37. }
  38. },
  39. {
  40. 'widget': 'extras.NoteWidget',
  41. 'width': 4,
  42. 'height': 2,
  43. 'title': 'Welcome!',
  44. 'color': 'green',
  45. 'config': {
  46. 'content': (
  47. 'This is your personal dashboard. Feel free to customize it by rearranging, resizing, or removing '
  48. 'widgets. You can also add new widgets using the "add widget" button below. Any changes affect only '
  49. '_your_ dashboard, so feel free to experiment!'
  50. )
  51. }
  52. },
  53. {
  54. 'widget': 'extras.ObjectCountsWidget',
  55. 'width': 4,
  56. 'height': 3,
  57. 'title': 'IPAM',
  58. 'config': {
  59. 'models': [
  60. 'ipam.vrf',
  61. 'ipam.aggregate',
  62. 'ipam.prefix',
  63. 'ipam.iprange',
  64. 'ipam.ipaddress',
  65. 'ipam.vlan',
  66. ]
  67. }
  68. },
  69. {
  70. 'widget': 'extras.RSSFeedWidget',
  71. 'width': 4,
  72. 'height': 4,
  73. 'title': 'NetBox News',
  74. 'config': {
  75. 'feed_url': 'https://api.netbox.oss.netboxlabs.com/v1/newsfeed/',
  76. 'max_entries': 10,
  77. 'cache_timeout': 14400,
  78. 'requires_internet': True,
  79. }
  80. },
  81. {
  82. 'widget': 'extras.ObjectCountsWidget',
  83. 'width': 4,
  84. 'height': 3,
  85. 'title': 'Circuits',
  86. 'config': {
  87. 'models': [
  88. 'circuits.provider',
  89. 'circuits.circuit',
  90. 'circuits.providernetwork',
  91. 'circuits.provideraccount',
  92. ]
  93. }
  94. },
  95. {
  96. 'widget': 'extras.ObjectCountsWidget',
  97. 'width': 4,
  98. 'height': 3,
  99. 'title': 'DCIM',
  100. 'config': {
  101. 'models': [
  102. 'dcim.site',
  103. 'dcim.rack',
  104. 'dcim.devicetype',
  105. 'dcim.device',
  106. 'dcim.cable',
  107. ],
  108. }
  109. },
  110. {
  111. 'widget': 'extras.ObjectCountsWidget',
  112. 'width': 4,
  113. 'height': 2,
  114. 'title': 'Virtualization',
  115. 'config': {
  116. 'models': [
  117. 'virtualization.cluster',
  118. 'virtualization.virtualmachine',
  119. ]
  120. }
  121. },
  122. {
  123. 'widget': 'extras.ObjectListWidget',
  124. 'width': 12,
  125. 'height': 5,
  126. 'title': 'Change Log',
  127. 'color': 'blue',
  128. 'config': {
  129. 'model': 'core.objectchange',
  130. 'page_size': 25,
  131. }
  132. },
  133. ]
  134. LOG_LEVEL_RANK = {
  135. LogLevelChoices.LOG_DEBUG: 0,
  136. LogLevelChoices.LOG_INFO: 1,
  137. LogLevelChoices.LOG_SUCCESS: 2,
  138. LogLevelChoices.LOG_WARNING: 3,
  139. LogLevelChoices.LOG_FAILURE: 4,
  140. }