networka 0.2.0__tar.gz → 0.3.0__tar.gz
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.
- {networka-0.2.0 → networka-0.3.0}/PKG-INFO +1 -1
- {networka-0.2.0 → networka-0.3.0}/docs/adding-platforms.md +19 -16
- {networka-0.2.0 → networka-0.3.0}/docs/configuration.md +12 -1
- {networka-0.2.0 → networka-0.3.0}/docs/development/platform-registry-explanations.md +6 -2
- {networka-0.2.0 → networka-0.3.0}/docs/development/platform-registry-implementation-plan.md +38 -15
- {networka-0.2.0 → networka-0.3.0}/docs/file_upload.md +2 -2
- {networka-0.2.0 → networka-0.3.0}/docs/library/adhoc-targets.md +4 -4
- {networka-0.2.0 → networka-0.3.0}/docs/library/quickstart.md +1 -5
- {networka-0.2.0 → networka-0.3.0}/docs/library/recipes.md +23 -19
- {networka-0.2.0 → networka-0.3.0}/docs/library/sessions.md +24 -13
- {networka-0.2.0 → networka-0.3.0}/docs/nornir-inventory.md +1 -3
- {networka-0.2.0 → networka-0.3.0}/docs/reference/introspection.md +10 -9
- {networka-0.2.0 → networka-0.3.0}/docs/running-commands.md +6 -0
- {networka-0.2.0 → networka-0.3.0}/docs/scrapli-platform-expansion-plan.md +3 -4
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/__about__.py +1 -1
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/__init__.py +7 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/api/run.py +59 -33
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/cli.py +6 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/client.py +5 -2
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/commands/run.py +4 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/config.py +36 -33
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/credentials.py +1 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/device.py +29 -7
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/inventory/nornir_simple.py +1 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/session_pool.py +10 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/transport/scrapli_sync.py +21 -2
- {networka-0.2.0 → networka-0.3.0}/.gitignore +0 -0
- {networka-0.2.0 → networka-0.3.0}/LICENSE +0 -0
- {networka-0.2.0 → networka-0.3.0}/README.md +0 -0
- {networka-0.2.0 → networka-0.3.0}/config/examples/README.md +0 -0
- {networka-0.2.0 → networka-0.3.0}/docs/LLM_TASK_NOTES.md +0 -0
- {networka-0.2.0 → networka-0.3.0}/docs/adding-gifs-guide.md +0 -0
- {networka-0.2.0 → networka-0.3.0}/docs/assets/gifs/networka-setup.gif +0 -0
- {networka-0.2.0 → networka-0.3.0}/docs/assets/images/networka.jpg +0 -0
- {networka-0.2.0 → networka-0.3.0}/docs/assets/images/networka.png +0 -0
- {networka-0.2.0 → networka-0.3.0}/docs/assets/images/networka2.png +0 -0
- {networka-0.2.0 → networka-0.3.0}/docs/assets/images/networka_readme.png +0 -0
- {networka-0.2.0 → networka-0.3.0}/docs/assets/javascripts/extra.js +0 -0
- {networka-0.2.0 → networka-0.3.0}/docs/assets/stylesheets/extra.css +0 -0
- {networka-0.2.0 → networka-0.3.0}/docs/backup-filename-normalization.md +0 -0
- {networka-0.2.0 → networka-0.3.0}/docs/backups.md +0 -0
- {networka-0.2.0 → networka-0.3.0}/docs/cisco-ios-platform-mapping.md +0 -0
- {networka-0.2.0 → networka-0.3.0}/docs/development/networka-release-qualification.md +0 -0
- {networka-0.2.0 → networka-0.3.0}/docs/development/networka-upgrade-plan.md +0 -0
- {networka-0.2.0 → networka-0.3.0}/docs/development/networka-upgrade-report-2026-11-24.md +0 -0
- {networka-0.2.0 → networka-0.3.0}/docs/development/platform-registry-summary.md +0 -0
- {networka-0.2.0 → networka-0.3.0}/docs/development.md +0 -0
- {networka-0.2.0 → networka-0.3.0}/docs/documentation-guidelines.md +0 -0
- {networka-0.2.0 → networka-0.3.0}/docs/environment-variables.md +0 -0
- {networka-0.2.0 → networka-0.3.0}/docs/examples/recipes.md +0 -0
- {networka-0.2.0 → networka-0.3.0}/docs/examples/user_sequences/README.md +0 -0
- {networka-0.2.0 → networka-0.3.0}/docs/examples/user_sequences/arista_eos/custom.yml +0 -0
- {networka-0.2.0 → networka-0.3.0}/docs/examples/user_sequences/mikrotik_routeros/custom.yml +0 -0
- {networka-0.2.0 → networka-0.3.0}/docs/getting-started.md +0 -0
- {networka-0.2.0 → networka-0.3.0}/docs/index.md +0 -0
- {networka-0.2.0 → networka-0.3.0}/docs/interactive-credentials.md +0 -0
- {networka-0.2.0 → networka-0.3.0}/docs/ip-address-support.md +0 -0
- {networka-0.2.0 → networka-0.3.0}/docs/library/index.md +0 -0
- {networka-0.2.0 → networka-0.3.0}/docs/multi-vendor-support.md +0 -0
- {networka-0.2.0 → networka-0.3.0}/docs/output-modes.md +0 -0
- {networka-0.2.0 → networka-0.3.0}/docs/overrides/home.html +0 -0
- {networka-0.2.0 → networka-0.3.0}/docs/overrides/partials/footer.html +0 -0
- {networka-0.2.0 → networka-0.3.0}/docs/overrides/partials/logo.html +0 -0
- {networka-0.2.0 → networka-0.3.0}/docs/platform-compatibility.md +0 -0
- {networka-0.2.0 → networka-0.3.0}/docs/pypi-setup.md +0 -0
- {networka-0.2.0 → networka-0.3.0}/docs/reference/api.md +0 -0
- {networka-0.2.0 → networka-0.3.0}/docs/reference/cli.md +0 -0
- {networka-0.2.0 → networka-0.3.0}/docs/results.md +0 -0
- {networka-0.2.0 → networka-0.3.0}/docs/shell-completion.md +0 -0
- {networka-0.2.0 → networka-0.3.0}/docs/ssh-config-sync.md +0 -0
- {networka-0.2.0 → networka-0.3.0}/docs/tmux-ssh.md +0 -0
- {networka-0.2.0 → networka-0.3.0}/docs/transport.md +0 -0
- {networka-0.2.0 → networka-0.3.0}/docs/troubleshooting.md +0 -0
- {networka-0.2.0 → networka-0.3.0}/docs/vendors/arista/index.md +0 -0
- {networka-0.2.0 → networka-0.3.0}/docs/vendors/cisco/index.md +0 -0
- {networka-0.2.0 → networka-0.3.0}/docs/vendors/index.md +0 -0
- {networka-0.2.0 → networka-0.3.0}/docs/vendors/juniper/index.md +0 -0
- {networka-0.2.0 → networka-0.3.0}/docs/vendors/mikrotik/index.md +0 -0
- {networka-0.2.0 → networka-0.3.0}/docs/vendors/nokia/index.md +0 -0
- {networka-0.2.0 → networka-0.3.0}/pyproject.toml +0 -0
- {networka-0.2.0 → networka-0.3.0}/shell_completion/bash_completion_nw.sh +0 -0
- {networka-0.2.0 → networka-0.3.0}/shell_completion/zsh_completion_nw.zsh +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/__main__.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/api/__init__.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/api/backup.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/api/diff.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/api/download.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/api/execution.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/api/firmware.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/api/info.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/api/list.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/api/platforms.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/api/routerboard_upgrade.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/api/state_diff.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/api/state_diff_patterns.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/api/upload.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/banner.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/builtin_sequences/arista_eos/common.yml +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/builtin_sequences/cisco_iosxe/common.yml +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/builtin_sequences/cisco_nxos/common.yml +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/builtin_sequences/juniper_junos/common.yml +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/builtin_sequences/mikrotik_routeros/common.yml +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/commands/__init__.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/commands/backup.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/commands/complete.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/commands/config.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/commands/diff.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/commands/download.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/commands/firmware.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/commands/info.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/commands/list.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/commands/platforms.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/commands/routerboard_upgrade.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/commands/schema.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/commands/sequence.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/commands/ssh.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/commands/ssh_engines.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/commands/ssh_fallback.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/commands/ssh_platform.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/commands/sync_ssh.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/commands/upload.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/commands/vendor_config_backup.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/common/color_magic.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/common/command.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/common/command_base.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/common/command_helpers.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/common/config_manifest.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/common/credentials.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/common/defaults.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/common/errors.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/common/file_utils.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/common/filename_utils.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/common/interactive_confirmation.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/common/logging.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/common/output.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/common/output_clean.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/common/paths.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/common/resolver.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/common/styles.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/common/table_generator.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/common/table_providers.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/device_transfers.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/exceptions.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/introspection.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/inventory/__init__.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/inventory/catalog.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/inventory/resolve.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/inventory/ssh_config.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/ip_device.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/platforms/__init__.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/platforms/base.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/platforms/cisco_ios/__init__.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/platforms/cisco_ios/operations.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/platforms/cisco_iosxe/__init__.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/platforms/cisco_iosxe/operations.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/platforms/cisco_shared/__init__.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/platforms/cisco_shared/operations.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/platforms/factory.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/platforms/mikrotik_routeros/__init__.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/platforms/mikrotik_routeros/confirmation_patterns.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/platforms/mikrotik_routeros/operations.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/platforms/registry.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/py.typed +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/results_enhanced.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/runtime.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/schemas/__init__.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/sequence_manager.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/shell_completion/bash_completion_nw.sh +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/shell_completion/zsh_completion_nw.zsh +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/transport/__init__.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/transport/factory.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/transport/interfaces.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/transport/nornir_inventory.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/transport/nornir_netmiko.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/tui/__init__.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/tui/app.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/tui/clipboard.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/tui/compat.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/tui/constants.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/tui/controller.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/tui/data.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/tui/dialogs.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/tui/helpers.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/tui/keymap.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/tui/layout.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/tui/models.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/tui/output_manager.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/tui/prompt.py +0 -0
- {networka-0.2.0 → networka-0.3.0}/src/network_toolkit/tui/services.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: networka
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: Modern Python cli toolkit for network device automation
|
|
5
5
|
Project-URL: Homepage, https://github.com/narrowin/networka
|
|
6
6
|
Project-URL: Documentation, https://narrowin.github.io/networka/
|
|
@@ -48,15 +48,14 @@ Edit `src/network_toolkit/platforms/registry.py` and add your platform to the `P
|
|
|
48
48
|
```python
|
|
49
49
|
PLATFORM_REGISTRY: dict[str, PlatformInfo] = {
|
|
50
50
|
# ... existing platforms ...
|
|
51
|
-
|
|
52
51
|
"your_platform": PlatformInfo(
|
|
53
|
-
device_type="your_platform",
|
|
54
|
-
display_name="Your Platform Name",
|
|
55
|
-
vendor="VendorName",
|
|
56
|
-
status=PlatformStatus.PLANNED,
|
|
52
|
+
device_type="your_platform", # Unique identifier (lowercase, underscore)
|
|
53
|
+
display_name="Your Platform Name", # Human-readable name
|
|
54
|
+
vendor="VendorName", # Vendor name for grouping
|
|
55
|
+
status=PlatformStatus.PLANNED, # Start with PLANNED
|
|
57
56
|
description="Brief platform description",
|
|
58
|
-
has_operations_class=False,
|
|
59
|
-
has_builtin_sequences=False,
|
|
57
|
+
has_operations_class=False, # Set True when adding operations
|
|
58
|
+
has_builtin_sequences=False, # Set True when adding sequences
|
|
60
59
|
),
|
|
61
60
|
}
|
|
62
61
|
```
|
|
@@ -511,6 +510,7 @@ def operations():
|
|
|
511
510
|
"""Provide operations instance."""
|
|
512
511
|
return YourPlatformOperations()
|
|
513
512
|
|
|
513
|
+
|
|
514
514
|
@pytest.fixture
|
|
515
515
|
def mock_session(mocker):
|
|
516
516
|
"""Provide mocked device session."""
|
|
@@ -528,21 +528,21 @@ Start with sequences before full implementation:
|
|
|
528
528
|
1. **PLANNED** - Add registry entry
|
|
529
529
|
|
|
530
530
|
```python
|
|
531
|
-
status=PlatformStatus.PLANNED
|
|
531
|
+
status = PlatformStatus.PLANNED
|
|
532
532
|
```
|
|
533
533
|
|
|
534
534
|
2. **SEQUENCES_ONLY** - Add command sequences
|
|
535
535
|
|
|
536
536
|
```python
|
|
537
|
-
status=PlatformStatus.SEQUENCES_ONLY
|
|
538
|
-
has_builtin_sequences=True
|
|
537
|
+
status = PlatformStatus.SEQUENCES_ONLY
|
|
538
|
+
has_builtin_sequences = True
|
|
539
539
|
```
|
|
540
540
|
|
|
541
541
|
3. **IMPLEMENTED** - Add operations class
|
|
542
542
|
```python
|
|
543
|
-
status=PlatformStatus.IMPLEMENTED
|
|
544
|
-
has_operations_class=True
|
|
545
|
-
capabilities=PlatformCapabilities(...)
|
|
543
|
+
status = PlatformStatus.IMPLEMENTED
|
|
544
|
+
has_operations_class = True
|
|
545
|
+
capabilities = PlatformCapabilities(...)
|
|
546
546
|
```
|
|
547
547
|
|
|
548
548
|
### Path 2: Full Implementation
|
|
@@ -561,14 +561,16 @@ Skip directly to full implementation if you have:
|
|
|
561
561
|
|
|
562
562
|
```python
|
|
563
563
|
# Fix: Add operations_class field
|
|
564
|
-
operations_class=
|
|
564
|
+
operations_class = (
|
|
565
|
+
"network_toolkit.platforms.your_platform.operations.YourPlatformOperations"
|
|
566
|
+
)
|
|
565
567
|
```
|
|
566
568
|
|
|
567
569
|
**Error: "Has firmware capabilities but no firmware_extensions specified"**
|
|
568
570
|
|
|
569
571
|
```python
|
|
570
572
|
# Fix: Add firmware extensions
|
|
571
|
-
firmware_extensions=[".bin", ".pkg"]
|
|
573
|
+
firmware_extensions = [".bin", ".pkg"]
|
|
572
574
|
```
|
|
573
575
|
|
|
574
576
|
### Platform Not Appearing in CLI
|
|
@@ -604,7 +606,7 @@ cat config/sequences/your_platform/common.yml
|
|
|
604
606
|
**Check registry flags:**
|
|
605
607
|
|
|
606
608
|
```python
|
|
607
|
-
has_builtin_sequences=True # Must be True
|
|
609
|
+
has_builtin_sequences = True # Must be True
|
|
608
610
|
```
|
|
609
611
|
|
|
610
612
|
### Operations Class Import Errors
|
|
@@ -622,6 +624,7 @@ src/network_toolkit/platforms/your_platform/
|
|
|
622
624
|
```python
|
|
623
625
|
# In __init__.py
|
|
624
626
|
from network_toolkit.platforms.your_platform.operations import YourPlatformOperations
|
|
627
|
+
|
|
625
628
|
__all__ = ["YourPlatformOperations"]
|
|
626
629
|
```
|
|
627
630
|
|
|
@@ -44,7 +44,6 @@ Configure this in `config/config.yml`:
|
|
|
44
44
|
inventory:
|
|
45
45
|
source: nornir_simple
|
|
46
46
|
nornir_inventory_dir: /path/to/clab-<lab-dir> # or a direct file path
|
|
47
|
-
merge_mode: replace
|
|
48
47
|
```
|
|
49
48
|
|
|
50
49
|
See [Nornir & Containerlab inventory](nornir-inventory.md) for the full workflow and options.
|
|
@@ -188,6 +187,18 @@ nw run router1 '/system/identity/print' --no-strict-host-key-checking
|
|
|
188
187
|
nw cli router1 --no-strict-host-key-checking
|
|
189
188
|
```
|
|
190
189
|
|
|
190
|
+
#### ssh_known_hosts_file
|
|
191
|
+
|
|
192
|
+
- **Type**: string (path, `~` is expanded)
|
|
193
|
+
- **Default**: unset, so the SSH client uses its own default file
|
|
194
|
+
- **Description**: Known-hosts file for CLI SSH sessions. The `system` transport always uses it. The `ssh2` transport uses it in strict mode. SFTP transfers still check `~/.ssh/known_hosts`.
|
|
195
|
+
|
|
196
|
+
```yaml
|
|
197
|
+
general:
|
|
198
|
+
ssh_strict_host_key_checking: true
|
|
199
|
+
ssh_known_hosts_file: ~/lab/known_hosts
|
|
200
|
+
```
|
|
201
|
+
|
|
191
202
|
## Bootstrap configuration (CLI)
|
|
192
203
|
|
|
193
204
|
Use the built-in `config` commands to inspect and manage configuration from the CLI. See the CLI reference for the full command set and options.
|
|
@@ -272,7 +272,9 @@ This is the "Facade Pattern" - common in Python projects:
|
|
|
272
272
|
from requests import get, post # Not: from requests.api import get
|
|
273
273
|
|
|
274
274
|
# Django
|
|
275
|
-
from django.conf import
|
|
275
|
+
from django.conf import (
|
|
276
|
+
settings,
|
|
277
|
+
) # Not: from django.conf.global_settings import settings
|
|
276
278
|
|
|
277
279
|
# Your project will do same
|
|
278
280
|
from network_toolkit.platforms import PLATFORM_REGISTRY
|
|
@@ -311,6 +313,7 @@ Or if you need more control:
|
|
|
311
313
|
# File: src/network_toolkit/config.py
|
|
312
314
|
from network_toolkit.platforms import PLATFORM_REGISTRY
|
|
313
315
|
|
|
316
|
+
|
|
314
317
|
def get_supported_device_types() -> set[str]:
|
|
315
318
|
"""Get supported device types from registry."""
|
|
316
319
|
return set(PLATFORM_REGISTRY.keys())
|
|
@@ -324,7 +327,8 @@ def get_supported_device_types() -> set[str]:
|
|
|
324
327
|
|
|
325
328
|
```python
|
|
326
329
|
# File: src/network_toolkit/platforms/registry.py
|
|
327
|
-
PLATFORM_REGISTRY = {
|
|
330
|
+
PLATFORM_REGISTRY = {...}
|
|
331
|
+
|
|
328
332
|
|
|
329
333
|
def get_platform_info(device_type: str) -> PlatformInfo | None:
|
|
330
334
|
return PLATFORM_REGISTRY.get(device_type)
|
|
@@ -117,26 +117,34 @@ This leads to:
|
|
|
117
117
|
from enum import Enum
|
|
118
118
|
from pydantic import BaseModel, Field
|
|
119
119
|
|
|
120
|
+
|
|
120
121
|
class PlatformStatus(str, Enum):
|
|
121
|
-
IMPLEMENTED = "implemented"
|
|
122
|
+
IMPLEMENTED = "implemented" # Full operations + sequences + docs
|
|
122
123
|
SEQUENCES_ONLY = "sequences_only" # Only builtin sequences, no operations
|
|
123
|
-
PLANNED = "planned"
|
|
124
|
-
EXPERIMENTAL = "experimental"
|
|
124
|
+
PLANNED = "planned" # On roadmap, no implementation
|
|
125
|
+
EXPERIMENTAL = "experimental" # Partial implementation, unstable
|
|
126
|
+
|
|
125
127
|
|
|
126
128
|
class PlatformCapabilities(BaseModel):
|
|
127
129
|
"""What operations this platform supports."""
|
|
130
|
+
|
|
128
131
|
firmware_upgrade: bool = False
|
|
129
132
|
firmware_downgrade: bool = False
|
|
130
133
|
bios_upgrade: bool = False
|
|
131
134
|
config_backup: bool = False
|
|
132
135
|
comprehensive_backup: bool = False
|
|
133
136
|
|
|
137
|
+
|
|
134
138
|
class PlatformInfo(BaseModel):
|
|
135
139
|
"""Complete information about a network platform."""
|
|
136
140
|
|
|
137
141
|
# Identity
|
|
138
|
-
device_type: str = Field(
|
|
139
|
-
|
|
142
|
+
device_type: str = Field(
|
|
143
|
+
description="Unique identifier (e.g., 'mikrotik_routeros')"
|
|
144
|
+
)
|
|
145
|
+
display_name: str = Field(
|
|
146
|
+
description="Human-readable name (e.g., 'MikroTik RouterOS')"
|
|
147
|
+
)
|
|
140
148
|
vendor: str = Field(description="Vendor name (e.g., 'MikroTik')")
|
|
141
149
|
|
|
142
150
|
# Status
|
|
@@ -145,13 +153,22 @@ class PlatformInfo(BaseModel):
|
|
|
145
153
|
|
|
146
154
|
# Technical details
|
|
147
155
|
capabilities: PlatformCapabilities = Field(default_factory=PlatformCapabilities)
|
|
148
|
-
firmware_extensions: list[str] = Field(
|
|
156
|
+
firmware_extensions: list[str] = Field(
|
|
157
|
+
default_factory=list, description="Supported firmware file extensions"
|
|
158
|
+
)
|
|
149
159
|
|
|
150
160
|
# References
|
|
151
|
-
has_operations_class: bool = Field(
|
|
161
|
+
has_operations_class: bool = Field(
|
|
162
|
+
description="Has platform operations implementation"
|
|
163
|
+
)
|
|
152
164
|
has_builtin_sequences: bool = Field(description="Has builtin command sequences")
|
|
153
|
-
docs_path: str | None = Field(
|
|
154
|
-
|
|
165
|
+
docs_path: str | None = Field(
|
|
166
|
+
default=None, description="Relative path to vendor docs"
|
|
167
|
+
)
|
|
168
|
+
operations_class: str | None = Field(
|
|
169
|
+
default=None, description="Fully qualified class name"
|
|
170
|
+
)
|
|
171
|
+
|
|
155
172
|
|
|
156
173
|
# The single source of truth
|
|
157
174
|
PLATFORM_REGISTRY: dict[str, PlatformInfo] = {
|
|
@@ -282,40 +299,46 @@ PLATFORM_REGISTRY: dict[str, PlatformInfo] = {
|
|
|
282
299
|
),
|
|
283
300
|
}
|
|
284
301
|
|
|
302
|
+
|
|
285
303
|
# Helper functions
|
|
286
304
|
def get_platform_info(device_type: str) -> PlatformInfo | None:
|
|
287
305
|
"""Get platform info by device type."""
|
|
288
306
|
return PLATFORM_REGISTRY.get(device_type)
|
|
289
307
|
|
|
308
|
+
|
|
290
309
|
def get_implemented_platforms() -> dict[str, PlatformInfo]:
|
|
291
310
|
"""Get only fully implemented platforms."""
|
|
292
311
|
return {
|
|
293
|
-
k: v
|
|
312
|
+
k: v
|
|
313
|
+
for k, v in PLATFORM_REGISTRY.items()
|
|
294
314
|
if v.status == PlatformStatus.IMPLEMENTED
|
|
295
315
|
}
|
|
296
316
|
|
|
317
|
+
|
|
297
318
|
def get_platforms_by_status(status: PlatformStatus) -> dict[str, PlatformInfo]:
|
|
298
319
|
"""Get platforms by status."""
|
|
299
|
-
return {
|
|
300
|
-
|
|
301
|
-
if v.status == status
|
|
302
|
-
}
|
|
320
|
+
return {k: v for k, v in PLATFORM_REGISTRY.items() if v.status == status}
|
|
321
|
+
|
|
303
322
|
|
|
304
323
|
def get_platforms_by_vendor(vendor: str) -> list[PlatformInfo]:
|
|
305
324
|
"""Get all platforms for a vendor."""
|
|
306
325
|
return [v for v in PLATFORM_REGISTRY.values() if v.vendor.lower() == vendor.lower()]
|
|
307
326
|
|
|
327
|
+
|
|
308
328
|
def get_platforms_with_capability(capability: str) -> list[PlatformInfo]:
|
|
309
329
|
"""Get platforms supporting a specific capability."""
|
|
310
330
|
return [
|
|
311
|
-
v
|
|
331
|
+
v
|
|
332
|
+
for v in PLATFORM_REGISTRY.values()
|
|
312
333
|
if getattr(v.capabilities, capability, False)
|
|
313
334
|
]
|
|
314
335
|
|
|
336
|
+
|
|
315
337
|
def get_supported_device_types() -> set[str]:
|
|
316
338
|
"""Get all device types (for validation)."""
|
|
317
339
|
return set(PLATFORM_REGISTRY.keys())
|
|
318
340
|
|
|
341
|
+
|
|
319
342
|
def validate_registry() -> list[str]:
|
|
320
343
|
"""Validate registry consistency. Returns list of errors."""
|
|
321
344
|
errors = []
|
|
@@ -28,7 +28,7 @@ with DeviceSession("router1", config) as session:
|
|
|
28
28
|
success = session.upload_file(
|
|
29
29
|
local_path="config_backup.rsc",
|
|
30
30
|
remote_filename="uploaded_config.rsc", # Optional: custom remote name
|
|
31
|
-
verify_upload=True # Optional: verify the upload
|
|
31
|
+
verify_upload=True, # Optional: verify the upload
|
|
32
32
|
)
|
|
33
33
|
|
|
34
34
|
if success:
|
|
@@ -49,7 +49,7 @@ results = DeviceSession.upload_file_to_devices(
|
|
|
49
49
|
local_path="firmware.npk",
|
|
50
50
|
remote_filename="new_firmware.npk",
|
|
51
51
|
verify_upload=True,
|
|
52
|
-
max_concurrent=3 # Upload to max 3 devices at once
|
|
52
|
+
max_concurrent=3, # Upload to max 3 devices at once
|
|
53
53
|
)
|
|
54
54
|
|
|
55
55
|
# Check results
|
|
@@ -15,7 +15,7 @@ client = NetworkaClient()
|
|
|
15
15
|
result = client.run(
|
|
16
16
|
target="192.168.1.100",
|
|
17
17
|
command_or_sequence="/system/identity/print",
|
|
18
|
-
device_type="mikrotik_routeros"
|
|
18
|
+
device_type="mikrotik_routeros",
|
|
19
19
|
)
|
|
20
20
|
|
|
21
21
|
if result.command_results:
|
|
@@ -35,7 +35,7 @@ client = NetworkaClient()
|
|
|
35
35
|
result = client.run(
|
|
36
36
|
target="192.168.1.100,192.168.1.101",
|
|
37
37
|
command_or_sequence="/system/identity/print",
|
|
38
|
-
device_type="mikrotik_routeros"
|
|
38
|
+
device_type="mikrotik_routeros",
|
|
39
39
|
)
|
|
40
40
|
|
|
41
41
|
# Access results
|
|
@@ -59,7 +59,7 @@ client.run(
|
|
|
59
59
|
target="192.168.1.100",
|
|
60
60
|
command_or_sequence="show version",
|
|
61
61
|
device_type="cisco_iosxe",
|
|
62
|
-
interactive_creds=creds
|
|
62
|
+
interactive_creds=creds,
|
|
63
63
|
)
|
|
64
64
|
```
|
|
65
65
|
|
|
@@ -93,7 +93,7 @@ client.run(
|
|
|
93
93
|
target="192.168.1.100",
|
|
94
94
|
command_or_sequence="show version",
|
|
95
95
|
device_type="mikrotik_routeros",
|
|
96
|
-
port=2222
|
|
96
|
+
port=2222,
|
|
97
97
|
)
|
|
98
98
|
```
|
|
99
99
|
|
|
@@ -74,11 +74,7 @@ from network_toolkit import NetworkaClient
|
|
|
74
74
|
client = NetworkaClient()
|
|
75
75
|
|
|
76
76
|
# Connect to an IP address (requires device_type)
|
|
77
|
-
result = client.run(
|
|
78
|
-
"192.168.1.1",
|
|
79
|
-
"show version",
|
|
80
|
-
device_type="mikrotik_routeros"
|
|
81
|
-
)
|
|
77
|
+
result = client.run("192.168.1.1", "show version", device_type="mikrotik_routeros")
|
|
82
78
|
if result.command_results:
|
|
83
79
|
print(result.command_results[0].output)
|
|
84
80
|
```
|
|
@@ -34,6 +34,7 @@ Run the same command on multiple devices simultaneously. Note that `NetworkaClie
|
|
|
34
34
|
from concurrent.futures import ThreadPoolExecutor, as_completed
|
|
35
35
|
from network_toolkit import NetworkaClient
|
|
36
36
|
|
|
37
|
+
|
|
37
38
|
def get_device_info(device_name):
|
|
38
39
|
"""Execute command on a single device."""
|
|
39
40
|
# Create a new client for each thread
|
|
@@ -45,12 +46,12 @@ def get_device_info(device_name):
|
|
|
45
46
|
except Exception as e:
|
|
46
47
|
return {"device": device_name, "output": None, "error": str(e)}
|
|
47
48
|
|
|
49
|
+
|
|
48
50
|
devices = ["router1", "router2", "router3", "router4"]
|
|
49
51
|
|
|
50
52
|
results = []
|
|
51
53
|
with ThreadPoolExecutor(max_workers=4) as executor:
|
|
52
|
-
futures = {executor.submit(get_device_info, dev): dev
|
|
53
|
-
for dev in devices}
|
|
54
|
+
futures = {executor.submit(get_device_info, dev): dev for dev in devices}
|
|
54
55
|
|
|
55
56
|
for future in as_completed(futures):
|
|
56
57
|
result = future.result()
|
|
@@ -72,6 +73,7 @@ Parse command output and validate against requirements:
|
|
|
72
73
|
```python
|
|
73
74
|
from network_toolkit import NetworkaClient
|
|
74
75
|
|
|
76
|
+
|
|
75
77
|
def check_compliance(device_name):
|
|
76
78
|
"""Run compliance checks on a device."""
|
|
77
79
|
checks = {
|
|
@@ -89,11 +91,12 @@ def check_compliance(device_name):
|
|
|
89
91
|
output = result.command_results[0].output if result.command_results else ""
|
|
90
92
|
results[check_name] = {
|
|
91
93
|
"passed": len(output) > 0 if output else False,
|
|
92
|
-
"output": output
|
|
94
|
+
"output": output,
|
|
93
95
|
}
|
|
94
96
|
|
|
95
97
|
return results
|
|
96
98
|
|
|
99
|
+
|
|
97
100
|
compliance = check_compliance("router1")
|
|
98
101
|
|
|
99
102
|
for check, result in compliance.items():
|
|
@@ -130,10 +133,7 @@ with DeviceSession("router1", client.config) as session:
|
|
|
130
133
|
|
|
131
134
|
# Download it
|
|
132
135
|
local_path = Path("./backups/router1-backup.backup")
|
|
133
|
-
session.download_file(
|
|
134
|
-
remote_file="mybackup.backup",
|
|
135
|
-
local_path=local_path
|
|
136
|
-
)
|
|
136
|
+
session.download_file(remote_file="mybackup.backup", local_path=local_path)
|
|
137
137
|
|
|
138
138
|
# Delete remote backup
|
|
139
139
|
session.execute_command("/file/remove mybackup.backup")
|
|
@@ -163,10 +163,7 @@ script_file.write_text(script_content)
|
|
|
163
163
|
try:
|
|
164
164
|
with DeviceSession("router1", client.config) as session:
|
|
165
165
|
# Upload script
|
|
166
|
-
session.upload_file(
|
|
167
|
-
local_file=script_file,
|
|
168
|
-
remote_path="temp_script.rsc"
|
|
169
|
-
)
|
|
166
|
+
session.upload_file(local_file=script_file, remote_path="temp_script.rsc")
|
|
170
167
|
|
|
171
168
|
# Execute it
|
|
172
169
|
output = session.execute_command("/import temp_script.rsc")
|
|
@@ -211,11 +208,12 @@ from network_toolkit import NetworkaClient, DeviceSession
|
|
|
211
208
|
from network_toolkit.exceptions import (
|
|
212
209
|
DeviceConnectionError,
|
|
213
210
|
DeviceExecutionError,
|
|
214
|
-
NetworkToolkitError
|
|
211
|
+
NetworkToolkitError,
|
|
215
212
|
)
|
|
216
213
|
|
|
217
214
|
client = NetworkaClient()
|
|
218
215
|
|
|
216
|
+
|
|
219
217
|
def safe_execute(device_name, command, config):
|
|
220
218
|
"""Execute command with comprehensive error handling."""
|
|
221
219
|
try:
|
|
@@ -227,30 +225,31 @@ def safe_execute(device_name, command, config):
|
|
|
227
225
|
return {
|
|
228
226
|
"success": False,
|
|
229
227
|
"output": None,
|
|
230
|
-
"error": f"Connection failed: {e.message}"
|
|
228
|
+
"error": f"Connection failed: {e.message}",
|
|
231
229
|
}
|
|
232
230
|
|
|
233
231
|
except DeviceExecutionError as e:
|
|
234
232
|
return {
|
|
235
233
|
"success": False,
|
|
236
234
|
"output": None,
|
|
237
|
-
"error": f"Command failed: {e.message}"
|
|
235
|
+
"error": f"Command failed: {e.message}",
|
|
238
236
|
}
|
|
239
237
|
|
|
240
238
|
except NetworkToolkitError as e:
|
|
241
239
|
return {
|
|
242
240
|
"success": False,
|
|
243
241
|
"output": None,
|
|
244
|
-
"error": f"Networka error: {e.message}"
|
|
242
|
+
"error": f"Networka error: {e.message}",
|
|
245
243
|
}
|
|
246
244
|
|
|
247
245
|
except Exception as e:
|
|
248
246
|
return {
|
|
249
247
|
"success": False,
|
|
250
248
|
"output": None,
|
|
251
|
-
"error": f"Unexpected error: {str(e)}"
|
|
249
|
+
"error": f"Unexpected error: {str(e)}",
|
|
252
250
|
}
|
|
253
251
|
|
|
252
|
+
|
|
254
253
|
result = safe_execute("router1", "/system/identity/print", client.config)
|
|
255
254
|
if result["success"]:
|
|
256
255
|
print(f"Output: {result['output']}")
|
|
@@ -266,6 +265,7 @@ Load credentials from environment or vault:
|
|
|
266
265
|
import os
|
|
267
266
|
from network_toolkit import NetworkaClient, DeviceSession, InteractiveCredentials
|
|
268
267
|
|
|
268
|
+
|
|
269
269
|
def get_credentials():
|
|
270
270
|
"""Load credentials from environment."""
|
|
271
271
|
return InteractiveCredentials(
|
|
@@ -273,12 +273,16 @@ def get_credentials():
|
|
|
273
273
|
password=os.getenv("DEVICE_PASSWORD", ""),
|
|
274
274
|
)
|
|
275
275
|
|
|
276
|
+
|
|
276
277
|
client = NetworkaClient()
|
|
277
278
|
creds = get_credentials()
|
|
278
279
|
|
|
279
|
-
with DeviceSession(
|
|
280
|
-
|
|
281
|
-
|
|
280
|
+
with DeviceSession(
|
|
281
|
+
"router1",
|
|
282
|
+
client.config,
|
|
283
|
+
username_override=creds.username,
|
|
284
|
+
password_override=creds.password,
|
|
285
|
+
) as session:
|
|
282
286
|
output = session.execute_command("/system/identity/print")
|
|
283
287
|
print(output)
|
|
284
288
|
```
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
`NetworkaClient` automatically manages SSH sessions for you. When you run a command, it checks if a connection to that device already exists. If so, it reuses it; if not, it opens a new one.
|
|
6
6
|
|
|
7
|
+
If a pooled session cannot connect, the client replaces it once. If a session loses its connection during a command, the call reports the error and the client closes that session and removes it from the pool. Networka does not send the command again, because the device may already have run it. The next call to that device opens a new session.
|
|
8
|
+
|
|
7
9
|
To ensure these connections are closed properly when you are done, you should use the client as a context manager.
|
|
8
10
|
|
|
9
11
|
**Recommended Pattern:**
|
|
@@ -21,7 +23,7 @@ with NetworkaClient() as client:
|
|
|
21
23
|
|
|
22
24
|
# You can switch between devices freely
|
|
23
25
|
client.run("switch1", "show vlan") # Opens new connection to switch1
|
|
24
|
-
client.run("router1", "show clock")
|
|
26
|
+
client.run("router1", "show clock") # Reuses existing connection to router1
|
|
25
27
|
|
|
26
28
|
# All sessions (router1, switch1) are closed here
|
|
27
29
|
```
|
|
@@ -65,9 +67,7 @@ Transfer a file to the device:
|
|
|
65
67
|
|
|
66
68
|
```python
|
|
67
69
|
client.upload(
|
|
68
|
-
target="router1",
|
|
69
|
-
local_file="firmware.npk",
|
|
70
|
-
remote_filename="firmware.npk"
|
|
70
|
+
target="router1", local_file="firmware.npk", remote_filename="firmware.npk"
|
|
71
71
|
)
|
|
72
72
|
```
|
|
73
73
|
|
|
@@ -77,9 +77,7 @@ Download a file from the device:
|
|
|
77
77
|
|
|
78
78
|
```python
|
|
79
79
|
client.download(
|
|
80
|
-
target="router1",
|
|
81
|
-
remote_file="backup.rsc",
|
|
82
|
-
local_path="./backups/backup.rsc"
|
|
80
|
+
target="router1", remote_file="backup.rsc", local_path="./backups/backup.rsc"
|
|
83
81
|
)
|
|
84
82
|
```
|
|
85
83
|
|
|
@@ -93,15 +91,11 @@ from network_toolkit.common.credentials import InteractiveCredentials
|
|
|
93
91
|
# Create credentials object
|
|
94
92
|
creds = InteractiveCredentials(
|
|
95
93
|
username="admin",
|
|
96
|
-
password="secret_password" # pragma: allowlist secret
|
|
94
|
+
password="secret_password", # pragma: allowlist secret
|
|
97
95
|
)
|
|
98
96
|
|
|
99
97
|
# Use credentials for this specific run
|
|
100
|
-
client.run(
|
|
101
|
-
"router1",
|
|
102
|
-
"show version",
|
|
103
|
-
interactive_creds=creds
|
|
104
|
-
)
|
|
98
|
+
client.run("router1", "show version", interactive_creds=creds)
|
|
105
99
|
```
|
|
106
100
|
|
|
107
101
|
## Error Handling
|
|
@@ -120,6 +114,20 @@ except ValueError as e:
|
|
|
120
114
|
# Connection still closes properly
|
|
121
115
|
```
|
|
122
116
|
|
|
117
|
+
`execute_command` raises `DeviceExecutionError` when the device rejects a command, and the message includes the device's reply. On RouterOS, replies that start with `syntax error`, `bad command name`, `expected end of command`, `input does not match any value`, `failure:` or `no such item` count as rejected. A connection failure raises `DeviceConnectionError` with the reason, and a rejected login raises its subclass `DeviceAuthError`.
|
|
118
|
+
|
|
119
|
+
`client.run()` does not raise for device failures. It reports them in `DeviceCommandResult.error` or `DeviceSequenceResult.error`, with the connection reason or the device's reply. A sequence stops at its first failed command, and `DeviceSequenceResult.outputs` keeps the outputs of the commands that ran before it.
|
|
120
|
+
|
|
121
|
+
## Logging
|
|
122
|
+
|
|
123
|
+
Networka does not configure logging when you use it as a library, and it prints nothing by default. Networka logs under the `network_toolkit` logger and Scrapli under `scrapli`. To see their records, configure logging in your application:
|
|
124
|
+
|
|
125
|
+
```python
|
|
126
|
+
import logging
|
|
127
|
+
|
|
128
|
+
logging.basicConfig(level=logging.WARNING)
|
|
129
|
+
```
|
|
130
|
+
|
|
123
131
|
## Parallel Sessions
|
|
124
132
|
|
|
125
133
|
Run commands on multiple devices simultaneously:
|
|
@@ -128,10 +136,12 @@ Run commands on multiple devices simultaneously:
|
|
|
128
136
|
from concurrent.futures import ThreadPoolExecutor
|
|
129
137
|
from network_toolkit import NetworkaClient, DeviceSession
|
|
130
138
|
|
|
139
|
+
|
|
131
140
|
def check_device(device_name, config):
|
|
132
141
|
with DeviceSession(device_name, config) as session:
|
|
133
142
|
return session.execute_command("/system/identity/print")
|
|
134
143
|
|
|
144
|
+
|
|
135
145
|
client = NetworkaClient()
|
|
136
146
|
devices = ["router1", "router2", "router3"]
|
|
137
147
|
|
|
@@ -152,6 +162,7 @@ general:
|
|
|
152
162
|
connection_retries: 3
|
|
153
163
|
retry_delay: 2
|
|
154
164
|
ssh_strict_host_key_checking: true
|
|
165
|
+
ssh_known_hosts_file: ~/lab/known_hosts
|
|
155
166
|
```
|
|
156
167
|
|
|
157
168
|
Disable strict host key checking programmatically:
|
|
@@ -19,7 +19,6 @@ general:
|
|
|
19
19
|
inventory:
|
|
20
20
|
source: nornir_simple
|
|
21
21
|
nornir_inventory_dir: /path/to/clab-<lab-dir>
|
|
22
|
-
merge_mode: replace
|
|
23
22
|
|
|
24
23
|
# Recommended when Containerlab inventory provides username/password
|
|
25
24
|
credentials_mode: inventory
|
|
@@ -75,8 +74,7 @@ With Scrapli’s default `system` transport, Networka will use your local OpenSS
|
|
|
75
74
|
|
|
76
75
|
- `inventory.source`: `nornir_simple`
|
|
77
76
|
- `inventory.nornir_inventory_dir`: directory containing `hosts.(yml|yaml)` (and optional `groups/defaults`), **or** a Containerlab lab directory, **or** a direct path to a `*.yml`/`*.yaml` hosts inventory file.
|
|
78
|
-
- `inventory.merge_mode`: `replace` (v1)
|
|
79
77
|
- `inventory.credentials_mode`: `env` (default) or `inventory` (opt-in)
|
|
80
78
|
- `inventory.group_membership`: `extended` (default) or `direct` (nested group inheritance only applies when `groups.(yml|yaml)` exists)
|
|
81
|
-
- `inventory.platform_mapping`: `none` (default) or `netmiko_to_networka`
|
|
79
|
+
- `inventory.platform_mapping`: `none` (default) or `netmiko_to_networka`. `netmiko_to_networka` maps Containerlab's `mikrotik_ros` and `mikrotik_chr` to `mikrotik_routeros`, `nokia_srl` to `nokia_srlinux`, `cisco_xe` to `cisco_iosxe` and `cisco_xr` to `cisco_iosxr`.
|
|
82
80
|
- `inventory.connect_host`: `inventory_hostname` (default), `host_key`, or `containerlab_longname`
|
|
@@ -72,16 +72,16 @@ Enum identifying the source type:
|
|
|
72
72
|
from network_toolkit.introspection import LoaderType
|
|
73
73
|
|
|
74
74
|
# Currently implemented
|
|
75
|
-
LoaderType.CONFIG_FILE
|
|
76
|
-
LoaderType.ENV_VAR
|
|
77
|
-
LoaderType.GROUP
|
|
78
|
-
LoaderType.SSH_CONFIG
|
|
75
|
+
LoaderType.CONFIG_FILE # YAML/CSV config file
|
|
76
|
+
LoaderType.ENV_VAR # Environment variable
|
|
77
|
+
LoaderType.GROUP # Device group inheritance
|
|
78
|
+
LoaderType.SSH_CONFIG # SSH config file
|
|
79
79
|
LoaderType.PYDANTIC_DEFAULT # Model default
|
|
80
80
|
|
|
81
81
|
# Reserved for future use
|
|
82
|
-
LoaderType.DOTENV
|
|
83
|
-
LoaderType.CLI
|
|
84
|
-
LoaderType.INTERACTIVE
|
|
82
|
+
LoaderType.DOTENV # .env file (planned)
|
|
83
|
+
LoaderType.CLI # CLI argument (planned)
|
|
84
|
+
LoaderType.INTERACTIVE # Interactive prompt (planned)
|
|
85
85
|
```
|
|
86
86
|
|
|
87
87
|
#### FieldHistory
|
|
@@ -114,8 +114,9 @@ history = ConfigHistory()
|
|
|
114
114
|
|
|
115
115
|
# Record field values
|
|
116
116
|
history.record_field("host", "10.0.0.1", LoaderType.PYDANTIC_DEFAULT)
|
|
117
|
-
history.record_field(
|
|
118
|
-
|
|
117
|
+
history.record_field(
|
|
118
|
+
"host", "192.168.1.1", LoaderType.CONFIG_FILE, identifier="devices.yml"
|
|
119
|
+
)
|
|
119
120
|
|
|
120
121
|
# Query
|
|
121
122
|
current = history.get_current("host") # Most recent value
|
|
@@ -68,6 +68,12 @@ device1: step 3/3 ... ok
|
|
|
68
68
|
Sequence completed successfully
|
|
69
69
|
```
|
|
70
70
|
|
|
71
|
+
## Exit status
|
|
72
|
+
|
|
73
|
+
`nw run` exits with code 0 when the command or sequence succeeded on every target device. It exits with code 1 when it failed on at least one device. This applies to a single device, a group and a device list. A group run prints the summary for all devices before it exits.
|
|
74
|
+
|
|
75
|
+
A command fails when Networka cannot connect, the login is rejected or the device rejects the command. On RouterOS, a reply that starts with `syntax error`, `bad command name`, `expected end of command`, `input does not match any value`, `failure:` or `no such item` counts as a rejected command. A sequence stops on a device at its first failed command.
|
|
76
|
+
|
|
71
77
|
## Upload and download
|
|
72
78
|
|
|
73
79
|
```bash
|