networka 0.1.9__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 (93) hide show
  1. network_toolkit/__about__.py +4 -0
  2. network_toolkit/__init__.py +8 -0
  3. network_toolkit/__main__.py +10 -0
  4. network_toolkit/builtin_sequences/arista_eos/common.yml +53 -0
  5. network_toolkit/builtin_sequences/mikrotik_routeros/common.yml +52 -0
  6. network_toolkit/cli.py +265 -0
  7. network_toolkit/commands/__init__.py +8 -0
  8. network_toolkit/commands/backup.py +441 -0
  9. network_toolkit/commands/complete.py +172 -0
  10. network_toolkit/commands/config.py +1068 -0
  11. network_toolkit/commands/diff.py +485 -0
  12. network_toolkit/commands/download.py +197 -0
  13. network_toolkit/commands/firmware.py +780 -0
  14. network_toolkit/commands/info.py +377 -0
  15. network_toolkit/commands/list.py +345 -0
  16. network_toolkit/commands/routerboard_upgrade.py +204 -0
  17. network_toolkit/commands/run.py +839 -0
  18. network_toolkit/commands/schema_unified.py +91 -0
  19. network_toolkit/commands/sequence.py +17 -0
  20. network_toolkit/commands/ssh.py +540 -0
  21. network_toolkit/commands/ssh_engines.py +0 -0
  22. network_toolkit/commands/ssh_fallback.py +97 -0
  23. network_toolkit/commands/ssh_platform.py +120 -0
  24. network_toolkit/commands/upload.py +237 -0
  25. network_toolkit/commands/vendor_config_backup.py +378 -0
  26. network_toolkit/common/color_magic.py +177 -0
  27. network_toolkit/common/command.py +135 -0
  28. network_toolkit/common/command_base.py +135 -0
  29. network_toolkit/common/command_helpers.py +214 -0
  30. network_toolkit/common/credentials.py +86 -0
  31. network_toolkit/common/defaults.py +17 -0
  32. network_toolkit/common/errors.py +130 -0
  33. network_toolkit/common/interactive_confirmation.py +144 -0
  34. network_toolkit/common/logging.py +47 -0
  35. network_toolkit/common/output.py +594 -0
  36. network_toolkit/common/output_clean.py +244 -0
  37. network_toolkit/common/paths.py +86 -0
  38. network_toolkit/common/resolver.py +207 -0
  39. network_toolkit/common/styles.py +199 -0
  40. network_toolkit/common/table_generator.py +169 -0
  41. network_toolkit/common/table_providers.py +716 -0
  42. network_toolkit/config.py +1506 -0
  43. network_toolkit/credentials.py +288 -0
  44. network_toolkit/device.py +1658 -0
  45. network_toolkit/device_transfers.py +170 -0
  46. network_toolkit/exceptions.py +78 -0
  47. network_toolkit/ip_device.py +241 -0
  48. network_toolkit/platforms/__init__.py +21 -0
  49. network_toolkit/platforms/base.py +267 -0
  50. network_toolkit/platforms/cisco_ios/__init__.py +6 -0
  51. network_toolkit/platforms/cisco_ios/constants.py +15 -0
  52. network_toolkit/platforms/cisco_ios/operations.py +426 -0
  53. network_toolkit/platforms/cisco_iosxe/__init__.py +6 -0
  54. network_toolkit/platforms/cisco_iosxe/constants.py +15 -0
  55. network_toolkit/platforms/cisco_iosxe/operations.py +580 -0
  56. network_toolkit/platforms/cisco_shared/__init__.py +0 -0
  57. network_toolkit/platforms/cisco_shared/operations.py +0 -0
  58. network_toolkit/platforms/factory.py +190 -0
  59. network_toolkit/platforms/mikrotik_routeros/__init__.py +8 -0
  60. network_toolkit/platforms/mikrotik_routeros/confirmation_patterns.py +24 -0
  61. network_toolkit/platforms/mikrotik_routeros/constants.py +31 -0
  62. network_toolkit/platforms/mikrotik_routeros/operations.py +686 -0
  63. network_toolkit/results_enhanced.py +364 -0
  64. network_toolkit/schemas/__init__.py +8 -0
  65. network_toolkit/sequence_manager.py +239 -0
  66. network_toolkit/shell_completion/bash_completion_nw.sh +339 -0
  67. network_toolkit/shell_completion/zsh_completion_nw.zsh +136 -0
  68. network_toolkit/transport/__init__.py +15 -0
  69. network_toolkit/transport/factory.py +113 -0
  70. network_toolkit/transport/interfaces.py +46 -0
  71. network_toolkit/transport/nornir_inventory.py +173 -0
  72. network_toolkit/transport/nornir_netmiko.py +277 -0
  73. network_toolkit/transport/scrapli_sync.py +36 -0
  74. network_toolkit/tui/__init__.py +18 -0
  75. network_toolkit/tui/app.py +1275 -0
  76. network_toolkit/tui/clipboard.py +46 -0
  77. network_toolkit/tui/compat.py +111 -0
  78. network_toolkit/tui/constants.py +111 -0
  79. network_toolkit/tui/controller.py +550 -0
  80. network_toolkit/tui/data.py +149 -0
  81. network_toolkit/tui/dialogs.py +196 -0
  82. network_toolkit/tui/helpers.py +55 -0
  83. network_toolkit/tui/keymap.py +31 -0
  84. network_toolkit/tui/layout.py +111 -0
  85. network_toolkit/tui/models.py +93 -0
  86. network_toolkit/tui/output_manager.py +372 -0
  87. network_toolkit/tui/prompt.py +172 -0
  88. network_toolkit/tui/services.py +285 -0
  89. networka-0.1.9.dist-info/METADATA +316 -0
  90. networka-0.1.9.dist-info/RECORD +93 -0
  91. networka-0.1.9.dist-info/WHEEL +4 -0
  92. networka-0.1.9.dist-info/entry_points.txt +2 -0
  93. networka-0.1.9.dist-info/licenses/LICENSE +73 -0
