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


Python ConnectHandler.find_prompt方法代码示例

本文整理汇总了Python中netmiko.ConnectHandler.find_prompt方法的典型用法代码示例。如果您正苦于以下问题:Python ConnectHandler.find_prompt方法的具体用法?Python ConnectHandler.find_prompt怎么用?Python ConnectHandler.find_prompt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在netmiko.ConnectHandler的用法示例。


在下文中一共展示了ConnectHandler.find_prompt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from netmiko import ConnectHandler [as 别名]
# 或者: from netmiko.ConnectHandler import find_prompt [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

示例2: setup_module

# 需要导入模块: from netmiko import ConnectHandler [as 别名]
# 或者: from netmiko.ConnectHandler import find_prompt [as 别名]
def setup_module(module):

    module.EXPECTED_RESPONSES = {
        'base_prompt' : 'openstack-rb5',
        'config_mode'   : '(config)',
    }

    net_connect = ConnectHandler(**brocade_vdx)

    # Enter enable mode
    module.prompt_initial = net_connect.find_prompt()
    net_connect.enable()
    module.enable_prompt = net_connect.find_prompt()

    # Send a set of config commands
    module.config_mode = net_connect.config_mode()
    config_commands = ['logging raslog console WARNING', 'interface vlan 20', 'banner motd test_message']
    net_connect.send_config_set(config_commands)

    # Exit config mode
    module.exit_config_mode = net_connect.exit_config_mode()

    # Verify config changes
    module.config_commands_output = net_connect.send_command('show vlan brief')

    net_connect.disconnect()
开发者ID:GGabriele,项目名称:netmiko,代码行数:28,代码来源:test_brocade_vdx_enable.py

示例3: show_version

# 需要导入模块: from netmiko import ConnectHandler [as 别名]
# 或者: from netmiko.ConnectHandler import find_prompt [as 别名]
def show_version(current_operator, current_device):

    command = "show version"
    net_connect = ConnectHandler(
            device_type=device_type,
            ip=current_device.ip,
            username=current_operator.username,
            password=current_operator.password
    )

    net_connect.find_prompt()

    output = net_connect.send_command(command)
    print output
开发者ID:aadamu,项目名称:SwitchConfigurator,代码行数:16,代码来源:ios_commands.py

示例4: show_ip_int_br

# 需要导入模块: from netmiko import ConnectHandler [as 别名]
# 或者: from netmiko.ConnectHandler import find_prompt [as 别名]
def show_ip_int_br(current_operator, current_device):

    command = "show ip interface brief"
    net_connect = ConnectHandler(
            device_type=device_type,
            ip=current_device.ip,
            username=current_operator.username,
            password=current_operator.password
    )

    net_connect.find_prompt()

    output = net_connect.send_command(command)
    print output
开发者ID:aadamu,项目名称:SwitchConfigurator,代码行数:16,代码来源:ios_commands.py

示例5: setup_module

# 需要导入模块: from netmiko import ConnectHandler [as 别名]
# 或者: from netmiko.ConnectHandler import find_prompt [as 别名]
def setup_module(module):

    module.EXPECTED_RESPONSES = {
        'enable_prompt'   : 'n7k1#',
        'base_prompt'   : 'n7k1',
        'interface_ip'  : '10.3.3.245',
        'config_mode'   : '(config)'
    }


    show_ver_command = 'show version'
    module.basic_command = 'show ip int brief'

    net_connect = ConnectHandler(**cisco_nxos)
    module.show_version = net_connect.send_command(show_ver_command)
    module.show_ip = net_connect.send_command(module.basic_command)

    net_connect.enable()
    module.enable_prompt = net_connect.find_prompt()

    module.config_mode = net_connect.config_mode()

    config_commands = ['logging monitor 3', 'logging monitor 7', 'no logging console']
    net_connect.send_config_set(config_commands)

    module.exit_config_mode = net_connect.exit_config_mode()

    module.config_commands_output = net_connect.send_command("show run | inc 'logging monitor'")

    net_connect.disconnect()
开发者ID:jayceechou,项目名称:netmiko,代码行数:32,代码来源:test_cisco_nxos_enable.py

示例6: main

