refactor(config): take the revision contract from napalm-device-types
driver / standard (pull_request) Successful in 17s
driver / lint (pull_request) Successful in 15s
driver / types (pull_request) Successful in 1m0s
driver / test (3.12) (pull_request) Successful in 1m11s
driver / test (3.13) (pull_request) Successful in 1m3s
driver / lowest (pull_request) Successful in 35s
driver / build (pull_request) Successful in 29s
driver / security (pull_request) Successful in 1m1s
CI / driver (pull_request) Successful in 2m44s
driver / publish (pull_request) Skipped
driver / standard (pull_request) Successful in 17s
driver / lint (pull_request) Successful in 15s
driver / types (pull_request) Successful in 1m0s
driver / test (3.12) (pull_request) Successful in 1m11s
driver / test (3.13) (pull_request) Successful in 1m3s
driver / lowest (pull_request) Successful in 35s
driver / build (pull_request) Successful in 29s
driver / security (pull_request) Successful in 1m1s
CI / driver (pull_request) Successful in 2m44s
driver / publish (pull_request) Skipped
napalm-device-types 4.38.0 declares ConfigRevisionsMixin: the listing, the reading, ConfigRevisionDict and the exceptions, and the revert as a template. The driver keeps the device communication: the three backup API calls, the revert step, and config_revision_content(), which leaves out the <revision> block every save writes into config.xml and the indentation between elements. The template reads the newest revision after the revert and checks that it holds the revision's configuration. OPNsense answers "reverted" even when restoreBackup() could not load the file and kept the previous one; that now raises ConfigRevertFailed instead of passing. A refusal of the firewall raises ConfigRevertFailed too. An id the history does not list still never reaches a request path. Refs NetOrk/netork#2511
This commit is contained in:
1 parent
5a20023c54
commit
a65a3ed6e3
5 files changed
+174
-62
No files matched your search
@@ -16,7 +16,7 @@ NAPALM community driver for **OPNsense** firewalls (read-only, via REST API).
|
||||
|---|---|
|
||||
| Python | 3.12 |
|
||||
| NAPALM | 4.0 |
|
||||
| napalm-device-types | 4.35.0 |
|
||||
| napalm-device-types | 4.38.0 |
|
||||
| requests | 2.28 |
|
||||
|
||||
## Installation
|
||||
@@ -208,10 +208,18 @@ first being the configuration in place now:
|
||||
]
|
||||
```
|
||||
|
||||
`get_config_revision(revision_id)` returns that revision's config.xml as text.
|
||||
`revert_config_revision(revision_id)` makes it the configuration again; it refuses an
|
||||
id that is not in the history now (`UnknownConfigRevision`, a `ValueError`) and raises
|
||||
`RuntimeError` when the firewall refuses, e.g. for a user with `user-config-readonly`.
|
||||
The contract is napalm-device-types' `ConfigRevisionsMixin`; this driver does the API
|
||||
calls. `get_config_revision(revision_id)` returns that revision's config.xml as text.
|
||||
`revert_config_revision(revision_id)` makes it the configuration again and returns the
|
||||
revision in place afterwards. It refuses an id that is not in the history now
|
||||
(`UnknownConfigRevision`, a `ValueError`) before anything changes, reads the revision,
|
||||
calls `revert_backup`, and then checks that the newest revision holds the revision's
|
||||
configuration: OPNsense answers `reverted` even when it could not load the file and kept
|
||||
the previous one. A refusal of the firewall (for a user with `user-config-readonly`) or
|
||||
a failed check raises `ConfigRevertFailed`, a `RuntimeError`. That is five requests.
|
||||
`config_revision_content(text)` is config.xml without the `<revision>` block every save
|
||||
writes (who, when, from where), in canonical XML, with the indentation between elements
|
||||
left out: two revisions with the same configuration compare equal through it.
|
||||
|
||||
**What a revert does.** OPNsense copies the revision over config.xml and saves it. The
|
||||
history gets a new newest entry with the revision's content, described as
|
||||
|
||||
Reference in new issue
Block a user