本文整理汇总了Python中netmiko.ConnectHandler.config_mode方法的典型用法代码示例。如果您正苦于以下问题:Python ConnectHandler.config_mode方法的具体用法?Python ConnectHandler.config_mode怎么用?Python ConnectHandler.config_mode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类netmiko.ConnectHandler
的用法示例。
在下文中一共展示了ConnectHandler.config_mode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from netmiko import ConnectHandler [as 别名]
# 或者: from netmiko.ConnectHandler import config_mode [as 别名]
def main():
for device in rtr_list:
rtr_conn = ConnectHandler(**device)
prompt = rtr_conn.find_prompt()
rtr_conn.config_mode()
output = rtr_conn.send_config_from_file(config_file='4_8_cfg.txt')
print output
示例2: main
# 需要导入模块: from netmiko import ConnectHandler [as 别名]
# 或者: from netmiko.ConnectHandler import config_mode [as 别名]
def main():
username = 'pyclass'
password = '88newclass'
pynet1 = {
'device_type': 'cisco_ios',
'ip': '50.76.53.27',
'username': username,
'password': password,
'port': 22,
}
pynet2 = {
'device_type': 'cisco_ios',
'ip': '50.76.53.27',
'username': username,
'password': password,
'port': 8022,
}
juniper_srx = {
'device_type': 'juniper',
'ip': '50.76.53.27',
'username': username,
'password': password,
'secret': '',
'port': 9822,
}
pynet_rtr2 = ConnectHandler( **pynet2 )
pynet_rtr2.config_mode()
if pynet_rtr2.check_config_mode() :
print "We are in config mode for pynet rtr2"
else:
print "No config mode for pynet rtr2"
示例3: main
# 需要导入模块: from netmiko import ConnectHandler [as 别名]
# 或者: from netmiko.ConnectHandler import config_mode [as 别名]
def main():
password = getpass()
py_router_2 = {
'device_type':'cisco_ios',
'ip':'50.76.53.27',
'username':'pyclass',
'password':password,
'port':8022,
}
rtr2 = ConnectHandler(**py_router_2)
rtr2.config_mode()
output = rtr2.check_config_mode()
print "RTR Config mode is %s" % output
if (output is True):
#config_command = ['loggin buffered 5555']
#output = rtr2.send_config_set(config_command)
output = rtr2.send_config_from_file(config_file='config_file.txt')
print "Changes send to router.\n %s" % output
rtr2.exit_config_mode()
else:
print "Could not get to config mode.\n"
示例4: main
# 需要导入模块: from netmiko import ConnectHandler [as 别名]
# 或者: from netmiko.ConnectHandler import config_mode [as 别名]
def main():
ip_addr = '50.76.53.27'
port_rtr1 = 22
port_rtr2 = 8022
username = 'pyclass'
password = '88newclass'
#password = getpass()
pynet1 = {
'device_type': 'cisco_ios',
'ip': ip_addr,
'username': username,
'password': password,
'port': port_rtr1,
}
pynet_rtr1 = ConnectHandler(**pynet1)
pynet_rtr1.find_prompt()
print "we are getting into config mode"
pynet_rtr1.config_mode()
if pynet_rtr1.check_config_mode():
print "yes, we are in config mode"
else:
print "sometthing is wrong, we are not in config mode!"
示例5: main
# 需要导入模块: from netmiko import ConnectHandler [as 别名]
# 或者: from netmiko.ConnectHandler import config_mode [as 别名]
def main():
#password = getpass()
password = '88newclass'
# Define libraries for devices we will connect to
pynet1 = {
'device_type': 'cisco_ios',
'ip': '50.76.53.27',
'username': 'pyclass',
'password': password,
'port': 22,
}
pynet2 = {
'device_type': 'cisco_ios',
'ip': '50.76.53.27',
'username': 'pyclass',
'password': password,
'port': 8022,
}
srx = {
'device_type': 'juniper',
'ip': '50.76.53.27',
'username': 'pyclass',
'password': password,
'port': 9822,
}
pynet_rtr2 = ConnectHandler(**pynet2)
pynet_rtr2.config_mode()
outp = pynet_rtr2.find_prompt()
print outp
outp2 = pynet_rtr2.check_config_mode()
print 'Config mode status is ' + str(outp2)
示例6: main
# 需要导入模块: from netmiko import ConnectHandler [as 别名]
# 或者: from netmiko.ConnectHandler import config_mode [as 别名]
def main():
rlist = [pynet1, pynet2]
for router in rlist:
rtr = ConnectHandler(**router)
rtr.config_mode()
rtr.send_config_from_file(config_file='configfile.txt')
rtr.exit_config_mode()
示例7: main
# 需要导入模块: from netmiko import ConnectHandler [as 别名]
# 或者: from netmiko.ConnectHandler import config_mode [as 别名]
def main():
password = getpass
pynet_rtr2 = ConnectHandler(**pynet2)
pynet_rtr2.config_mode()
if pynet_rtr2.check_config_mode():
print "You are in config mode.\n"
else:
print "Config mode failed.\n"
示例8: main
# 需要导入模块: from netmiko import ConnectHandler [as 别名]
# 或者: from netmiko.ConnectHandler import config_mode [as 别名]
def main():
'''Main function, opens connection, enters config mode and verifies'''
pynet_rtr1 = ConnectHandler(**device_list.RTR1)
pynet_rtr1.config_mode()
if pynet_rtr1.check_config_mode():
print "We are in Config mode"
else:
print "We are NOT in Config mode"
示例9: main
# 需要导入模块: from netmiko import ConnectHandler [as 别名]
# 或者: from netmiko.ConnectHandler import config_mode [as 别名]
def main():
"""
se Netmiko to enter into configuration mode on pynet-rtr2.
Also use Netmiko to verify your state
(i.e. that you are currently in configuration mode).
"""
pynet_rtr1 = ConnectHandler(**PYNET1)
pynet_rtr1.config_mode()
router_mode(pynet_rtr1)
示例10: main
# 需要导入模块: from netmiko import ConnectHandler [as 别名]
# 或者: from netmiko.ConnectHandler import config_mode [as 别名]
def main():
'''Main function, opens connection, enters config mode, changes logging
and verifies'''
pynet_rtr2 = ConnectHandler(**RTR2)
pynet_rtr2.config_mode()
if pynet_rtr2.check_config_mode():
pynet_rtr2.send_command("logging buffered 16384")
pynet_rtr2.exit_config_mode()
output = pynet_rtr2.send_command("show run | include logging buff")
print output
else:
print "We are NOT in Config mode"
示例11: main
# 需要导入模块: from netmiko import ConnectHandler [as 别名]
# 或者: from netmiko.ConnectHandler import config_mode [as 别名]
def main():
'''
Use Netmiko to change the logging buffer size (logging buffered <size>)
on pynet-rtr2.
'''
pynet_rtr2 = ConnectHandler(**pynet2)
pynet_rtr2.config_mode()
config_commands = ['logging buffered 102400']
output = pynet_rtr2.send_config_set(config_commands)
print
print output
print
示例12: main
# 需要导入模块: from netmiko import ConnectHandler [as 别名]
# 或者: from netmiko.ConnectHandler import config_mode [as 别名]
def main():
'''
Use Netmiko to enter into configuration mode on pynet-rtr2. Also use Netmiko
to verify your state (i.e. that you are currently in configuration mode).
'''
pynet_rtr2 = ConnectHandler(**pynet2)
pynet_rtr2.config_mode()
output = pynet_rtr2.check_config_mode()
print
print 'Checking to see if we are in config mode:'
print output
print
示例13: main
# 需要导入模块: from netmiko import ConnectHandler [as 别名]
# 或者: from netmiko.ConnectHandler import config_mode [as 别名]
def main():
'''
Logs into each router and executes commands cmd and ver
'''
print '=' *80
ssh_conn = ConnectHandler(**device)
ssh_conn.config_mode()
ssh_conn.send_command(cmd)
output = ssh_conn.send_command(ver)
prompt = ssh_conn.find_prompt()
print '\n %s from %s \n %s' %(cmd, prompt, output)
print
print '=' *80
示例14: main
# 需要导入模块: from netmiko import ConnectHandler [as 别名]
# 或者: from netmiko.ConnectHandler import config_mode [as 别名]
def main():
password = getpass()
for a_dict in (pynet1, pynet2, juniper_srx):
a_dict['password'] = password
net_connect2 = ConnectHandler(**pynet2)
net_connect2.config_mode()
print "Config mode:{}".format(net_connect2.check_config_mode())
print "Current prompt: {}".format(net_connect2.find_prompt())
示例15: main
# 需要导入模块: from netmiko import ConnectHandler [as 别名]
# 或者: from netmiko.ConnectHandler import config_mode [as 别名]
def main():
# Definition of rtr2.
rtr2 = {
'device_type': 'cisco_ios',
'ip': '50.76.53.27',
'username': 'pyclass',
'password': '88newclass',
'port': 8022,
}
# Log into router.
net_connect = ConnectHandler(**rtr2)
# Check current logging buffer size.
output = net_connect.send_command("show run | inc buffered")
print
print "Initial logging buffer size: " + output
# Enter config mode, change logging buffer size, exit config mode.
output = net_connect.config_mode()
output = net_connect.send_command("logging buffer 64000")
output = net_connect.exit_config_mode()
# Check logging buffer size again.
output = net_connect.send_command("show run | inc buffered")
print "Final logging buffer size: " + output
print