constants.py 4.0 KB

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