| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
import pyroute2 |
| 17 |
|
| 18 |
from neutron_fwaas import privileged |
| 19 |
from neutron_fwaas.privileged import utils |
| 20 |
|
| 21 |
|
| 22 |
def _get_ifname(link): |
| 23 |
attr_dict = dict(link['attrs']) |
| 24 |
return attr_dict['IFLA_IFNAME'] |
| 25 |
|
| 26 |
|
| 27 |
def list_interface_names(): |
| 28 |
iproute = pyroute2.IPRoute() |
| 29 |
result = iproute.get_links() |
| 30 |
return [_get_ifname(link) for link in result] |
| 31 |
|
| 32 |
|
| 33 |
@privileged.default.entrypoint |
| 34 |
def get_in_namespace_interfaces(namespace): |
| 35 |
before = list_interface_names() |
| 36 |
with utils.in_namespace(namespace): |
| 37 |
inside = list_interface_names() |
| 38 |
after = list_interface_names() |
| 39 |
return before, inside, after |