-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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 #737 from ktbyers/develop
Netmiko release 2.1.0
- Loading branch information
Showing
38 changed files
with
932 additions
and
582 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,21 @@ | ||
#!/usr/bin/env python | ||
from __future__ import print_function, unicode_literals | ||
|
||
# Netmiko is the same as ConnectHandler | ||
from netmiko import Netmiko | ||
from getpass import getpass | ||
|
||
my_device = { | ||
'host': "host.domain.com", | ||
'username': 'pyclass', | ||
'password': getpass(), | ||
'device_type': 'cisco_ios', | ||
# Increase (essentially) all sleeps by a factor of 2 | ||
'global_delay_factor': 2, | ||
} | ||
|
||
net_connect = Netmiko(**my_device) | ||
# Increase the sleeps for just send_command by a factor of 2 | ||
output = net_connect.send_command("show ip int brief", delay_factor=2) | ||
print(output) | ||
net_connect.disconnect() |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,2 @@ | ||
logging buffered 8000 | ||
logging console |
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,22 @@ | ||
#!/usr/bin/env python | ||
from __future__ import print_function, unicode_literals | ||
|
||
# Netmiko is the same as ConnectHandler | ||
from netmiko import Netmiko | ||
from getpass import getpass | ||
|
||
my_device = { | ||
'host': "host.domain.com", | ||
'username': 'pyclass', | ||
'password': getpass(), | ||
'device_type': 'cisco_ios', | ||
} | ||
|
||
net_connect = Netmiko(**my_device) | ||
cfg_commands = ['logging buffered 10000', 'no logging console'] | ||
|
||
# send_config_set() will automatically enter/exit config mode | ||
output = net_connect.send_config_set(cfg_commands) | ||
print(output) | ||
|
||
net_connect.disconnect() |
21 changes: 21 additions & 0 deletions
21
examples/configuration_changes/config_changes_from_file.py
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,21 @@ | ||
#!/usr/bin/env python | ||
from __future__ import print_function, unicode_literals | ||
|
||
# Netmiko is the same as ConnectHandler | ||
from netmiko import Netmiko | ||
from getpass import getpass | ||
|
||
my_device = { | ||
'host': "host.domain.com", | ||
'username': 'pyclass', | ||
'password': getpass(), | ||
'device_type': 'cisco_ios', | ||
} | ||
|
||
net_connect = Netmiko(**my_device) | ||
|
||
# Make configuration changes using an external file | ||
output = net_connect.send_config_from_file("change_file.txt") | ||
print(output) | ||
|
||
net_connect.disconnect() |
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,37 @@ | ||
#!/usr/bin/env python | ||
""" | ||
This example is serial (i.e. no concurrency). Connect to one device, after the other, | ||
after the other. | ||
""" | ||
from __future__ import print_function, unicode_literals | ||
|
||
# Netmiko is the same as ConnectHandler | ||
from netmiko import Netmiko | ||
from getpass import getpass | ||
|
||
password = getpass() | ||
|
||
cisco1 = { | ||
'host': "host1.domain.com", | ||
'username': 'pyclass', | ||
'password': password, | ||
'device_type': 'cisco_ios', | ||
} | ||
|
||
arista1 = { | ||
'host': "host2.domain.com", | ||
'username': 'pyclass', | ||
'password': password, | ||
'device_type': 'arista_eos', | ||
} | ||
|
||
srx1 = { | ||
'host': "host3.domain.com", | ||
'username': 'pyclass', | ||
'password': password, | ||
'device_type': 'juniper_junos', | ||
} | ||
|
||
for device in (cisco1, arista1, srx1): | ||
net_connect = Netmiko(**device) | ||
print(net_connect.find_prompt()) |
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,20 @@ | ||
#!/usr/bin/env python | ||
from __future__ import print_function, unicode_literals | ||
|
||
# Netmiko is the same as ConnectHandler | ||
from netmiko import Netmiko | ||
from getpass import getpass | ||
|
||
my_device = { | ||
'host': "host.domain.com", | ||
'username': 'pyclass', | ||
'password': getpass(), | ||
'device_type': 'cisco_ios', | ||
} | ||
|
||
net_connect = Netmiko(**my_device) | ||
# Ensure in enable mode | ||
net_connect.enable() | ||
print(net_connect.find_prompt()) | ||
|
||
net_connect.disconnect() |
Oops, something went wrong.