saltstack/salt — Issue #742: network.interfaces should do a better job parsing
Author: fatbox
Created: 2012-02-23 02:51:21+00:00
State: open

Consider the following output from `ip addr show`

```
1: lo: mtu 16436 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:23:8b:64:7a:34 brd ff:ff:ff:ff:ff:ff
inet 1.2.3.5/29 brd 1.2.3.7 scope global eth0
inet 1.2.3.4/29 brd 1.2.3.7 scope global secondary eth0:0
inet6 fe80::223:8bff:fe64:7a34/64 scope link
valid_lft forever preferred_lft forever
3: eth1: mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:23:8b:64:7a:35 brd ff:ff:ff:ff:ff:ff
inet6 fe80::223:8bff:fe64:7a35/64 scope link
valid_lft forever preferred_lft forever
4: vlan998@eth1: mtu 1500 qdisc noqueue state UP
link/ether 00:23:8b:64:7a:35 brd ff:ff:ff:ff:ff:ff
inet 192.168.169.1/24 brd 192.168.169.255 scope global vlan998
inet6 fe80::223:8bff:fe64:7a35/64 scope link
valid_lft forever preferred_lft forever
```

Yet network interfaces only yields

```
{'local': {'eth0': {'hwaddr': '00:23:8b:64:7a:34',
'ipaddr': '1.2.3.4',
'netmask': '255.255.255.248',
'up': True},
'eth1': {'hwaddr': '00:23:8b:64:7a:35',
'ipaddr': None,
'netmask': None,
'up': True},
'lo': {'hwaddr': '00:00:00:00:00:00',
'ipaddr': '127.0.0.1',
'netmask': '255.0.0.0',
'up': True}}}
```

Things that should be added:

* Correctly handle vlan interfaces - This is pretty straight forward. I have implemented it in a branch and will push it to github once I create this issue.
* Correctly handle inet6 interfaces
* Correctly handle secondary addresses. Currently `network.interfaces` is incorrectly listing the secondary address for eth0.

The last two are what I got stuck on as they both will require a change that will break anything that is using the current structure.

I have written the code for parsing out the network details from each line, but I am unsure in how to represent it in the data structure. Do we add another member for v6 addresses? Should we use a list of dict's for secondary addresses?