當前位置: 首頁>>代碼示例>>Python>>正文


Python Netmiko.send_command方法代碼示例

本文整理匯總了Python中netmiko.Netmiko.send_command方法的典型用法代碼示例。如果您正苦於以下問題:Python Netmiko.send_command方法的具體用法?Python Netmiko.send_command怎麽用?Python Netmiko.send_command使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在netmiko.Netmiko的用法示例。


在下文中一共展示了Netmiko.send_command方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: getpass

# 需要導入模塊: from netmiko import Netmiko [as 別名]
# 或者: from netmiko.Netmiko import send_command [as 別名]
#!/usr/bin/env python
from netmiko import Netmiko
from getpass import getpass

cisco1 = {
    "host": "cisco1.twb-tech.com",
    "username": "pyclass",
    "password": getpass(),
    "device_type": "cisco_ios",
}

net_connect = Netmiko(**cisco1)
command = "show ip int brief"

print()
print(net_connect.find_prompt())
output = net_connect.send_command(command, use_textfsm=True)
net_connect.disconnect()
print(output)
print()
開發者ID:ktbyers,項目名稱:netmiko,代碼行數:22,代碼來源:send_command_textfsm.py

示例2: getpass

# 需要導入模塊: from netmiko import Netmiko [as 別名]
# 或者: from netmiko.Netmiko import send_command [as 別名]
#!/usr/bin/env python
from netmiko import Netmiko
from getpass import getpass

cisco1 = {
    'host': 'cisco1.twb-tech.com', 
    'username': 'pyclass', 
    'password': getpass(), 
    'device_type': 'cisco_ios',
}

net_connect = Netmiko(**cisco1)
command = 'copy flash:c880data-universalk9-mz.154-2.T1.bin flash:test1.bin'

print()
print(net_connect.find_prompt())
output = net_connect.send_command(command, delay_factor=4)
print(output)
print()
開發者ID:ilique,項目名稱:netmiko,代碼行數:21,代碼來源:send_command_delay.py

示例3: getpass

# 需要導入模塊: from netmiko import Netmiko [as 別名]
# 或者: from netmiko.Netmiko import send_command [as 別名]
#!/usr/bin/env python
from __future__ import print_function, unicode_literals

# Netmiko is the same as ConnectHandler
from netmiko import Netmiko
from getpass import getpass

my_device = {
    'host': "host.domain.com",
    'username': 'pyclass',
    'password': getpass(),
    'device_type': 'cisco_ios',
    # Increase (essentially) all sleeps by a factor of 2
    'global_delay_factor': 2,
}

net_connect = Netmiko(**my_device)
# Increase the sleeps for just send_command by a factor of 2
output = net_connect.send_command("show ip int brief", delay_factor=2)
print(output)
net_connect.disconnect()
開發者ID:ilique,項目名稱:netmiko,代碼行數:23,代碼來源:add_delay.py

示例4: Netmiko

# 需要導入模塊: from netmiko import Netmiko [as 別名]
# 或者: from netmiko.Netmiko import send_command [as 別名]
#!/usr/bin/env python
from netmiko import Netmiko
from getpass import getpass

key_file = "/home/gituser/.ssh/test_rsa"

cisco1 = {
    "device_type": "cisco_ios",
    "host": "cisco1.twb-tech.com",
    "username": "testuser",
    "use_keys": True,
    "key_file": key_file,
}

net_connect = Netmiko(**cisco1)
print(net_connect.find_prompt())
output = net_connect.send_command("show ip arp")
print(output)
開發者ID:ktbyers,項目名稱:netmiko,代碼行數:20,代碼來源:conn_ssh_keys.py

示例5: getpass

# 需要導入模塊: from netmiko import Netmiko [as 別名]
# 或者: from netmiko.Netmiko import send_command [as 別名]
#!/usr/bin/env python
from netmiko import Netmiko
from getpass import getpass

cisco1 = {
    "host": "cisco1.twb-tech.com",
    "username": "pyclass",
    "password": getpass(),
    "device_type": "cisco_ios",
}

net_connect = Netmiko(**cisco1)
command = "show ip int brief"

print()
print(net_connect.find_prompt())
output = net_connect.send_command(command)
net_connect.disconnect()
print(output)
print()
開發者ID:ktbyers,項目名稱:netmiko,代碼行數:22,代碼來源:send_command.py

