本文整理汇总了Python中netmiko.ConnectHandler.check_config_mode方法的典型用法代码示例。如果您正苦于以下问题:Python ConnectHandler.check_config_mode方法的具体用法?Python ConnectHandler.check_config_mode怎么用?Python ConnectHandler.check_config_mode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类netmiko.ConnectHandler
的用法示例。
在下文中一共展示了ConnectHandler.check_config_mode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from netmiko import ConnectHandler [as 别名]
# 或者: from netmiko.ConnectHandler import check_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)
示例2: main
# 需要导入模块: from netmiko import ConnectHandler [as 别名]
# 或者: from netmiko.ConnectHandler import check_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!"
示例3: main
# 需要导入模块: from netmiko import ConnectHandler [as 别名]
# 或者: from netmiko.ConnectHandler import check_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 check_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"
示例5: main
# 需要导入模块: from netmiko import ConnectHandler [as 别名]
# 或者: from netmiko.ConnectHandler import check_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"
示例6: main
# 需要导入模块: from netmiko import ConnectHandler [as 别名]
# 或者: from netmiko.ConnectHandler import check_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"
示例7: main
# 需要导入模块: from netmiko import ConnectHandler [as 别名]
# 或者: from netmiko.ConnectHandler import check_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"
示例8: main
# 需要导入模块: from netmiko import ConnectHandler [as 别名]
# 或者: from netmiko.ConnectHandler import check_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
示例9: main
# 需要导入模块: from netmiko import ConnectHandler [as 别名]
# 或者: from netmiko.ConnectHandler import check_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())
示例10: main
# 需要导入模块: from netmiko import ConnectHandler [as 别名]
# 或者: from netmiko.ConnectHandler import check_config_mode [as 别名]
def main():
my_device = {
'device_type': 'cisco_ios',
'ip': '10.40.0.1',
'username': 'myuser',
'password': 'mypass'
}
# Connect to device
device_conn = ConnectHandler(**my_device)
# Enter Config mode
device_conn.config_mode()
# Verify current mode
print device_conn.check_config_mode()
# Print the current prompt
print device_conn.find_prompt()
# Close connection
device_conn.disconnect()
示例11: main
# 需要导入模块: from netmiko import ConnectHandler [as 别名]
# 或者: from netmiko.ConnectHandler import check_config_mode [as 别名]
def main():
pynet2 = {
'device_type': 'cisco_ios',
'ip' : '50.76.53.27',
'username' : 'pyclass',
'port' : 8022,
'password' : '88newclass'
}
pynet_rtr2 = ConnectHandler(**pynet2)
pynet_rtr2.config_mode()
if pynet_rtr2.check_config_mode():
print "We're in config mode"
pynet_rtr2.send_command("logging buffered 33333")
else:
print "Nope, We're NOT in config mode"
示例12: main
# 需要导入模块: from netmiko import ConnectHandler [as 别名]
# 或者: from netmiko.ConnectHandler import check_config_mode [as 别名]
def main():
'''
Connects to router and switches to config mode
'''
pynet_rtr2 = ConnectHandler(**pynet2)
pynet_rtr2.enable()
pynet_rtr2.config_mode()
'''
Checks to see if you are in enable mode and prints results to screen
'''
if pynet_rtr2.check_config_mode() is True:
output = pynet_rtr2.find_prompt()
print output
else:
print 'You are NOT in config mode'
示例13: main
# 需要导入模块: from netmiko import ConnectHandler [as 别名]
# 或者: from netmiko.ConnectHandler import check_config_mode [as 别名]
def main():
'''
Using Netmiko enter into configuration mode on a network device.
Verify that you are currently in configuration mode.
'''
password = getpass()
for a_dict in (pynet1, pynet2, juniper_srx):
a_dict['password'] = password
net_connect2 = ConnectHandler(**pynet2)
net_connect2.config_mode()
print "\n>>>>"
print "Checking pynet-rtr2 is in configuration mode."
print "Config mode check: {}".format(net_connect2.check_config_mode())
print "Current prompt: {}".format(net_connect2.find_prompt())
print ">>>>\n"
示例14: main
# 需要导入模块: from netmiko import ConnectHandler [as 别名]
# 或者: from netmiko.ConnectHandler import check_config_mode [as 别名]
def main():
pynet2 = {
'device_type': 'cisco_ios',
'ip' : '50.76.53.27',
'username' : 'pyclass',
'port' : 8022,
'password' : '88newclass'
}
pynet_rtr2 = ConnectHandler(**pynet2)
pynet_rtr2.config_mode()
if pynet_rtr2.check_config_mode():
print "We're in config mode"
else:
print "Nope, We're NOT in config mode"
print pynet_rtr2.find_prompt()
pynet_rtr2.exit_config_mode()
print pynet_rtr2.find_prompt()
示例15: main
# 需要导入模块: from netmiko import ConnectHandler [as 别名]
# 或者: from netmiko.ConnectHandler import check_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
rtr2.exit_config_mode()