-
Notifications
You must be signed in to change notification settings - Fork 237
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pass ssh_config only if file exists (#538)
* pass ssh_config only if file exists * added test that verifies non-existent files don't break
- Loading branch information
Showing
7 changed files
with
53 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from nornir.core.task import Result, Task | ||
from nornir.plugins.tasks import networking | ||
|
||
|
||
def get_task(task: Task, path: str = "", filter_type: str = "xpath") -> Result: | ||
manager = task.host.get_connection("netconf", task.nornir.config) | ||
params = {} | ||
if path: | ||
params["filter"] = (filter_type, path) | ||
result = manager.get(**params) | ||
|
||
return Result(host=task.host, result=result.data_xml) | ||
|
||
|
||
class Test: | ||
def test_netconf_connection_non_existent_ssh_config(self, netconf): | ||
netconf = netconf.filter(name="netconf2.no_group") | ||
assert netconf.inventory.hosts | ||
|
||
netconf.config.ssh.config_file = "i dont exist" | ||
result = netconf.run(networking.netconf_capabilities) | ||
assert result | ||
|
||
for _, v in result.items(): | ||
assert not isinstance(v.exception, FileNotFoundError) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters