Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support VLAN devices #40

Closed
fdellwing opened this issue Oct 7, 2019 · 1 comment · Fixed by #41
Closed

Support VLAN devices #40

fdellwing opened this issue Oct 7, 2019 · 1 comment · Fixed by #41

Comments

@fdellwing
Copy link
Contributor

Hi,

we use VLAN devices (there are a lot of them in production) and sadly ifcfg is unable to parse them. I do not need any real information about the VLAN interfaces, but the script should not crash.

Python 3.7.4 (default, Sep 16 2019, 11:45:03) 
[GCC 4.9.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ifcfg
>>> ifcfg.interfaces()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.7/site-packages/ifcfg/__init__.py", line 66, in interfaces
    return Parser(ifconfig=ifconfig).interfaces
  File "/usr/local/lib/python3.7/site-packages/ifcfg/parser.py", line 30, in __init__
    self.parse(self.ifconfig_data)
  File "/usr/local/lib/python3.7/site-packages/ifcfg/parser.py", line 70, in parse
    self.add_device(cur)
  File "/usr/local/lib/python3.7/site-packages/ifcfg/parser.py", line 34, in add_device
    raise RuntimeError("Device {} already added".format(device_name))
RuntimeError: Device eth2 already added
br2       Link encap:Ethernet  HWaddr 08:00:27:7c:6d:9d  
          inet addr:10.0.0.1  Bcast:10.0.0.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe7c:6d9d/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:20 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:1528 (1.4 KiB)

br4       Link encap:Ethernet  HWaddr 08:00:27:7c:6d:9d  
          inet addr:10.0.2.1  Bcast:10.0.2.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe7c:6d9d/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:727 errors:0 dropped:0 overruns:0 frame:0
          TX packets:643 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:88547 (86.4 KiB)  TX bytes:890348 (869.4 KiB)

brlan     Link encap:Ethernet  HWaddr 08:00:27:d8:78:41  
          inet addr:192.168.0.1  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fed8:7841/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:6905 errors:0 dropped:0 overruns:0 frame:0
          TX packets:20 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:351150 (342.9 KiB)  TX bytes:1568 (1.5 KiB)

eth0      Link encap:Ethernet  HWaddr 08:00:27:d8:78:41  
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:7353 errors:0 dropped:433 overruns:0 frame:0
          TX packets:20 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:482610 (471.2 KiB)  TX bytes:1568 (1.5 KiB)

eth1      Link encap:Ethernet  HWaddr 08:00:27:f2:d0:cb  
          inet addr:172.16.25.205  Bcast:172.16.25.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fef2:d0cb/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:65901 errors:0 dropped:0 overruns:0 frame:0
          TX packets:36638 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:80272939 (76.5 MiB)  TX bytes:5598473 (5.3 MiB)

eth2      Link encap:Ethernet  HWaddr 08:00:27:7c:6d:9d  
          inet6 addr: fe80::a00:27ff:fe7c:6d9d/64 Scope:Link
          UP BROADCAST RUNNING PROMISC MULTICAST  MTU:1500  Metric:1
          RX packets:7200 errors:0 dropped:431 overruns:0 frame:0
          TX packets:111 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:471382 (460.3 KiB)  TX bytes:8368 (8.1 KiB)

eth2.2    Link encap:Ethernet  HWaddr 08:00:27:7c:6d:9d  
          inet6 addr: fe80::a00:27ff:fe7c:6d9d/64 Scope:Link
          UP BROADCAST RUNNING PROMISC MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:31 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:2278 (2.2 KiB)

eth2.4    Link encap:Ethernet  HWaddr 08:00:27:7c:6d:9d  
          inet6 addr: fe80::a00:27ff:fe7c:6d9d/64 Scope:Link
          UP BROADCAST RUNNING PROMISC MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:52 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:3704 (3.6 KiB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:12786 errors:0 dropped:0 overruns:0 frame:0
          TX packets:12786 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1 
          RX bytes:1853178 (1.7 MiB)  TX bytes:1853178 (1.7 MiB)

tap2      Link encap:Ethernet  HWaddr ba:c7:a9:f5:ae:6b  
          inet6 addr: fe80::b8c7:a9ff:fef5:ae6b/64 Scope:Link
          UP BROADCAST RUNNING PROMISC MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:41 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:100 
          RX bytes:0 (0.0 B)  TX bytes:3146 (3.0 KiB)

tap4      Link encap:Ethernet  HWaddr 22:e9:b0:f5:6d:9d  
          inet addr:10.0.2.2  Bcast:10.0.2.255  Mask:255.255.255.0
          inet6 addr: fe80::20e9:b0ff:fef5:6d9d/64 Scope:Link
          UP BROADCAST RUNNING PROMISC MULTICAST  MTU:1500  Metric:1
          RX packets:727 errors:0 dropped:0 overruns:0 frame:0
          TX packets:983 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:100 
          RX bytes:98725 (96.4 KiB)  TX bytes:913020 (891.6 KiB)
@benjaoming
Copy link
Collaborator

Thanks for the report @fdellwing !

Guessing that the issue is that eth2.2 gets matched and added as eth2 which should crash, as it already exists... BUT it's the matching that's the problem. Assuming that . should be allowed in the pattern for interface names.

PR is absolutely welcomed :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants