Jaymes Mosher | 603e62a | 2017-06-28 15:53:19 -0600 | [diff] [blame] | 1 | # -*- coding: utf-8 -*- |
| 2 | |
| 3 | import re |
| 4 | |
azvyagintsev | 42b64a1 | 2018-08-17 11:47:45 +0300 | [diff] [blame] | 5 | def __virtual__(): |
| 6 | return 'linux_netlink' |
Jaymes Mosher | 603e62a | 2017-06-28 15:53:19 -0600 | [diff] [blame] | 7 | |
Jaymes Mosher | 279cb88 | 2017-06-29 11:03:57 -0600 | [diff] [blame] | 8 | def ls(regex): |
Jaymes Mosher | 603e62a | 2017-06-28 15:53:19 -0600 | [diff] [blame] | 9 | """ |
| 10 | Provide a list of network interfaces. |
| 11 | """ |
| 12 | _lo_re = re.compile(r'^lo$') |
| 13 | _alphanum_re = re.compile(regex) |
| 14 | |
| 15 | def _filter(interface): |
| 16 | return _alphanum_re.match(interface) and not _lo_re.match(interface) |
| 17 | |
| 18 | return filter(_filter, __salt__['grains.get']('ip_interfaces', {}).keys()) |