New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add banner support to system api #75
Changes from 4 commits
8cbdfc5
3b555a4
2b884ec
36a3be5
4ef7c33
428f094
ff70c48
00c6912
2056e22
b8dcc75
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -521,6 +521,43 @@ def config(self, commands): | |
# pop the configure command output off the stack | ||
response.pop(0) | ||
|
||
return response | ||
def config_with_input(self, commands): | ||
"""Configures the node with a command that would normally take stdin | ||
|
||
This method will send a configuration change to the node for commands | ||
to use std input. Banners are an example of such a configuration. | ||
It will take a dictionary where the key is the command and the value | ||
would be entered as if it where coming from standard input | ||
|
||
Args: | ||
commands(dict or list): the dict should have a key of command | ||
and value. Where command is configuration item to change with | ||
string set for the key value. | ||
These commands will be constructed into the | ||
correct form to be sent to node to make the desired config | ||
changes. The function will preprend the required commands | ||
to put the session in config mode | ||
|
||
Returns: | ||
The config method will return a list of dictionaries with | ||
the ouptut from each command | ||
""" | ||
command_list = [] | ||
command_list.append('configure terminal') | ||
if isinstance(commands, list): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you can make the change to the config method by checking for the value key for each command. If the value key is defined then you would add the input key when building the command list. Note that you can leverage the make_iterable call in the config method. |
||
for com in commands: | ||
command_list.append({'cmd': com['command'], 'input': com['value']}) | ||
else: | ||
command_list.append({'cmd': commands['command'], 'input': commands['value']}) | ||
|
||
response = self.run_commands(command_list) | ||
|
||
if self.autorefresh: | ||
self.refresh() | ||
|
||
response.pop(0) | ||
|
||
return response | ||
|
||
def section(self, regex, config='running_config'): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ host: 192.168.1.16 | |
username: eapi | ||
password: password | ||
transport: http | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unnecessary empty line, there shouldn't be any changes to the dut.conf. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks John. Sorry about the oversights here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you need this method anymore.