当前位置: 首页>>代码示例>>Python>>正文


Python ConnectHandler.check_config_mode方法代码示例

本文整理汇总了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)
开发者ID:swackhap,项目名称:pynet_python_class,代码行数:36,代码来源:netmiko_test1.py

示例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!"
开发者ID:thomarite,项目名称:pynetw4,代码行数:29,代码来源:w4-5.py

示例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"
开发者ID:cocoloco69,项目名称:pynet,代码行数:27,代码来源:w4e8.py

示例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"
开发者ID:kadamski-york,项目名称:pynet_testz,代码行数:37,代码来源:c4e5.py

示例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"
开发者ID:ssherman68,项目名称:PyNetAutoClass,代码行数:10,代码来源:4-5.py

示例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"
开发者ID:brianbooher,项目名称:pynet_testz,代码行数:10,代码来源:exercise5_netmiko_config_mode.py

示例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"
开发者ID:brianbooher,项目名称:pynet_testz,代码行数:14,代码来源:exercise7_netmiko_change_logging.py

示例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
开发者ID:ibyt32,项目名称:pynet_test,代码行数:15,代码来源:w4e5_netmiko.py

示例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())
开发者ID:dracode22,项目名称:pynet_class,代码行数:16,代码来源:ex5.py

示例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()
开发者ID:ande0581,项目名称:pynet,代码行数:25,代码来源:class4_ex5.py

示例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"
开发者ID:jvalcke,项目名称:pynet,代码行数:18,代码来源:ex7.py

示例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'
开发者ID:eaboytes,项目名称:pynet_testz,代码行数:18,代码来源:exercise5.py

示例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"
开发者ID:McGuireChris,项目名称:pynet,代码行数:19,代码来源:ex5_netmiko.py

示例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() 
开发者ID:jvalcke,项目名称:pynet,代码行数:20,代码来源:ex5.py

示例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()
开发者ID:cocoloco69,项目名称:pynet,代码行数:20,代码来源:w4e5.py


注:本文中的netmiko.ConnectHandler.check_config_mode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。