本文整理匯總了Python中netmiko.Netmiko.send_config_from_file方法的典型用法代碼示例。如果您正苦於以下問題:Python Netmiko.send_config_from_file方法的具體用法?Python Netmiko.send_config_from_file怎麽用?Python Netmiko.send_config_from_file使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類netmiko.Netmiko
的用法示例。
在下文中一共展示了Netmiko.send_config_from_file方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: getpass
# 需要導入模塊: from netmiko import Netmiko [as 別名]
# 或者: from netmiko.Netmiko import send_config_from_file [as 別名]
#!/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()
示例2: getpass
# 需要導入模塊: from netmiko import Netmiko [as 別名]
# 或者: from netmiko.Netmiko import send_config_from_file [as 別名]
#!/usr/bin/env python
from netmiko import Netmiko
from getpass import getpass
nxos1 = {
'host': 'nxos1.twb-tech.com',
'username': 'pyclass',
'password': getpass(),
'device_type': 'cisco_nxos',
}
cfg_file = 'config_changes.txt'
net_connect = Netmiko(**nxos1)
print()
print(net_connect.find_prompt())
output = net_connect.send_config_from_file(cfg_file)
print(output)
print()
net_connect.save_config()
net_connect.disconnect()
示例3: input
# 需要導入模塊: from netmiko import Netmiko [as 別名]
# 或者: from netmiko.Netmiko import send_config_from_file [as 別名]
except NameError:
host = input("Enter host to connect to: ")
password = getpass()
device = {
'host': host,
'username': 'pyclass',
'password': password,
'device_type': 'cisco_ios',
}
net_connect = Netmiko(**device)
# Use send_config_set() to make config change
config = ['logging console', 'logging buffer 15000']
output = net_connect.send_config_set(config)
output_printer(output)
# Use send_config_from_file() to make config change
output = net_connect.send_config_from_file('config.txt')
output_printer(output)
message = "Verifying config change\n"
output = net_connect.send_command("show run | inc logging")
if '8000' in output:
message += "Logging buffer is size 8000"
else:
message += "Logging buffer size is not correct!"
output_printer(message)