Ejemplo n.º 1
0
def Host_getCapabilities_Ret(server_address, ret):
    """
    We need to add additional information to getCaps as it was done for xmlrpc.
    """
    ret['info']['lastClientIface'] = getDeviceByIP(server_address)

    return ret['info']
Ejemplo n.º 2
0
 def getCapabilities(self):
     api = API.Global()
     ret = api.getCapabilities()
     ret['info']['lastClient'] = self.cif.threadLocal.client
     ret['info']['lastClientIface'] = getDeviceByIP(
         self.cif.threadLocal.server)
     return ret
Ejemplo n.º 3
0
def Host_getCapabilities_Ret(server_address, ret):
    """
    We need to add additional information to getCaps as it is done for xmlrpc.
    """
    ret['info']['lastClientIface'] = getDeviceByIP(server_address)

    return ret['info']
Ejemplo n.º 4
0
 def testGetDeviceByIP(self):
     for addr in nl_addr.iter_addrs():
         # Link-local IPv6 addresses are generated from the MAC address,
         # which is shared between a nic and its bridge. Since We don't
         # support having the same IP address on two different NICs, and
         # link-local IPv6 addresses aren't interesting for 'getDeviceByIP'
         # then ignore them in the test
         if addr['scope'] != 'link':
             self.assertEqual(
                 addr['label'],
                 addresses.getDeviceByIP(addr['address'].split('/')[0]))
Ejemplo n.º 5
0
    def test_get_device_by_ip(self):
        NL_ADDRESS4 = {'label': 'iface0',
                       'address': '127.0.0.1/32',
                       'family': 'inet'}
        NL_ADDRESS6 = {'label': 'iface1',
                       'address': '2001::1:1:1/48',
                       'family': 'inet6'}
        NL_ADDRESSES = [NL_ADDRESS4, NL_ADDRESS6]

        with mock.patch.object(addresses.nl_addr, 'iter_addrs',
                               lambda: NL_ADDRESSES):
            for nl_addr in NL_ADDRESSES:
                self.assertEqual(
                    nl_addr['label'],
                    addresses.getDeviceByIP(nl_addr['address'].split('/')[0]))
Ejemplo n.º 6
0
    def test_get_device_by_ip(self):
        NL_ADDRESS4 = {'label': 'iface0',
                       'address': '127.0.0.1/32',
                       'family': 'inet'}
        NL_ADDRESS6 = {'label': 'iface1',
                       'address': '2001::1:1:1/48',
                       'family': 'inet6'}
        NL_ADDRESSES = [NL_ADDRESS4, NL_ADDRESS6]

        with mock.patch.object(addresses.nl_addr, 'iter_addrs',
                               lambda: NL_ADDRESSES):
            for nl_addr in NL_ADDRESSES:
                self.assertEqual(
                    nl_addr['label'],
                    addresses.getDeviceByIP(nl_addr['address'].split('/')[0]))
Ejemplo n.º 7
0
    def testGetDeviceByIP(self):
        NL_ADDRESS4 = {'label': 'iface0',
                       'address': '127.0.0.1/32',
                       'family': 'inet'}
        NL_ADDRESS6 = {'label': 'iface1',
                       'address': '2001::1:1:1/48',
                       'family': 'inet6'}
        NL_ADDRESSES = [NL_ADDRESS4, NL_ADDRESS6]

        with MonkeyPatchScope([
                (addresses.nl_addr, 'iter_addrs', lambda: NL_ADDRESSES)]):
            for nl_addr in NL_ADDRESSES:
                self.assertEqual(
                    nl_addr['label'],
                    addresses.getDeviceByIP(nl_addr['address'].split('/')[0]))