Return interface name from interface index
(self, if_index)
| 281 | network_name) |
| 282 | |
| 283 | def dev_from_index(self, if_index): |
| 284 | # type: (int) -> NetworkInterface |
| 285 | """Return interface name from interface index""" |
| 286 | try: |
| 287 | if_index = int(if_index) # Backward compatibility |
| 288 | return next(iface for iface in self.values() |
| 289 | if iface.index == if_index) |
| 290 | except (StopIteration, RuntimeError): |
| 291 | if str(if_index) == "1": |
| 292 | # Test if the loopback interface is set up |
| 293 | return self.dev_from_networkname(conf.loopback_name) |
| 294 | raise ValueError("Unknown network interface index %r" % if_index) |
| 295 | |
| 296 | def _add_fake_iface(self, |
| 297 | ifname, |
no test coverage detected