def get_interfaces_ip(self): interfaces_ip = {} ipv4_addresses = self.api('/ip/address/print') for ifname in (row['interface'] for row in ipv4_addresses): interfaces_ip.setdefault(ifname, dict()) interfaces_ip[ifname]['ipv4'] = iface_addresses(ipv4_addresses, ifname) ipv6_addresses = self.api('/ipv6/address/print') for ifname in (row['interface'] for row in ipv6_addresses): interfaces_ip.setdefault(ifname, dict()) interfaces_ip[ifname]['ipv6'] = iface_addresses(ipv6_addresses, ifname) return interfaces_ip
def get_interfaces_ip(self): interfaces_ip = {} ipv4_addresses = self.api('/ip/address/print') for ifname in (row['interface'] for row in ipv4_addresses): interfaces_ip.setdefault(ifname, dict()) interfaces_ip[ifname]['ipv4'] = iface_addresses(ipv4_addresses, ifname) ipv6_addresses = self.api('/ip6/address/print') for ifname in (row['interface'] for row in ipv6_addresses): interfaces_ip.setdefault(ifname, dict()) interfaces_ip[ifname]['ipv6'] = iface_addresses(ipv6_addresses, ifname) return interfaces_ip
def get_interfaces_ip(self): interfaces_ip = {} ipv4_addresses = self.api('/ip/address/print') for ifname in (row['interface'] for row in ipv4_addresses): interfaces_ip.setdefault(ifname, dict()) interfaces_ip[ifname]['ipv4'] = iface_addresses(ipv4_addresses, ifname) try: ipv6_addresses = self.api('/ipv6/address/print') for ifname in (row['interface'] for row in ipv6_addresses): interfaces_ip.setdefault(ifname, dict()) interfaces_ip[ifname]['ipv6'] = iface_addresses(ipv6_addresses, ifname) except (TrapError, MultiTrapError): pass return interfaces_ip
def get_interfaces_ip(self): interfaces_ip = {} ipv4_addresses = tuple(self.api('/ip/address/print')) for ifname in (row['interface'] for row in ipv4_addresses): interfaces_ip.setdefault(ifname, {}) interfaces_ip[ifname]['ipv4'] = iface_addresses(ipv4_addresses, ifname) try: ipv6_addresses = tuple(self.api('/ipv6/address/print')) for ifname in (row['interface'] for row in ipv6_addresses): interfaces_ip.setdefault(ifname, {}) interfaces_ip[ifname]['ipv6'] = iface_addresses(ipv6_addresses, ifname) except (TrapError, MultiTrapError): pass return interfaces_ip
def test_iface_addresses_empty(): rows = ({'interface': 'ether1', 'address': '192.168.1.1/24'}, ) assert utils.iface_addresses(rows, 'ether2') == {}
def test_iface_addresses(passed, expected): assert utils.iface_addresses(passed, 'ether1') == expected
def test_iface_addresses_empty(): rows = ({'interface': 'ether1', 'address': '192.168.1.1/24'},) assert utils.iface_addresses(rows, 'ether2') == {}
def test_iface_addresses(passed, expected): assert utils.iface_addresses(passed, 'ether1') == expected