@@ -0,0 +1,267 @@
1
+ # SPDX-License-Identifier: MIT
2
+ """Base platform abstraction classes for network device operations."""
3
+
4
+ from __future__ import annotations
5
+
6
+ from abc import ABC, abstractmethod
7
+ from pathlib import Path
8
+ from typing import TYPE_CHECKING
9
+
10
+ if TYPE_CHECKING:
11
+ from network_toolkit.device import DeviceSession
12
+
13
+
14
+ class PlatformOperations(ABC):
15
+ """Abstract base class for platform-specific operations.
16
+
17
+ Each platform must implement these methods to provide vendor-specific
18
+ implementations of common network operations.
19
+ """
20
+
21
+ def __init__(self, session: DeviceSession) -> None:
22
+ """Initialize platform operations with device session.
23
+
24
+ Parameters
25
+ ----------
26
+ session : DeviceSession
27
+ Active device session for executing commands
28
+ """
29
+ self.session = session
30
+
31
+ @abstractmethod
32
+ def firmware_upgrade(
33
+ self,
34
+ local_firmware_path: Path,
35
+ remote_filename: str | None = None,
36
+ verify_upload: bool = True,
37
+ verify_checksum: bool = True,
38
+ pre_reboot_delay: float = 3.0,
39
+ confirmation_timeout: float = 10.0,
40
+ ) -> bool:
41
+ """Upload firmware package and reboot device to apply it.
42
+
43
+ Parameters
44
+ ----------
45
+ local_firmware_path : Path
46
+ Path to the local firmware file
47
+ remote_filename : str | None
48
+ Remote filename (default: same as local file)
49
+ verify_upload : bool
50
+ Verify file was uploaded successfully
51
+ verify_checksum : bool
52
+ Verify file integrity using checksums
53
+ pre_reboot_delay : float
54
+ Delay in seconds before rebooting
55
+ confirmation_timeout : float
56
+ Timeout for confirmation prompts
57
+
58
+ Returns
59
+ -------
60
+ bool
61
+ True if upgrade was initiated successfully
62
+ """
63
+ ...
64
+
65
+ @abstractmethod
66
+ def firmware_downgrade(
67
+ self,
68
+ local_firmware_path: Path,
69
+ remote_filename: str | None = None,
70
+ verify_upload: bool = True,
71
+ verify_checksum: bool = True,
72
+ confirmation_timeout: float = 10.0,
73
+ ) -> bool:
74
+ """Upload older firmware package and schedule downgrade.
75
+
76
+ Parameters
77
+ ----------
78
+ local_firmware_path : Path
79
+ Path to the local firmware file
80
+ remote_filename : str | None
81
+ Remote filename (default: same as local file)
82
+ verify_upload : bool
83
+ Verify file was uploaded successfully
84
+ verify_checksum : bool
85
+ Verify file integrity using checksums
86
+ confirmation_timeout : float
87
+ Timeout for confirmation prompts
88
+
89
+ Returns
90
+ -------
91
+ bool
92
+ True if downgrade was initiated successfully
93
+ """
94
+ ...
95
+
96
+ @abstractmethod
97
+ def bios_upgrade(
98
+ self,
99
+ pre_reboot_delay: float = 3.0,
100
+ confirmation_timeout: float = 10.0,
101
+ verify_before: bool = True,
102
+ ) -> bool:
103
+ """Upgrade device BIOS/RouterBOOT and reboot to apply.
104
+
105
+ Parameters
106
+ ----------
107
+ pre_reboot_delay : float
108
+ Delay in seconds before rebooting
109
+ confirmation_timeout : float
110
+ Timeout for confirmation prompts
111
+ verify_before : bool
112
+ Verify current status before upgrade
113
+
114
+ Returns
115
+ -------
116
+ bool
117
+ True if BIOS upgrade was initiated successfully
118
+ """
119
+ ...
120
+
121
+ @abstractmethod
122
+ def create_backup(
123
+ self,
124
+ backup_sequence: list[str],
125
+ download_files: list[dict[str, str]] | None = None,
126
+ ) -> bool:
127
+ """Create device backup using platform-specific commands.
128
+
129
+ Parameters
130
+ ----------
131
+ backup_sequence : list[str]
132
+ List of commands to execute for backup
133
+ download_files : list[dict[str, str]] | None
134
+ Optional list of files to download after backup
135
+
136
+ Returns
137
+ -------
138
+ bool
139
+ True if backup was created successfully
140
+ """
141
+ ...
142
+
143
+ @abstractmethod
144
+ def config_backup(
145
+ self,
146
+ backup_sequence: list[str],
147
+ download_files: list[dict[str, str]] | None = None,
148
+ ) -> bool:
149
+ """Create device configuration backup using platform-specific commands.
150
+
151
+ This operation creates a text representation of the device configuration.
152
+ For text-only configuration exports.
153
+
154
+ Parameters
155
+ ----------
156
+ backup_sequence : list[str]
157
+ List of commands to execute for configuration backup
158
+ download_files : list[dict[str, str]] | None
159
+ Optional list of files to download after backup
160
+
161
+ Returns
162
+ -------
163
+ bool
164
+ True if configuration backup was created successfully
165
+ """
166
+ ...
167
+
168
+ @abstractmethod
169
+ def backup(
170
+ self,
171
+ backup_sequence: list[str],
172
+ download_files: list[dict[str, str]] | None = None,
173
+ ) -> bool:
174
+ """Create comprehensive device backup using platform-specific commands.
175
+
176
+ This operation creates both text and binary backups of the device.
177
+ For full system backup including configuration and system state.
178
+
179
+ Parameters
180
+ ----------
181
+ backup_sequence : list[str]
182
+ List of commands to execute for comprehensive backup
183
+ download_files : list[dict[str, str]] | None
184
+ Optional list of files to download after backup
185
+
186
+ Returns
187
+ -------
188
+ bool
189
+ True if comprehensive backup was created successfully
190
+ """
191
+ ...
192
+
193
+ @classmethod
194
+ @abstractmethod
195
+ def get_supported_file_extensions(cls) -> list[str]:
196
+ """Get list of supported firmware file extensions for this platform.
197
+
198
+ Returns
199
+ -------
200
+ list[str]
201
+ List of supported file extensions (e.g., ['.npk', '.pkg'])
202
+ """
203
+ ...
204
+
205
+ @classmethod
206
+ @abstractmethod
207
+ def get_platform_name(cls) -> str:
208
+ """Get human-readable platform name.
209
+
210
+ Returns
211
+ -------
212
+ str
213
+ Platform name (e.g., 'MikroTik RouterOS')
214
+ """
215
+ ...
216
+
217
+ @classmethod
218
+ @abstractmethod
219
+ def get_device_types(cls) -> list[str]:
220
+ """Get list of device types supported by this platform.
221
+
222
+ Returns
223
+ -------
224
+ list[str]
225
+ List of supported device types
226
+ """
227
+ ...
228
+
229
+ def is_operation_supported(self, operation: str) -> bool:
230
+ """Check if an operation is supported by this platform.
231
+
232
+ Parameters
233
+ ----------
234
+ operation : str
235
+ Operation name ('firmware_upgrade', 'bios_upgrade', etc.)
236
+
237
+ Returns
238
+ -------
239
+ bool
240
+ True if operation is supported
241
+ """
242
+ # Default implementation checks if method exists and is not abstract
243
+ if not hasattr(self, operation):
244
+ return False
245
+
246
+ method = getattr(self, operation)
247
+ return callable(method) and not getattr(method, "__isabstractmethod__", False)
248
+
249
+
250
+ class UnsupportedOperationError(Exception):
251
+ """Raised when an operation is not supported by a platform."""
252
+
253
+ def __init__(self, platform: str, operation: str) -> None:
254
+ """Initialize with platform and operation details.
255
+
256
+ Parameters
257
+ ----------
258
+ platform : str
259
+ Platform name
260
+ operation : str
261
+ Operation that is not supported
262
+ """
263
+ self.platform = platform
264
+ self.operation = operation
265
+ super().__init__(
266
+ f"Operation '{operation}' is not supported on platform '{platform}'"
267
+ )
@@ -0,0 +1,6 @@
1
+ # SPDX-License-Identifier: MIT
2
+ """Cisco IOS platform implementation."""
3
+
4
+ from network_toolkit.platforms.cisco_ios.operations import CiscoIOSOperations
5
+
6
+ __all__ = ["CiscoIOSOperations"]
@@ -0,0 +1,15 @@
1
+ # SPDX-License-Identifier: MIT
2
+ """Cisco IOS platform constants."""
3
+
4
+ # File extensions supported by Cisco IOS
5
+ SUPPORTED_FIRMWARE_EXTENSIONS = [".bin", ".tar"]
6
+
7
+ # Platform information
8
+ PLATFORM_NAME = "Cisco IOS"
9
+ DEVICE_TYPES = ["cisco_ios"]
10
+
11
+ # Default backup sequence commands (example - not implemented)
12
+ DEFAULT_BACKUP_SEQUENCE = [
13
+ "show running-config",
14
+ "show startup-config",
15
+ ]