My purpose in this code is to detect interfaces with L3 IP under the "Virtual-ethernet" interfaces in a NE40 Huawei device. I was able to do this step. As I mentioned below, my question is, How can I see the configurations of these interfaces with get_device() or a different method? Or should I use a different library with Napalm?
First part of code :
from napalm import get_network_driver
driver = get_network_driver('huawei_vrp')
device = driver(hostname='X.X.X.X', username='admin', password='admin')
device.open()
get_interfaces_ip = device.get_interfaces_ip()
get_config_device = device.get_config()
for i in get_interfaces_ip:
if "Virtual-Ether" in i:
print(i)
print(i) Output:
Virtual-Ethernet3/0/1.3083
Virtual-Ethernet3/0/1.3086
Virtual-Ethernet3/0/1.3087
Virtual-Ethernet3/0/1.3090
Virtual-Ethernet3/0/1.3091
Full code: ( Added get_config() feature to code)
from napalm import get_network_driver
driver = get_network_driver('huawei_vrp')
device = driver(hostname='X.X.X.X', username='admin', password='admin')
device.open()
get_interfaces_ip = device.get_interfaces_ip()
get_config_device = device.get_config()
for i in get_interfaces_ip:
if "Virtual-Ether" in i:
#print(i)
interface_config = get_config_device[i]
print(interface_config)
print(interface_config) Error received :
[appadmin@ryugbz01 Huawei]$ python3 napalm_vrp_huawei_conf.py
Virtual-Ethernet3/0/1.24
Traceback (most recent call last):
File "napalm_vrp_huawei_conf.py", line 19, in <module>
interface_config = get_config_device[i]
KeyError: 'Virtual-Ethernet3/0/1.24'
In the last part, with the get_config() feature, I cannot see the configurations under Virtual-Ethernet3/0/1.24 interface, for example. What method should I apply?
Maybe the following script can give an idea.