# 需要导入模块: from netmiko import ConnectHandler [as 别名]
# 或者: from netmiko.ConnectHandler import find_prompt [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

示例7: main

# 需要导入模块: from netmiko import ConnectHandler [as 别名]
# 或者: from netmiko.ConnectHandler import find_prompt [as 别名]
def main():

    router1 = {
        'device_type': 'cisco_ios',
        'ip': '10.9.0.67',
        'username': 'myuser',
        'password': 'mypass'
    }

    router2 = {
        'device_type': 'cisco_ios',
        'ip': '10.63.176.57',
        'username': 'myuser',
        'password': 'mypass'
    }

    routers = [router1, router2]

    for router in routers:
        # Connect to device
        device_conn = ConnectHandler(**router)

        # Change config from file
        device_conn.send_config_from_file(config_file='config_commands.txt')

        # Validate changes
        print ">>> " + device_conn.find_prompt() + " <<<"
        #output = device_conn.send_command("show run | in logging", delay_factor=.5)
        output = device_conn.send_command_expect("show run | in logging")
        print output + "\n\n"

        # Close connection
        device_conn.disconnect()
开发者ID:ande0581,项目名称:pynet,代码行数:35,代码来源:class4_ex8.py

示例8: main

# 需要导入模块: from netmiko import ConnectHandler [as 别名]
# 或者: from netmiko.ConnectHandler import find_prompt [as 别名]
def main():

    try:
        hostname = raw_input("Enter remote host to test: ")
    except NameError:
        hostname = input("Enter remote host to test: ")

    home_dir = path.expanduser("~")
    key_file = "{}/.ssh/cisco_rsa".format(home_dir)

    cisco_test = {
        "ip": hostname,
        "username": "testuser2",
        "device_type": "cisco_ios",
        "use_keys": True,
        "key_file": key_file,
        "verbose": False,
    }

    net_connect = ConnectHandler(**cisco_test)
    print()
    print("Checking prompt: ")
    print(net_connect.find_prompt())
    print()
    print("Testing show ip int brief: ")
    output = net_connect.send_command("show ip int brief")
    print(output)
    print()
开发者ID:Rosiak,项目名称:netmiko,代码行数:30,代码来源:test_cisco_w_key.py

示例9: main

# 需要导入模块: from netmiko import ConnectHandler [as 别名]
# 或者: from netmiko.ConnectHandler import find_prompt [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

示例10: show_version

# 需要导入模块: from netmiko import ConnectHandler [as 别名]
# 或者: from netmiko.ConnectHandler import find_prompt [as 别名]
def show_version(current_device):

    device_ip = socket.gethostbyname(current_device)
    command = "show version"
    net_connect = ConnectHandler(
            device_type=device_type,
            ip=device_ip,
            username=current_operator.username,
            password=current_operator.password
    )

    net_connect.find_prompt()
    net_connect.enable()
    output = net_connect.send_command(command)

    return (output)
开发者ID:aadamu,项目名称:network-tools,代码行数:18,代码来源:cisco_status.py

示例11: main

# 需要导入模块: from netmiko import ConnectHandler [as 别名]
# 或者: from netmiko.ConnectHandler import find_prompt [as 别名]
def main():
    """Exercises using Netmiko"""
    rtr1_pass = getpass("Enter router password: ")
    sw1_pass = getpass("Enter switch password: ")
    pynet_rtr1 = {
        'device_type': 'cisco_ios',
        'ip':   '184.105.247.70',
        'username': 'pyclass',
        'password': rtr1_pass,
    }

    pynet_sw1 = {
        'device_type': 'arista_eos',
        'ip':   '184.105.247.72',
        'username': 'admin1',
        'password': sw1_pass,
    }

    for a_device in (pynet_rtr1, pynet_sw1):
        net_connect = ConnectHandler(**a_device)
        print "Current Prompt: " + net_connect.find_prompt()

        show_arp = net_connect.send_command("show arp")
        print
        print '#' * 80
        print show_arp
        print '#' * 80
        print

        show_run = net_connect.send_command("show run")
        filename = net_connect.base_prompt + ".txt"
        print "Save show run output: {}\n".format(filename)
        save_file(filename, show_run)
