-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Updated IOSXE base config to include netconf setup for consistency w/ scrapli_netconf - Removed "pipes" authentication for system ssh -- this is mostly an internal change that simplifies the way that system transport authenticates. We lose the ability to very easily read out of stderr what is going on so even if we auth with a key now we have to "confirm" that we are authenticated, but this removes a fair bit of code and unifies things as well as allows for the next line item... - Added support for `auth_private_key_passphrase` to system transport -- allows for entering ssh key passphrase to decrypt ssh keys - Added an example on how to deal with "weird" things like banners and macros -- these types of things change how the ssh channel works in that they are pseudo "interactive" -- meaning the prompt is modified/removed so scrapli can't ever "know" when a command is done inserting. It would be possible to support these types of config items more "natively" but doing so would lose some of the smarts about how scrapli enters/confirms inputs sent, so for now (and probably for forever) these will need to be configured in a "special" fashion - Updated IOSXE for functional tests to use 16.12.03 -- this includes updates to the base config/expected configs... AFAIK there is some better netconf/restconf support in this version which may be handy for tests for scrapli-netconf - Update channel/drivers to never decode bytes -- this now only happens in the response object; primary motivation for this is to not have to decode/re-encode in general, and in scrapli-netconf in particular
- Loading branch information
1 parent
0f06079
commit f7fefeb
Showing
39 changed files
with
662 additions
and
483 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
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,66 @@ | ||
"""examples.banners_macros_etc.iosxe_banners_macros_etc""" | ||
from scrapli.driver.core import IOSXEDriver | ||
|
||
MY_DEVICE = { | ||
"host": "172.18.0.11", | ||
"auth_username": "vrnetlab", | ||
"auth_password": "VR-netlab9", | ||
"auth_strict_key": False, | ||
} | ||
|
||
|
||
def main(): | ||
"""Simple example of configuring banners and macros on an IOSXEDevice""" | ||
conn = IOSXEDriver(**MY_DEVICE) | ||
conn.open() | ||
|
||
my_banner = """This is my router, get outa here! | ||
I'm serious, you can't be in here! | ||
Go away! | ||
""" | ||
|
||
# the overall pattern/process is that we must use send_interactive as this is an "interactive" | ||
# style command/input because the prompt changes and relies on a human to understand what is | ||
# going on. this whole operation is completed by the `send_interactive` method, but we break it | ||
# up here so its easier to understand what is going on. first we have a "start" point -- where | ||
# we send the actual command that kicks things off -- in this case "banner motd ^" -- we need to | ||
# tell scrapli what to expect so it knows there is success; "Enter TEXT message." in this | ||
# exmaple. We set the "hidden input" to `True` because this forces scrapli to not try to read | ||
# the inputs back off the channel -- we can't read the inputs because they are interrupted by | ||
# the prompt of enter your text blah blah. | ||
banner_start = ("banner motd ^", "Enter TEXT message.", True) | ||
# next we can simply create an "event" for each line of the banner we want to send, we dont | ||
# need to set the "hidden_prompt" value to `True` here because scrapli can simply read the | ||
# inputs off the channel normally as there is no prompts/inputs from the device | ||
banner_lines = [(line, "\n") for line in my_banner.splitlines()] | ||
# then we need to "end" our interactive event and ensure scrapli knows how to find the prompt | ||
# that we'll be left at at the end of this operation. note that you could just capture the | ||
# config mode prompt via `get_prompt` if you wanted and pass that value here, but we'll set it | ||
# manually for this example | ||
banner_end = ("^", "csr1000v(config)#", True) | ||
# finally we need to add all these sections up into a single list of tuples so that we can pass | ||
# this to the `send_interactive` method -- note the `*` in front of the `banner_lines` argument | ||
# we "unpack" the tuples from the list into this final list object | ||
banner_events = [banner_start, *banner_lines, banner_end] | ||
result = conn.send_interactive(interact_events=banner_events, privilege_level="configuration") | ||
print(result.result) | ||
|
||
# Note: csr1000v (at least the version scrapli is regularly tested with does not support macros | ||
# the following has been tested and works on a 3560 switch | ||
my_macro = """# description | ||
desc this_is_a_neat_macro | ||
# do a thing | ||
power inline never | ||
""" | ||
|
||
macro_start = ("macro name my_macro", "Enter macro commands one per line.", True) | ||
macro_lines = [(line, "\n", True) for line in my_macro.splitlines()] | ||
macro_end = ("@", "csr1000v(config)#", True) | ||
macro_events = [macro_start, *macro_lines, macro_end] | ||
result = conn.send_interactive(interact_events=macro_events, privilege_level="configuration") | ||
print(result.result) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
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
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
Oops, something went wrong.