Skip to content

Commit

Permalink
Dont set credentials, if using data source
Browse files Browse the repository at this point in the history
  • Loading branch information
miaow2 committed Jun 22, 2024
1 parent 206ee9e commit f926562
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
5 changes: 4 additions & 1 deletion netbox_config_diff/compliance/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,10 @@ def get_devices_with_rendered_configs(self, devices: Iterable[Device]) -> Iterat
self.check_netbox_secrets()
self.substitutes = {}
for device in devices:
username, password, auth_secondary, default_desired_privilege_level = self.get_credentials(device)
if self.data["data_source"]:
username, password, auth_secondary, default_desired_privilege_level = None, None, None, None
else:
username, password, auth_secondary, default_desired_privilege_level = self.get_credentials(device)
rendered_config = None
error = None
context_data = device.get_config_context()
Expand Down
5 changes: 4 additions & 1 deletion netbox_config_diff/compliance/secrets.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ def get_master_key(self) -> None:
self.master_key = sk.get_master_key(self.session_key)
except Exception as e:
if getattr(self, "logger"):
self.log_failure(f"Can't fetch master_key: {str(e)}")
if getattr(self.logger, "log_failure"):
self.logger.log_failure(f"Can't fetch master_key: {str(e)}")
else:
self.logger.error(f"Can't fetch master_key: {str(e)}")
else:
self.log_failure(f"Can't fetch master_key: {str(e)}")

Expand Down
4 changes: 2 additions & 2 deletions netbox_config_diff/models/data_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class BaseDeviceDataClass:
name: str
mgmt_ip: str
platform: str
username: str
password: str
username: str | None
password: str | None
exclude_regex: str | None = None
rendered_config: str | None = None
actual_config: str | None = None
Expand Down

0 comments on commit f926562

Please sign in to comment.