开发者ID:andylinjefferson,项目名称:pynet_ons,代码行数:35,代码来源:ex25_netmiko.py

示例12: main

# 需要导入模块: from netmiko import ConnectHandler [as 别名]
# 或者: from netmiko.ConnectHandler import find_prompt [as 别名]
def main():
    """Exercises using Netmiko"""
    # 99saturday
    sw1_pass = getpass("Enter switch password: ")

    pynet_sw1 = {
        'device_type': 'arista_eos',
        'ip':   '184.105.247.72',
        'username': 'admin1',
        'password': sw1_pass,
    }

    cfg_commands = [
        'vlan 901',
        'name red',
    ]

    net_connect = ConnectHandler(**pynet_sw1)
    print "Current Prompt: " + net_connect.find_prompt()

    print "\nConfiguring VLAN"
    print "#" * 80
    output = net_connect.send_config_set(cfg_commands)
    print output
    print "#" * 80
    print

    print "\nConfiguring VLAN from file"
    print "#" * 80
    output = net_connect.send_config_from_file("vlan_cfg.txt")
    print output
    print "#" * 80
    print
开发者ID:squeezer,项目名称:pynet_test,代码行数:35,代码来源:my_test26.py

示例13: connect_net_device

# 需要导入模块: from netmiko import ConnectHandler [as 别名]
# 或者: from netmiko.ConnectHandler import find_prompt [as 别名]
def connect_net_device(**kwarg):
    net_connect = ConnectHandler(**kwarg)
    print "Current prompt: {}".format(net_connect.find_prompt())
    show_run = net_connect.send_command("sh run")
    print "sh run output: \n\n{}".format(show_run)
    filename = net_connect.base_prompt + ".txt"
    save_file (filename , show_run)
开发者ID:aniketpuranik,项目名称:pynet_test,代码行数:9,代码来源:ex25_Netmiko.py

示例14: setup_module

# 需要导入模块: from netmiko import ConnectHandler [as 别名]
# 或者: from netmiko.ConnectHandler import find_prompt [as 别名]
def setup_module(module):

    module.EXPECTED_RESPONSES = {
        'enable_prompt' : 'xe-test-rtr#',
        'base_prompt'   : 'xe-test-rtr',
        'interface_ip'  : '172.30.0.167',
        'config_mode'   : '(config)',
    }
    
    show_ver_command = 'show version'
    module.basic_command = 'show ip int brief'
    
    net_connect = ConnectHandler(**cisco_xe)
    module.show_version = net_connect.send_command(show_ver_command)
    module.show_ip = net_connect.send_command(module.basic_command)

    net_connect.enable()
    module.enable_prompt = net_connect.find_prompt()

    module.config_mode = net_connect.config_mode()

    config_commands = ['logging buffered 20000', 'logging buffered 20010', 'no logging console']
    net_connect.send_config_set(config_commands)

    module.exit_config_mode = net_connect.exit_config_mode()

    module.config_commands_output = net_connect.send_command('show run | inc logging buffer')

    net_connect.disconnect()
开发者ID:GGabriele,项目名称:netmiko,代码行数:31,代码来源:test_cisco_xe_enable.py

示例15: main

# 需要导入模块: from netmiko import ConnectHandler [as 别名]
# 或者: from netmiko.ConnectHandler import find_prompt [as 别名]
def main():
    print 'Username:',
    usern = raw_input()
    passwd = getpass()

    for i in range(len(DEVICES)):
        try:
            net_dev = {
                        'device_type':DEV_TYPE[i],
                        'ip':DEVICES[i],
                        'username':usern,
                        'password':passwd
                    }

            print '>>>>>>>>>>>>> DEVICE: {} <<<<<<<<<<<<<<'.format(DEVICES[i])
            # Initiating netmiko connection
            net_connect = ConnectHandler(**net_dev)
            resp = net_connect.find_prompt()
            print resp

            # Entering config mode, deploying commands and exiting config mode
            resp = net_connect.send_config_set(CONF_COMMANDS)
            print resp

        except Exception as e:
            print e
            exit(0)
开发者ID:ahsec,项目名称:PyNet_Class_Exercises,代码行数:29,代码来源:exercise_07.py


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