示例#1
0
 def test_get_v4_ips_by_interface_bad_id(self):
     with contextlib.nested(
             mock.patch.object(db,
                               'virtual_interface_get_by_uuid',
                               return_value=None), ):
         ipam_lib = nova_ipam_lib.NeutronNovaIPAMLib(None)
         v4_IPs = ipam_lib.get_v4_ips_by_interface(None, 'net_id', 'vif_id',
                                                   'project_id')
         self.assertEqual([], v4_IPs)
示例#2
0
 def test_get_v4_ips_by_interface(self):
     with contextlib.nested(
             mock.patch.object(db, 'virtual_interface_get_by_uuid',
                               return_value={'id': 'fakeid'}),
             mock.patch.object(db, 'fixed_ips_by_virtual_interface',
                               return_value=[{'address': '192.168.1.101'},
                                             {'address': '192.168.1.102'}])
     ):
         ipam_lib = nova_ipam_lib.NeutronNovaIPAMLib(None)
         v4_IPs = ipam_lib.get_v4_ips_by_interface(None,
                                                   'net_id',
                                                   'vif_id',
                                                   'project_id')
         self.assertEqual(['192.168.1.101', '192.168.1.102'], v4_IPs)
示例#3
0
    def test_get_v6_ips_by_interface_bad_id(self):
        class FakeContext(context.RequestContext):
            def elevated(self):
                pass

        net = dict(test_network.fake_network, cidr_v6='2001:db8::')
        with contextlib.nested(
                mock.patch.object(db, 'network_get_by_uuid', return_value=net),
                mock.patch.object(db,
                                  'virtual_interface_get_by_uuid',
                                  return_value=None)):
            ipam_lib = nova_ipam_lib.NeutronNovaIPAMLib(None)
            ctx = FakeContext('user_id', 'project_id')
            v6_IPs = ipam_lib.get_v6_ips_by_interface(ctx, 'net_id', 'vif_id',
                                                      'project_id')
            self.assertEqual([], v6_IPs)
示例#4
0
 def test_get_v4_ips_by_interface(self):
     fake_ips = [
         dict(test_fixed_ip.fake_fixed_ip, address='192.168.1.101'),
         dict(test_fixed_ip.fake_fixed_ip, address='192.168.1.102')
     ]
     with contextlib.nested(
             mock.patch.object(db,
                               'virtual_interface_get_by_uuid',
                               return_value=fake_vif),
             mock.patch.object(db,
                               'fixed_ips_by_virtual_interface',
                               return_value=fake_ips)):
         ipam_lib = nova_ipam_lib.NeutronNovaIPAMLib(None)
         v4_IPs = ipam_lib.get_v4_ips_by_interface(None, 'net_id', 'vif_id',
                                                   'project_id')
         self.assertEqual(['192.168.1.101', '192.168.1.102'], v4_IPs)
示例#5
0
    def test_get_v6_ips_by_interface(self):
        class FakeContext(context.RequestContext):
            def elevated(self):
                pass

        with contextlib.nested(
                mock.patch.object(db,
                                  'network_get_by_uuid',
                                  return_value={'cidr_v6': '2001:db8::'}),
                mock.patch.object(db,
                                  'virtual_interface_get_by_uuid',
                                  return_value=fake_vif)):
            ipam_lib = nova_ipam_lib.NeutronNovaIPAMLib(None)
            ctx = FakeContext('user_id', 'project_id')
            v6_IPs = ipam_lib.get_v6_ips_by_interface(ctx, 'net_id', 'vif_id',
                                                      'project_id')
            self.assertEqual(['2001:db8::200:ff:fe00:0'], v6_IPs)