示例6: getpass

# 需要導入模塊: from netmiko import Netmiko [as 別名]
# 或者: from netmiko.Netmiko import send_command [as 別名]
#!/usr/bin/env python
from __future__ import print_function, unicode_literals

# Netmiko is the same as ConnectHandler
from netmiko import Netmiko
from getpass import getpass

my_device = {
    'host': 'host.domain.com',
    'username': 'pyclass',
    'password': getpass(),
    'device_type': 'cisco_ios',
}

net_connect = Netmiko(**my_device)
# Requires ntc-templates to be installed in ~/ntc-templates/templates
output = net_connect.send_command("show ip int brief", use_textfsm=True)
print(output)
開發者ID:ilique,項目名稱:netmiko,代碼行數:20,代碼來源:show_command_textfsm.py

示例7: getpass

# 需要導入模塊: from netmiko import Netmiko [as 別名]
# 或者: from netmiko.Netmiko import send_command [as 別名]
#!/usr/bin/env python
from netmiko import Netmiko
from getpass import getpass

nxos1 = {
    "host": "nxos1.twb-tech.com",
    "username": "pyclass",
    "password": getpass(),
    "device_type": "cisco_nxos",
}

commands = ["logging history size 500"]

net_connect = Netmiko(**nxos1)

print()
print(net_connect.find_prompt())
output = net_connect.send_config_set(commands)
output += net_connect.send_command("copy run start")
print(output)
print()
開發者ID:ktbyers,項目名稱:netmiko,代碼行數:23,代碼來源:config_change.py

示例8: getpass

# 需要導入模塊: from netmiko import Netmiko [as 別名]
# 或者: from netmiko.Netmiko import send_command [as 別名]
#!/usr/bin/env python
from __future__ import print_function, unicode_literals

# Netmiko is the same as ConnectHandler
from netmiko import Netmiko
from getpass import getpass

my_device = {
    'host': 'host.domain.com',
    'username': 'pyclass',
    'password': getpass(),
    'device_type': 'cisco_ios',
}

net_connect = Netmiko(**my_device)

output = net_connect.send_command("show ip int brief")
print(output)

net_connect.disconnect()
開發者ID:ilique,項目名稱:netmiko,代碼行數:22,代碼來源:show_command.py

示例9: getpass

# 需要導入模塊: from netmiko import Netmiko [as 別名]
# 或者: from netmiko.Netmiko import send_command [as 別名]
R01 = {
    "host": "192.168.1.32",
    "username": "admin",
    "password": getpass(),
    "device_type": "cisco_ios",
}

cfg_file = "config_changes.txt"
net_connect = Netmiko(**R01)

# routing table before change #
command = "show ip route"
print('routes PRE changes')
print(net_connect.find_prompt())
pre_routes = net_connect.send_command(command) 
print(pre_routes)
print()

# make changes #
print()
print(net_connect.find_prompt())
output = net_connect.send_config_from_file(cfg_file)
print(output)
print()

# routing table after changes #
print('routes POST changes')
print(net_connect.find_prompt())
post_routes = net_connect.send_command(command)
print(post_routes)
開發者ID:befthimi,項目名稱:neteng,代碼行數:32,代碼來源:netmiko_changes_from_file.py

示例10: input

# 需要導入模塊: from netmiko import Netmiko [as 別名]
# 或者: from netmiko.Netmiko import send_command [as 別名]
except NameError:
    host = input("Enter host to connect to: ")

password = getpass()
device = {
    'host': host,
    'username': 'pyclass',
    'password': password,
    'device_type': 'cisco_ios',
}

net_connect = Netmiko(**device)

# Use send_config_set() to make config change
config = ['logging console', 'logging buffer 15000']
output = net_connect.send_config_set(config)
output_printer(output)

# Use send_config_from_file() to make config change
output = net_connect.send_config_from_file('config.txt')
output_printer(output)


message = "Verifying config change\n"
output = net_connect.send_command("show run | inc logging")
if '8000' in output:
    message += "Logging buffer is size 8000"
else:
    message += "Logging buffer size is not correct!"
output_printer(message)
開發者ID:McGuireChris,項目名稱:pynet,代碼行數:32,代碼來源:exercise4.py


注:本文中的netmiko.Netmiko.send_command方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。