This repository has been archived by the owner on Nov 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from netdevops/netconf
add netconf
- Loading branch information
Showing
9 changed files
with
105 additions
and
45 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,4 @@ | |
netnir will create the default config and folders. | ||
""" | ||
|
||
__version__ = "0.0.10" | ||
__version__ = "0.0.11" |
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,19 @@ | ||
from netnir.helpers.scaffold.command import CommandScaffold | ||
|
||
|
||
class NetConf(CommandScaffold): | ||
"""netconf commands""" | ||
|
||
def run(self): | ||
"""execute netconf commands | ||
:returns: nornir Result object | ||
""" | ||
from netnir.plugins.netconf import netconf_get | ||
from nornir.plugins.functions.text import print_result | ||
|
||
self.nr = self._inventory() | ||
results = self.nr.run(task=netconf_get, name="NETCONF GET CONFIG AND STATE") | ||
print_result(results) | ||
|
||
return results |
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,49 @@ | ||
""" netnir command scaffolding """ | ||
|
||
|
||
class CommandScaffold: | ||
""" scaffold class """ | ||
|
||
def __init__(self, args): | ||
"""initialize the class | ||
:params args: type object | ||
""" | ||
from netnir.constants import NR | ||
|
||
self.args = args | ||
self.nr = NR | ||
|
||
@staticmethod | ||
def parser(parser): | ||
"""command parser function | ||
:params parser: type object | ||
""" | ||
from netnir.helpers.common.args import filter_host, filter_hosts, filter_group | ||
|
||
filter_host(parser) | ||
filter_hosts(parser) | ||
filter_group(parser) | ||
|
||
def run(self): | ||
"""things to do""" | ||
return "things to do" | ||
|
||
def _inventory(self): | ||
"""filter inventory | ||
:returns: filtered nornir inventory object | ||
""" | ||
from netnir.helpers import inventory_filter, filter_type | ||
|
||
devices_filter = filter_type( | ||
host=self.args.host, filter=self.args.filter, group=self.args.group | ||
) | ||
self.nr = inventory_filter( | ||
nr=self.nr, | ||
device_filter=devices_filter["data"], | ||
type=devices_filter["type"], | ||
) | ||
|
||
return self.nr |
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,14 @@ | ||
from nornir.core.task import Task, Result | ||
|
||
|
||
def netconf_get(task: Task) -> Result: | ||
"""nornir netconf get task | ||
:params task: type object | ||
""" | ||
manager = task.host.get_connection( | ||
connection="netconf", configuration=task.nornir.config | ||
) | ||
result = manager.get() | ||
|
||
return Result(result=result, host=task.host) |
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