def NetInterfaces(self, active_only: bool = True): """Access the local network interfaces. Args: active_only: Only consider active interfaces. Returns: A list of NetInterface objects corresponding to each detected interface. """ ni = net_info.NetInfo(active_only=active_only, poll=True) return ni.Interfaces()
def setUp(self, _): self.netinfo = net_info.NetInfo(poll=False) self.mock_ip1 = mock.Mock() self.mock_ip1.IPAddress = None self.mock_ip1.default_gateway = None self.mock_ip2 = mock.Mock() self.mock_ip2.IPAddress = None self.mock_ip2.default_gateway = '2620:0::100' self.mock_ip3 = mock.Mock() self.mock_ip3.IPAddress = None self.mock_ip3.default_gateway = '172.25.100.1' self.mock_ip4 = mock.Mock() self.mock_ip4.IPAddress = None self.mock_ip4.default_gateway = '10.1.10.2'
def _NetInfo(self): if not self._net_info: self._net_info = net_info.NetInfo(active_only=False, poll=True) return self._net_info