예제 #1
0
    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
예제 #2
0
파일: ros.py 프로젝트: inetuid/napalm-ros
    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
예제 #3
0
    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
예제 #4
0
파일: ros.py 프로젝트: sHorst/napalm-ros
    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
예제 #5
0
def test_iface_addresses_empty():
    rows = ({'interface': 'ether1', 'address': '192.168.1.1/24'}, )
    assert utils.iface_addresses(rows, 'ether2') == {}
예제 #6
0
def test_iface_addresses(passed, expected):
    assert utils.iface_addresses(passed, 'ether1') == expected
예제 #7
0
def test_iface_addresses_empty():
    rows = ({'interface': 'ether1', 'address': '192.168.1.1/24'},)
    assert utils.iface_addresses(rows, 'ether2') == {}
예제 #8
0
def test_iface_addresses(passed, expected):
    assert utils.iface_addresses(passed, 'ether1') == expected