netbox-toolkit-plugin 0.1.0__py3-none-any.whl → 0.1.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. netbox_toolkit_plugin/__init__.py +32 -0
  2. {netbox_toolkit → netbox_toolkit_plugin}/api/serializers.py +71 -35
  3. {netbox_toolkit → netbox_toolkit_plugin}/api/urls.py +3 -3
  4. {netbox_toolkit → netbox_toolkit_plugin}/config.py +80 -73
  5. {netbox_toolkit → netbox_toolkit_plugin}/connectors/factory.py +170 -111
  6. {netbox_toolkit → netbox_toolkit_plugin}/connectors/netmiko_connector.py +242 -179
  7. {netbox_toolkit → netbox_toolkit_plugin}/connectors/scrapli_connector.py +256 -172
  8. netbox_toolkit_plugin/migrations/0001_initial.py +108 -0
  9. netbox_toolkit_plugin/migrations/0002_alter_command_options_alter_command_unique_together_and_more.py +70 -0
  10. {netbox_toolkit → netbox_toolkit_plugin}/migrations/0003_permission_system_update.py +26 -12
  11. {netbox_toolkit → netbox_toolkit_plugin}/migrations/0004_remove_django_permissions.py +27 -29
  12. {netbox_toolkit → netbox_toolkit_plugin}/migrations/0005_alter_command_options_and_more.py +7 -8
  13. {netbox_toolkit → netbox_toolkit_plugin}/migrations/0006_commandlog_parsed_data_commandlog_parsing_success_and_more.py +7 -8
  14. {netbox_toolkit → netbox_toolkit_plugin}/migrations/0007_alter_commandlog_parsing_template.py +6 -4
  15. {netbox_toolkit → netbox_toolkit_plugin}/models.py +31 -32
  16. {netbox_toolkit → netbox_toolkit_plugin}/navigation.py +6 -6
  17. {netbox_toolkit → netbox_toolkit_plugin}/services/command_service.py +188 -128
  18. {netbox_toolkit → netbox_toolkit_plugin}/services/rate_limiting_service.py +104 -97
  19. netbox_toolkit_plugin/tables.py +51 -0
  20. netbox_toolkit_plugin/templates/netbox_toolkit/command.html +108 -0
  21. netbox_toolkit_plugin/templates/netbox_toolkit/command_list.html +12 -0
  22. netbox_toolkit_plugin/templates/netbox_toolkit/commandlog.html +170 -0
  23. netbox_toolkit_plugin/templates/netbox_toolkit/device_toolkit.html +557 -0
  24. {netbox_toolkit/templates/netbox_toolkit → netbox_toolkit_plugin/templates/netbox_toolkit_plugin}/command.html +5 -5
  25. {netbox_toolkit/templates/netbox_toolkit → netbox_toolkit_plugin/templates/netbox_toolkit_plugin}/command_list.html +2 -2
  26. {netbox_toolkit/templates/netbox_toolkit → netbox_toolkit_plugin/templates/netbox_toolkit_plugin}/commandlog.html +2 -2
  27. {netbox_toolkit/templates/netbox_toolkit → netbox_toolkit_plugin/templates/netbox_toolkit_plugin}/device_toolkit.html +6 -6
  28. netbox_toolkit_plugin/urls.py +38 -0
  29. {netbox_toolkit → netbox_toolkit_plugin}/utils/logging.py +20 -19
  30. {netbox_toolkit → netbox_toolkit_plugin}/views.py +251 -169
  31. {netbox_toolkit_plugin-0.1.0.dist-info → netbox_toolkit_plugin-0.1.1.dist-info}/METADATA +2 -2
  32. netbox_toolkit_plugin-0.1.1.dist-info/RECORD +60 -0
  33. netbox_toolkit_plugin-0.1.1.dist-info/entry_points.txt +2 -0
  34. netbox_toolkit_plugin-0.1.1.dist-info/top_level.txt +1 -0
  35. netbox_toolkit/__init__.py +0 -30
  36. netbox_toolkit/migrations/0001_initial.py +0 -54
  37. netbox_toolkit/migrations/0002_alter_command_options_alter_command_unique_together_and_more.py +0 -66
  38. netbox_toolkit/tables.py +0 -37
  39. netbox_toolkit/urls.py +0 -22
  40. netbox_toolkit_plugin-0.1.0.dist-info/RECORD +0 -56
  41. netbox_toolkit_plugin-0.1.0.dist-info/entry_points.txt +0 -2
  42. netbox_toolkit_plugin-0.1.0.dist-info/top_level.txt +0 -1
  43. {netbox_toolkit → netbox_toolkit_plugin}/admin.py +0 -0
  44. {netbox_toolkit → netbox_toolkit_plugin}/api/__init__.py +0 -0
  45. {netbox_toolkit → netbox_toolkit_plugin}/api/mixins.py +0 -0
  46. {netbox_toolkit → netbox_toolkit_plugin}/api/schemas.py +0 -0
  47. {netbox_toolkit → netbox_toolkit_plugin}/api/views/__init__.py +0 -0
  48. {netbox_toolkit → netbox_toolkit_plugin}/api/views/command_logs.py +0 -0
  49. {netbox_toolkit → netbox_toolkit_plugin}/api/views/commands.py +0 -0
  50. {netbox_toolkit → netbox_toolkit_plugin}/connectors/__init__.py +0 -0
  51. {netbox_toolkit → netbox_toolkit_plugin}/connectors/base.py +0 -0
  52. {netbox_toolkit → netbox_toolkit_plugin}/exceptions.py +0 -0
  53. {netbox_toolkit → netbox_toolkit_plugin}/filtersets.py +0 -0
  54. {netbox_toolkit → netbox_toolkit_plugin}/forms.py +0 -0
  55. {netbox_toolkit → netbox_toolkit_plugin}/migrations/__init__.py +0 -0
  56. {netbox_toolkit → netbox_toolkit_plugin}/search.py +0 -0
  57. {netbox_toolkit → netbox_toolkit_plugin}/services/__init__.py +0 -0
  58. {netbox_toolkit → netbox_toolkit_plugin}/services/device_service.py +0 -0
  59. {netbox_toolkit/static/netbox_toolkit → netbox_toolkit_plugin/static/netbox_toolkit_plugin}/css/toolkit.css +0 -0
  60. {netbox_toolkit/static/netbox_toolkit → netbox_toolkit_plugin/static/netbox_toolkit_plugin}/js/toolkit.js +0 -0
  61. {netbox_toolkit/templates/netbox_toolkit → netbox_toolkit_plugin/templates/netbox_toolkit_plugin}/command_edit.html +0 -0
  62. {netbox_toolkit/templates/netbox_toolkit → netbox_toolkit_plugin/templates/netbox_toolkit_plugin}/commandlog_list.html +0 -0
  63. {netbox_toolkit → netbox_toolkit_plugin}/utils/__init__.py +0 -0
  64. {netbox_toolkit → netbox_toolkit_plugin}/utils/connection.py +0 -0
  65. {netbox_toolkit → netbox_toolkit_plugin}/utils/error_parser.py +0 -0
  66. {netbox_toolkit → netbox_toolkit_plugin}/utils/network.py +0 -0
  67. {netbox_toolkit_plugin-0.1.0.dist-info → netbox_toolkit_plugin-0.1.1.dist-info}/WHEEL +0 -0
  68. {netbox_toolkit_plugin-0.1.0.dist-info → netbox_toolkit_plugin-0.1.1.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,38 @@
1
+ from django.urls import path
2
+ from . import views
3
+
4
+ app_name = "netbox_toolkit_plugin"
5
+
6
+ urlpatterns = [
7
+ # Command views
8
+ path("commands/", views.CommandListView.as_view(), name="command_list"),
9
+ path("commands/add/", views.CommandEditView.as_view(), name="command_add"),
10
+ path("commands/<int:pk>/", views.CommandView.as_view(), name="command_detail"),
11
+ path(
12
+ "commands/<int:pk>/edit/", views.CommandEditView.as_view(), name="command_edit"
13
+ ),
14
+ path(
15
+ "commands/<int:pk>/delete/",
16
+ views.CommandDeleteView.as_view(),
17
+ name="command_delete",
18
+ ),
19
+ path(
20
+ "commands/<int:pk>/changelog/",
21
+ views.CommandChangeLogView.as_view(),
22
+ name="command_changelog",
23
+ ),
24
+ # Command Log views
25
+ path("logs/", views.CommandLogListView.as_view(), name="commandlog_list"),
26
+ path("logs/<int:pk>/", views.CommandLogView.as_view(), name="commandlog_view"),
27
+ path(
28
+ "logs/<int:pk>/changelog/",
29
+ views.CommandLogChangeLogView.as_view(),
30
+ name="commandlog_changelog",
31
+ ),
32
+ # Device toolkit view
33
+ path(
34
+ "devices/<int:pk>/toolkit/",
35
+ views.DeviceToolkitView.as_view(),
36
+ name="device_toolkit",
37
+ ),
38
+ ]
@@ -1,31 +1,32 @@
1
1
  """Logging utilities for NetBox Toolkit plugin."""
2
+
2
3
  import logging
3
4
  from django.conf import settings
4
5
 
5
6
 
6
7
  class RequireToolkitDebug(logging.Filter):
7
8
  """
8
- Custom logging filter that only allows log records when the plugin's
9
+ Custom logging filter that only allows log records when the plugin's
9
10
  debug_logging setting is enabled.
10
-
11
- This allows plugin-specific debug logging without requiring Django's
11
+
12
+ This allows plugin-specific debug logging without requiring Django's
12
13
  DEBUG=True, making it safe for production environments.
13
14
  """
14
-
15
+
15
16
  def filter(self, record):
16
17
  """
17
18
  Check if toolkit debug logging is enabled.
18
-
19
+
19
20
  Returns:
20
21
  bool: True if debug logging is enabled for this plugin
21
22
  """
22
23
  try:
23
24
  # Get plugin configuration from Django settings
24
- plugins_config = getattr(settings, 'PLUGINS_CONFIG', {})
25
- toolkit_config = plugins_config.get('netbox_toolkit', {})
26
-
25
+ plugins_config = getattr(settings, "PLUGINS_CONFIG", {})
26
+ toolkit_config = plugins_config.get("netbox_toolkit_plugin", {})
27
+
27
28
  # Check if debug_logging is enabled (default: False)
28
- return toolkit_config.get('debug_logging', False)
29
+ return toolkit_config.get("debug_logging", False)
29
30
  except (AttributeError, KeyError):
30
31
  # If configuration is not available, don't log
31
32
  return False
@@ -34,25 +35,25 @@ class RequireToolkitDebug(logging.Filter):
34
35
  def get_toolkit_logger(name: str) -> logging.Logger:
35
36
  """
36
37
  Get a logger for the toolkit plugin with the proper namespace.
37
-
38
+
38
39
  Args:
39
40
  name: Logger name (typically __name__)
40
-
41
+
41
42
  Returns:
42
43
  Logger instance for the toolkit plugin
43
44
  """
44
- # Ensure we're using the netbox_toolkit namespace
45
- if not name.startswith('netbox_toolkit'):
46
- if name == '__main__':
47
- name = 'netbox_toolkit'
45
+ # Ensure we're using the netbox_toolkit_plugin namespace
46
+ if not name.startswith("netbox_toolkit_plugin"):
47
+ if name == "__main__":
48
+ name = "netbox_toolkit_plugin"
48
49
  else:
49
50
  # Extract module name and add to toolkit namespace
50
- module_parts = name.split('.')
51
- if 'netbox_toolkit' in module_parts:
51
+ module_parts = name.split(".")
52
+ if "netbox_toolkit" in module_parts:
52
53
  # Already in our namespace, use as-is
53
54
  pass
54
55
  else:
55
56
  # Add to our namespace
56
- name = f'netbox_toolkit.{name.split(".")[-1]}'
57
-
57
+ name = f"netbox_toolkit.{name.split('.')[-1]}"
58
+
58
59
  return logging.getLogger(name)