Skip to content

Commit 715283a

Browse files
committed
Closes #35: Add ability to define password for accessing priviliged exec mode
1 parent 04297ca commit 715283a

File tree

8 files changed

+30
-4
lines changed

8 files changed

+30
-4
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ PLUGINS_CONFIG = {
7777
"netbox_config_diff": {
7878
"USERNAME": "foo",
7979
"PASSWORD": "bar",
80+
"AUTH_SECONDARY": "foobar", # define here password for accessing Privileged EXEC mode, this variable is optional
8081
},
8182
}
8283
```
@@ -119,6 +120,14 @@ No diff
119120

120121
![Screenshot of the compliance ok](docs/media/screenshots/compliance-ok.png)
121122

123+
Configuration request
124+
125+
![Screenshot of the CR](docs/media/screenshots/cr-created.png)
126+
127+
Completed Configuration request
128+
129+
![Screenshot of the completed CR](docs/media/screenshots/cr-completed.png)
130+
122131
## Credits
123132

124133
Based on the NetBox plugin tutorial:

docs/changelog.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# Changelog
22

3+
## 2.1.0 (2023-10-26)
4+
5+
* [#35](https://github.com/miaow2/netbox-config-diff/issues/35) Add ability to define password for accessing priviliged exec mode
6+
* [#37](https://github.com/miaow2/netbox-config-diff/issues/37) Add `DeviceRole` field to `CollectDiffScript`
7+
* [#38](https://github.com/miaow2/netbox-config-diff/issues/38) Remove config template filter for devices filed in forms
8+
* [#39](https://github.com/miaow2/netbox-config-diff/issues/39) Add `Status` field to `CollectDiffScript`
9+
* [#43](https://github.com/miaow2/netbox-config-diff/issues/43) `ConfigDiffScript` does not create empty changelog entries
10+
11+
## 2.0.1 (2023-10-22)
12+
13+
* [#33](https://github.com/miaow2/netbox-config-diff/issues/33) Fix failing migrations on fresh database install
14+
315
## 2.0.0 (2023-10-18)
416

517
* [#25](https://github.com/miaow2/netbox-config-diff/issues/25) Add configuration management
47.3 KB
Loading

docs/media/screenshots/cr-created.png

41.3 KB
Loading

docs/secrets.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ You can store credentials for devices authentification in NetBox secrets [plugin
44

55
Read NetBox secrets docs for more info.
66

7-
In plugin variables define secrets roles for username (`USER_SECRET_ROLE`) and password (`PASSWORD_SECRET_ROLE`).
7+
In plugin variables define secrets roles for username (`USER_SECRET_ROLE`), password (`PASSWORD_SECRET_ROLE`) and
8+
password (`SECOND_AUTH_SECRET_ROLE`) for Privileged EXEC mode.
89

910
Default values for this variables are:
1011

@@ -13,6 +14,7 @@ PLUGINS_CONFIG = {
1314
"netbox_config_diff": {
1415
"USER_SECRET_ROLE": "Username",
1516
"PASSWORD_SECRET_ROLE": "Password",
17+
"SECOND_AUTH_SECRET_ROLE": "Second Auth",
1618
},
1719
}
1820
```

netbox_config_diff/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
__author__ = "Artem Kotik"
44
__email__ = "miaow2@yandex.ru"
5-
__version__ = "2.0.1"
5+
__version__ = "2.1.0"
66

77

88
class ConfigDiffConfig(PluginConfig):
@@ -18,6 +18,7 @@ class ConfigDiffConfig(PluginConfig):
1818
default_settings = {
1919
"USER_SECRET_ROLE": "Username",
2020
"PASSWORD_SECRET_ROLE": "Password",
21+
"SECOND_AUTH_SECRET_ROLE": "Second Auth",
2122
}
2223

2324

netbox_config_diff/compliance/base.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def get_devices_with_rendered_configs(self, devices: Iterable[Device]) -> Iterat
124124
self.check_netbox_secrets()
125125
self.substitutes = {}
126126
for device in devices:
127-
username, password = self.get_credentials(device)
127+
username, password, auth_secondary = self.get_credentials(device)
128128
rendered_config = None
129129
error = None
130130
context_data = device.get_config_context()
@@ -152,6 +152,7 @@ def get_devices_with_rendered_configs(self, devices: Iterable[Device]) -> Iterat
152152
exclude_regex=device.platform.platform_setting.exclude_regex,
153153
username=username,
154154
password=password,
155+
auth_secondary=auth_secondary,
155156
rendered_config=rendered_config,
156157
error=error,
157158
)

netbox_config_diff/configurator/base.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def __init__(self, devices: Iterable[Device], request: NetBoxFakeRequest) -> Non
3737
def validate_devices(self) -> None:
3838
self.check_netbox_secrets()
3939
for device in self.devices:
40-
username, password = self.get_credentials(device)
40+
username, password, auth_secondary = self.get_credentials(device)
4141
if device.platform.platform_setting is None:
4242
self.logger.log_warning(f"Skipping {device}, add PlatformSetting for {device.platform} platform")
4343
elif device.platform.platform_setting.driver not in ACCEPTABLE_DRIVERS:
@@ -66,6 +66,7 @@ def validate_devices(self) -> None:
6666
platform=device.platform.platform_setting.driver,
6767
username=username,
6868
password=password,
69+
auth_secondary=auth_secondary,
6970
rendered_config=rendered_config,
7071
error=error,
7172
)

0 commit comments

Comments
 (0)