2

我正在尝试使用带有函数 send_config_set() 的 ssh 向我的 netgear 交换机发送一些配置

Netgear_M4100_66={'device_type':'netgear_prosafe',
        'host':'172.16.97.66',
        'username':'admin',
        'password':'******',
        }
    

all_devices=[Netgear_M4100_66]
config_commands=['interface vlan 97']

    
for device in all_devices:    
    
    net_connect = ConnectHandler(**device,fast_cli=True)
    net_connect.enable()
    net_connect.send_config_set(config_commands)
    output=net_connect.send_command('show port status all')
    print("\n\n------------- Device {0} = {1} -------------".format(device['device_type'],device['host']))
    print(output)
    print("----------- End ------------")

这是回溯

`Traceback (most recent call last):
File "add_Switch_netmiko.py", line 118, in <module>
options()
File "add_Switch_netmiko.py", line 99, in options
config_mehrere_Switche()
File "add_Switch_netmiko.py", line 80, in config_mehrere_Switche 
net_connect.send_config_set(config_commands)
File "/usr/local/lib/python3.6/dist-packages/netmiko/base_connection.py", 
line 1837, in send_config_set
output += self.config_mode(*cfg_mode_args)
File "/usr/local/lib/python3.6/dist- 
packages/netmiko/netgear/netgear_prosafe_ssh.py", line 29, in config_mode
return super().config_mode(config_command=config_command, pattern=pattern)
File "/usr/local/lib/python3.6/dist- 
packages/netmiko/cisco_base_connection.py", line 41, in config_mode
config_command=config_command, pattern=pattern, re_flags=re_flags
File "/usr/local/lib/python3.6/dist-packages/netmiko/base_connection.py", 
line 1728, in config_mode
if not re.search(pattern, output, flags=re_flags):
File "/usr/lib/python3.6/re.py", line 182, in search
return _compile(pattern, flags).search(string)
File "/usr/lib/python3.6/re.py", line 301, in _compile
p = sre_compile.compile(pattern, flags)
File "/usr/lib/python3.6/sre_compile.py", line 562, in compile
p = sre_parse.parse(p, flags)
File "/usr/lib/python3.6/sre_parse.py", line 869, in parse
raise source.error("unbalanced parenthesis")
sre_constants.error: unbalanced parenthesis at position 0`

在查看了互联网上的所有示例之后,这应该可以正常工作,但不幸的是,它不是 . 我以为问题出在python3.6上,所以我将它升级到最新的python3.8,但仍然遇到同样的问题。

4

0 回答 0