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


Python ConnectHandler.config_mode方法代码示例

本文整理汇总了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
开发者ID:ssherman68,项目名称:PyNetAutoClass,代码行数:9,代码来源:4-8.py

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

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

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

示例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)
开发者ID:swackhap,项目名称:pynet_python_class,代码行数:36,代码来源:netmiko_test1.py

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

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

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

示例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)
开发者ID:HassanHbar,项目名称:pynet_ansible,代码行数:11,代码来源:exercice5.py

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

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

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

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

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

示例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
开发者ID:dprzybyla,项目名称:python-ansible,代码行数:30,代码来源:netmiko_logging_buffer.py


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