本文整理汇总了Python中netmiko.Netmiko.send_config_set方法的典型用法代码示例。如果您正苦于以下问题:Python Netmiko.send_config_set方法的具体用法?Python Netmiko.send_config_set怎么用?Python Netmiko.send_config_set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类netmiko.Netmiko
的用法示例。
在下文中一共展示了Netmiko.send_config_set方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getpass
# 需要导入模块: from netmiko import Netmiko [as 别名]
# 或者: from netmiko.Netmiko import send_config_set [as 别名]
#!/usr/bin/env python
from netmiko import Netmiko
from getpass import getpass
device = {
'host': 'srx1.twb-tech.com',
'username': 'pyclass',
'password': getpass(),
'device_type': 'juniper_junos',
}
commands = [
'set system syslog archive size 240k files 3 '
]
net_connect = Netmiko(**device)
print()
print(net_connect.find_prompt())
output = net_connect.send_config_set(commands, exit_config_mode=False)
output += net_connect.commit(and_quit=True)
print(output)
print()
net_connect.disconnect()
示例2: getpass
# 需要导入模块: from netmiko import Netmiko [as 别名]
# 或者: from netmiko.Netmiko import send_config_set [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)
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()
示例3: input
# 需要导入模块: from netmiko import Netmiko [as 别名]
# 或者: from netmiko.Netmiko import send_config_set [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)