Example #1
0
 def testc_delete_ofc_tenant(self):
     """test delete ofc_tenant."""
     t, n, p, f, none = self.get_random_params()
     self.ofc.create_ofc_tenant(self.ctx, t)
     self.assertTrue(ndb.get_ofc_item(self.ctx.session, 'ofc_tenant', t))
     self.ofc.delete_ofc_tenant(self.ctx, t)
     self.assertFalse(ndb.get_ofc_item(self.ctx.session, 'ofc_tenant', t))
 def testc_delete_ofc_tenant(self):
     """test delete ofc_tenant."""
     t, n, p, f, none = self.get_random_params()
     self.ofc.create_ofc_tenant(self.ctx, t)
     self.assertTrue(ndb.get_ofc_item(self.ctx.session, 'ofc_tenant', t))
     self.ofc.delete_ofc_tenant(self.ctx, t)
     self.assertFalse(ndb.get_ofc_item(self.ctx.session, 'ofc_tenant', t))
Example #3
0
 def test_delete_ofc_router(self):
     """test delete ofc_router"""
     t, r, _n = self.get_random_params()
     self.ofc.create_ofc_tenant(self.ctx, t)
     self.ofc.create_ofc_router(self.ctx, t, r)
     self.assertTrue(ndb.get_ofc_item(self.ctx.session, 'ofc_router', r))
     self.ofc.delete_ofc_router(self.ctx, r, {'tenant_id': t})
     self.assertFalse(ndb.get_ofc_item(self.ctx.session, 'ofc_network', r))
 def testa_create_ofc_tenant(self):
     """test create ofc_tenant."""
     t, n, p, f, none = self.get_random_params()
     self.assertFalse(ndb.get_ofc_item(self.ctx.session, 'ofc_tenant', t))
     self.ofc.create_ofc_tenant(self.ctx, t)
     self.assertTrue(ndb.get_ofc_item(self.ctx.session, 'ofc_tenant', t))
     tenant = ndb.get_ofc_item(self.ctx.session, 'ofc_tenant', t)
     self.assertEqual(tenant.ofc_id, "ofc-" + t[:-4])
 def testf_delete_ofc_network(self):
     """test delete ofc_network."""
     t, n, p, f, none = self.get_random_params()
     self.ofc.create_ofc_tenant(self.ctx, t)
     self.ofc.create_ofc_network(self.ctx, t, n)
     self.assertTrue(ndb.get_ofc_item(self.ctx.session, 'ofc_network', n))
     self.ofc.delete_ofc_network(self.ctx, n, {'tenant_id': t})
     self.assertFalse(ndb.get_ofc_item(self.ctx.session, 'ofc_network', n))
Example #6
0
 def testf_delete_ofc_network(self):
     """test delete ofc_network."""
     t, n, p, f, none = self.get_random_params()
     self.ofc.create_ofc_tenant(self.ctx, t)
     self.ofc.create_ofc_network(self.ctx, t, n)
     self.assertTrue(ndb.get_ofc_item(self.ctx.session, 'ofc_network', n))
     self.ofc.delete_ofc_network(self.ctx, n, {'tenant_id': t})
     self.assertFalse(ndb.get_ofc_item(self.ctx.session, 'ofc_network', n))
Example #7
0
 def test_delete_ofc_router(self):
     """test delete ofc_router"""
     t, r, _n = self.get_random_params()
     self.ofc.create_ofc_tenant(self.ctx, t)
     self.ofc.create_ofc_router(self.ctx, t, r)
     self.assertTrue(ndb.get_ofc_item(self.ctx.session, 'ofc_router', r))
     self.ofc.delete_ofc_router(self.ctx, r, {'tenant_id': t})
     self.assertFalse(ndb.get_ofc_item(self.ctx.session, 'ofc_network', r))
Example #8
0
 def testa_create_ofc_tenant(self):
     """test create ofc_tenant."""
     t, n, p, f, none = self.get_random_params()
     self.assertFalse(ndb.get_ofc_item(self.ctx.session, 'ofc_tenant', t))
     self.ofc.create_ofc_tenant(self.ctx, t)
     self.assertTrue(ndb.get_ofc_item(self.ctx.session, 'ofc_tenant', t))
     tenant = ndb.get_ofc_item(self.ctx.session, 'ofc_tenant', t)
     self.assertEqual(tenant.ofc_id, "ofc-" + t[:-4])
Example #9
0
 def testd_create_ofc_network(self):
     """test create ofc_network."""
     t, n, p, f, none = self.get_random_params()
     self.ofc.create_ofc_tenant(self.ctx, t)
     self.assertFalse(ndb.get_ofc_item(self.ctx.session, 'ofc_network', n))
     self.ofc.create_ofc_network(self.ctx, t, n)
     self.assertTrue(ndb.get_ofc_item(self.ctx.session, 'ofc_network', n))
     network = ndb.get_ofc_item(self.ctx.session, 'ofc_network', n)
     self.assertEqual(network.ofc_id, "ofc-" + n[:-4])
Example #10
0
 def test_create_ofc_router(self):
     """test create ofc_router"""
     t, r, _n = self.get_random_params()
     self.ofc.create_ofc_tenant(self.ctx, t)
     self.assertFalse(ndb.get_ofc_item(self.ctx.session, 'ofc_router', r))
     self.ofc.create_ofc_router(self.ctx, t, r, 'test router')
     self.assertTrue(ndb.get_ofc_item(self.ctx.session, 'ofc_router', r))
     router = ndb.get_ofc_item(self.ctx.session, 'ofc_router', r)
     self.assertEqual(router.ofc_id, "ofc-" + r[:-4])
Example #11
0
 def test_create_ofc_router(self):
     """test create ofc_router"""
     t, r, _n = self.get_random_params()
     self.ofc.create_ofc_tenant(self.ctx, t)
     self.assertFalse(ndb.get_ofc_item(self.ctx.session, 'ofc_router', r))
     self.ofc.create_ofc_router(self.ctx, t, r, 'test router')
     self.assertTrue(ndb.get_ofc_item(self.ctx.session, 'ofc_router', r))
     router = ndb.get_ofc_item(self.ctx.session, 'ofc_router', r)
     self.assertEqual(router.ofc_id, "ofc-" + r[:-4])
 def testd_create_ofc_network(self):
     """test create ofc_network."""
     t, n, p, f, none = self.get_random_params()
     self.ofc.create_ofc_tenant(self.ctx, t)
     self.assertFalse(ndb.get_ofc_item(self.ctx.session, 'ofc_network', n))
     self.ofc.create_ofc_network(self.ctx, t, n)
     self.assertTrue(ndb.get_ofc_item(self.ctx.session, 'ofc_network', n))
     network = ndb.get_ofc_item(self.ctx.session, 'ofc_network', n)
     self.assertEqual(network.ofc_id, "ofc-" + n[:-4])
    def testb_get_ofc_item(self):
        """test get OFC item."""
        o, q, n = self.get_ofc_item_random_params()
        ndb.add_ofc_item(self.session, 'ofc_tenant', q, o)
        tenant = ndb.get_ofc_item(self.session, 'ofc_tenant', q)
        self.assertEqual(tenant.ofc_id, o)
        self.assertEqual(tenant.quantum_id, q)

        tenant_none = ndb.get_ofc_item(self.session, 'ofc_tenant', n)
        self.assertEqual(None, tenant_none)
Example #14
0
    def testb_get_ofc_item(self):
        """test get OFC item."""
        o, q, n = self.get_ofc_item_random_params()
        ndb.add_ofc_item(self.session, 'ofc_tenant', q, o)
        tenant = ndb.get_ofc_item(self.session, 'ofc_tenant', q)
        self.assertEqual(tenant.ofc_id, o)
        self.assertEqual(tenant.quantum_id, q)

        tenant_none = ndb.get_ofc_item(self.session, 'ofc_tenant', n)
        self.assertEqual(None, tenant_none)
    def test_add_ofc_item_old(self):
        o, q, n = self.get_ofc_item_random_params()
        ret = ndb.add_ofc_item(self.session, 'ofc_tenant', q, o, self.OLD)
        self.assertEqual(ret.id, o)
        self.assertEqual(ret.quantum_id, q)

        ret = ndb.get_ofc_item(self.session, 'ofc_tenant', q, self.NEW)
        self.assertEqual(ret, None)
        ret = ndb.get_ofc_item(self.session, 'ofc_tenant', q, self.OLD)
        self.assertEqual(ret.id, o)
        self.assertEqual(ret.quantum_id, q)
Example #16
0
    def test_add_ofc_item_old(self):
        o, q, n = self.get_ofc_item_random_params()
        ret = ndb.add_ofc_item(self.session, 'ofc_tenant', q, o, self.OLD)
        self.assertEqual(ret.id, o)
        self.assertEqual(ret.quantum_id, q)

        ret = ndb.get_ofc_item(self.session, 'ofc_tenant', q, self.NEW)
        self.assertEqual(ret, None)
        ret = ndb.get_ofc_item(self.session, 'ofc_tenant', q, self.OLD)
        self.assertEqual(ret.id, o)
        self.assertEqual(ret.quantum_id, q)
 def testi_delete_ofc_port(self):
     """test delete ofc_port."""
     t, n, p, f, none = self.get_random_params()
     self.ofc.create_ofc_tenant(self.ctx, t)
     self.ofc.create_ofc_network(self.ctx, t, n)
     ndb.add_portinfo(self.ctx.session, p, "0xabc", 3, 65535,
                      "00:13:22:33:44:55")
     port = {'tenant_id': t, 'network_id': n}
     self.ofc.create_ofc_port(self.ctx, p, port)
     self.assertTrue(ndb.get_ofc_item(self.ctx.session, 'ofc_port', p))
     self.ofc.delete_ofc_port(self.ctx, p, port)
     self.assertFalse(ndb.get_ofc_item(self.ctx.session, 'ofc_port', p))
Example #18
0
 def testi_delete_ofc_port(self):
     """test delete ofc_port."""
     t, n, p, f, none = self.get_random_params()
     self.ofc.create_ofc_tenant(self.ctx, t)
     self.ofc.create_ofc_network(self.ctx, t, n)
     get_portinfo = self._mock_get_portinfo(p)
     port = {'tenant_id': t, 'network_id': n}
     self.ofc.create_ofc_port(self.ctx, p, port)
     self.assertTrue(ndb.get_ofc_item(self.ctx.session, 'ofc_port', p))
     self.ofc.delete_ofc_port(self.ctx, p, port)
     self.assertFalse(ndb.get_ofc_item(self.ctx.session, 'ofc_port', p))
     get_portinfo.assert_called_once_with(mock.ANY, p)
 def testl_delete_ofc_packet_filter(self):
     """test delete ofc_filter."""
     t, n, p, f, none = self.get_random_params()
     self.ofc.create_ofc_tenant(self.ctx, t)
     self.ofc.create_ofc_network(self.ctx, t, n)
     pf = {'tenant_id': t, 'network_id': n}
     self.ofc.create_ofc_packet_filter(self.ctx, f, pf)
     self.assertTrue(ndb.get_ofc_item(self.ctx.session,
                                      'ofc_packet_filter', f))
     self.ofc.delete_ofc_packet_filter(self.ctx, f)
     self.assertFalse(ndb.get_ofc_item(self.ctx.session,
                                       'ofc_packet_filter', f))
Example #20
0
 def testi_delete_ofc_port(self):
     """test delete ofc_port."""
     t, n, p, f, none = self.get_random_params()
     self.ofc.create_ofc_tenant(self.ctx, t)
     self.ofc.create_ofc_network(self.ctx, t, n)
     ndb.add_portinfo(self.ctx.session, p, "0xabc", 3, 65535,
                      "00:13:22:33:44:55")
     port = {'tenant_id': t, 'network_id': n}
     self.ofc.create_ofc_port(self.ctx, p, port)
     self.assertTrue(ndb.get_ofc_item(self.ctx.session, 'ofc_port', p))
     self.ofc.delete_ofc_port(self.ctx, p, port)
     self.assertFalse(ndb.get_ofc_item(self.ctx.session, 'ofc_port', p))
Example #21
0
 def testi_delete_ofc_port(self):
     """test delete ofc_port."""
     t, n, p, f, none = self.get_random_params()
     self.ofc.create_ofc_tenant(self.ctx, t)
     self.ofc.create_ofc_network(self.ctx, t, n)
     get_portinfo = self._mock_get_portinfo(p)
     port = {'tenant_id': t, 'network_id': n}
     self.ofc.create_ofc_port(self.ctx, p, port)
     self.assertTrue(ndb.get_ofc_item(self.ctx.session, 'ofc_port', p))
     self.ofc.delete_ofc_port(self.ctx, p, port)
     self.assertFalse(ndb.get_ofc_item(self.ctx.session, 'ofc_port', p))
     get_portinfo.assert_called_once_with(mock.ANY, p)
Example #22
0
 def testl_delete_ofc_packet_filter(self):
     """test delete ofc_filter."""
     t, n, p, f, none = self.get_random_params()
     self.ofc.create_ofc_tenant(self.ctx, t)
     self.ofc.create_ofc_network(self.ctx, t, n)
     pf = {'tenant_id': t, 'network_id': n}
     self.ofc.create_ofc_packet_filter(self.ctx, f, pf)
     self.assertTrue(
         ndb.get_ofc_item(self.ctx.session, 'ofc_packet_filter', f))
     self.ofc.delete_ofc_packet_filter(self.ctx, f)
     self.assertFalse(
         ndb.get_ofc_item(self.ctx.session, 'ofc_packet_filter', f))
Example #23
0
 def testg_create_ofc_port(self):
     """test create ofc_port."""
     t, n, p, f, none = self.get_random_params()
     self.ofc.create_ofc_tenant(self.ctx, t)
     self.ofc.create_ofc_network(self.ctx, t, n)
     ndb.add_portinfo(self.ctx.session, p, "0xabc", 1, 65535,
                      "00:11:22:33:44:55")
     self.assertFalse(ndb.get_ofc_item(self.ctx.session, 'ofc_port', p))
     port = {'tenant_id': t, 'network_id': n}
     self.ofc.create_ofc_port(self.ctx, p, port)
     self.assertTrue(ndb.get_ofc_item(self.ctx.session, 'ofc_port', p))
     port = ndb.get_ofc_item(self.ctx.session, 'ofc_port', p)
     self.assertEqual(port.ofc_id, "ofc-" + p[:-4])
 def testj_create_ofc_packet_filter(self):
     """test create ofc_filter."""
     t, n, p, f, none = self.get_random_params()
     self.ofc.create_ofc_tenant(self.ctx, t)
     self.ofc.create_ofc_network(self.ctx, t, n)
     self.assertFalse(ndb.get_ofc_item(self.ctx.session,
                                       'ofc_packet_filter', f))
     pf = {'tenant_id': t, 'network_id': n}
     self.ofc.create_ofc_packet_filter(self.ctx, f, pf)
     self.assertTrue(ndb.get_ofc_item(self.ctx.session,
                                      'ofc_packet_filter', f))
     _filter = ndb.get_ofc_item(self.ctx.session, 'ofc_packet_filter', f)
     self.assertEqual(_filter.ofc_id, "ofc-" + f[:-4])
 def testg_create_ofc_port(self):
     """test create ofc_port."""
     t, n, p, f, none = self.get_random_params()
     self.ofc.create_ofc_tenant(self.ctx, t)
     self.ofc.create_ofc_network(self.ctx, t, n)
     ndb.add_portinfo(self.ctx.session, p, "0xabc", 1, 65535,
                      "00:11:22:33:44:55")
     self.assertFalse(ndb.get_ofc_item(self.ctx.session, 'ofc_port', p))
     port = {'tenant_id': t, 'network_id': n}
     self.ofc.create_ofc_port(self.ctx, p, port)
     self.assertTrue(ndb.get_ofc_item(self.ctx.session, 'ofc_port', p))
     port = ndb.get_ofc_item(self.ctx.session, 'ofc_port', p)
     self.assertEqual(port.ofc_id, "ofc-" + p[:-4])
Example #26
0
 def testj_create_ofc_packet_filter(self):
     """test create ofc_filter."""
     t, n, p, f, none = self.get_random_params()
     self.ofc.create_ofc_tenant(self.ctx, t)
     self.ofc.create_ofc_network(self.ctx, t, n)
     self.assertFalse(
         ndb.get_ofc_item(self.ctx.session, 'ofc_packet_filter', f))
     pf = {'tenant_id': t, 'network_id': n}
     self.ofc.create_ofc_packet_filter(self.ctx, f, pf)
     self.assertTrue(
         ndb.get_ofc_item(self.ctx.session, 'ofc_packet_filter', f))
     _filter = ndb.get_ofc_item(self.ctx.session, 'ofc_packet_filter', f)
     self.assertEqual(_filter.ofc_id, "ofc-" + f[:-4])
Example #27
0
    def test_del_ofc_item(self):
        o, q, n = self.get_ofc_item_random_params()
        ndb.add_ofc_item(self.session, 'ofc_tenant', q, o)
        self.assertTrue(ndb.del_ofc_item(self.session, 'ofc_tenant', q))

        self.assertIsNone(ndb.get_ofc_item(self.session, 'ofc_tenant', q))
        self.assertIsNone(ndb.find_ofc_item(self.session, 'ofc_tenant', o))
Example #28
0
    def test_del_ofc_item(self):
        o, q, n = self.get_ofc_item_random_params()
        ndb.add_ofc_item(self.session, 'ofc_tenant', q, o)
        self.assertTrue(ndb.del_ofc_item(self.session, 'ofc_tenant', q))

        self.assertIsNone(ndb.get_ofc_item(self.session, 'ofc_tenant', q))
        self.assertIsNone(ndb.find_ofc_item(self.session, 'ofc_tenant', o))
Example #29
0
    def test_router_route(self):
        t, r, _n = self.get_random_params()
        self.ofc.create_ofc_tenant(self.ctx, t)
        self.ofc.create_ofc_router(self.ctx, t, r)
        self.assertTrue(ndb.get_ofc_item(self.ctx.session, 'ofc_router', r))

        routes = [{'destination': '2.2.2.0/24', 'nexthop': '1.1.1.10'}]
        self.ofc.update_ofc_router_route(self.ctx, r, routes)
        self.assertEqual(len(self.ofc.driver.ofc_router_route_dict), 1)

        routes = [{
            'destination': '3.3.3.0/24',
            'nexthop': '1.1.1.11'
        }, {
            'destination': '4.4.4.0/24',
            'nexthop': '1.1.1.11'
        }]
        self.ofc.update_ofc_router_route(self.ctx, r, routes)
        self.assertEqual(len(self.ofc.driver.ofc_router_route_dict), 2)

        routes = [{'destination': '2.2.2.0/24', 'nexthop': '1.1.1.10'}]
        self.ofc.update_ofc_router_route(self.ctx, r, routes)
        self.assertEqual(len(self.ofc.driver.ofc_router_route_dict), 1)

        routes = []
        self.ofc.update_ofc_router_route(self.ctx, r, routes)
        self.assertEqual(len(self.ofc.driver.ofc_router_route_dict), 0)
    def testb_exists_ofc_item(self):
        """test get OFC d."""
        o, q, n = self.get_ofc_item_random_params()
        ndb.add_ofc_item(self.session, 'ofc_tenant', q, o)
        ret = ndb.exists_ofc_item(self.session, 'ofc_tenant', q)
        self.assertTrue(ret)

        tenant_none = ndb.get_ofc_item(self.session, 'ofc_tenant', n)
        self.assertEqual(None, tenant_none)
Example #31
0
    def testb_get_ofc_id(self):
        """test get OFC d."""
        o, q, n = self.get_ofc_item_random_params()
        ndb.add_ofc_item(self.session, 'ofc_tenant', q, o)
        tenant_id = ndb.get_ofc_id(self.session, 'ofc_tenant', q)
        self.assertEqual(tenant_id, o)

        tenant_none = ndb.get_ofc_item(self.session, 'ofc_tenant', n)
        self.assertIsNone(tenant_none)
Example #32
0
    def testb_exists_ofc_item(self):
        """test get OFC d."""
        o, q, n = self.get_ofc_item_random_params()
        ndb.add_ofc_item(self.session, 'ofc_tenant', q, o)
        ret = ndb.exists_ofc_item(self.session, 'ofc_tenant', q)
        self.assertTrue(ret)

        tenant_none = ndb.get_ofc_item(self.session, 'ofc_tenant', n)
        self.assertEqual(None, tenant_none)
Example #33
0
    def testb_get_ofc_id(self):
        """test get OFC d."""
        o, q, n = self.get_ofc_item_random_params()
        ndb.add_ofc_item(self.session, 'ofc_tenant', q, o)
        tenant_id = ndb.get_ofc_id(self.session, 'ofc_tenant', q)
        self.assertEqual(tenant_id, o)

        tenant_none = ndb.get_ofc_item(self.session, 'ofc_tenant', n)
        self.assertIsNone(tenant_none)
Example #34
0
    def test_router_interface(self):
        t, r, n = self.get_random_params()
        self.ofc.create_ofc_tenant(self.ctx, t)
        self.ofc.create_ofc_router(self.ctx, t, r)
        self.ofc.create_ofc_network(self.ctx, t, n)
        self.assertTrue(ndb.get_ofc_item(self.ctx.session, 'ofc_router', r))
        self.assertTrue(ndb.get_ofc_item(self.ctx.session, 'ofc_network', n))

        p = {'id': uuidutils.generate_uuid(),
             'network_id': n, 'ip_address': '10.1.1.1', 'cidr': '10.1.0.0/20',
             'mac_address': '11:22:33:44:55:66'}
        self.ofc.add_ofc_router_interface(self.ctx, r, p['id'], p)
        self.assertTrue(ndb.get_ofc_item(self.ctx.session,
                                         'ofc_port', p['id']))
        self.ofc.delete_ofc_router_interface(self.ctx, r, p['id'])
        self.assertFalse(ndb.get_ofc_item(self.ctx.session,
                                          'ofc_port', p['id']))
        self.ofc.delete_ofc_router(self.ctx, r, {'tenant_id': t})
        self.assertFalse(ndb.get_ofc_item(self.ctx.session, 'ofc_network', r))
Example #35
0
    def test_router_interface(self):
        t, r, n = self.get_random_params()
        self.ofc.create_ofc_tenant(self.ctx, t)
        self.ofc.create_ofc_router(self.ctx, t, r)
        self.ofc.create_ofc_network(self.ctx, t, n)
        self.assertTrue(ndb.get_ofc_item(self.ctx.session, 'ofc_router', r))
        self.assertTrue(ndb.get_ofc_item(self.ctx.session, 'ofc_network', n))

        p = {'id': uuidutils.generate_uuid(),
             'network_id': n, 'ip_address': '10.1.1.1', 'cidr': '10.1.0.0/20',
             'mac_address': '11:22:33:44:55:66'}
        self.ofc.add_ofc_router_interface(self.ctx, r, p['id'], p)
        self.assertTrue(ndb.get_ofc_item(self.ctx.session,
                                         'ofc_port', p['id']))
        self.ofc.delete_ofc_router_interface(self.ctx, r, p['id'])
        self.assertFalse(ndb.get_ofc_item(self.ctx.session,
                                          'ofc_port', p['id']))
        self.ofc.delete_ofc_router(self.ctx, r, {'tenant_id': t})
        self.assertFalse(ndb.get_ofc_item(self.ctx.session, 'ofc_network', r))
Example #36
0
    def testc_del_ofc_item(self):
        """test delete OFC item."""
        o, q, n = self.get_ofc_item_random_params()
        ndb.add_ofc_item(self.session, 'ofc_tenant', q, o)
        ndb.del_ofc_item(self.session, 'ofc_tenant', q)

        tenant_none = ndb.get_ofc_item(self.session, 'ofc_tenant', q)
        self.assertEqual(None, tenant_none)
        tenant_none = ndb.find_ofc_item(self.session, 'ofc_tenant', o)
        self.assertEqual(None, tenant_none)
    def _check_delete_ofc_item(self, mode, detect_mode=False):
        o, q, n = self.get_ofc_item_random_params()
        ret = ndb.add_ofc_item(self.session, 'ofc_tenant', q, o, mode)
        ofc_id = ret.ofc_id if mode == self.NEW else ret.id
        self.assertEqual(ofc_id, o)
        self.assertEqual(ret.quantum_id, q)
        ret = ndb.get_ofc_item(self.session, 'ofc_tenant', q, mode)
        ofc_id = ret.ofc_id if mode == self.NEW else ret.id
        self.assertEqual(ofc_id, o)
        self.assertEqual(ret.quantum_id, q)

        if detect_mode:
            ndb.del_ofc_item_lookup_both(self.session, 'ofc_tenant', q)
        else:
            ndb.del_ofc_item(self.session, 'ofc_tenant', q, mode)

        ret = ndb.get_ofc_item(self.session, 'ofc_tenant', q, self.NEW)
        self.assertEqual(ret, None)
        ret = ndb.get_ofc_item(self.session, 'ofc_tenant', q, self.OLD)
        self.assertEqual(ret, None)
Example #38
0
 def _test_create_ofc_port(self, with_filter=False):
     t, n, p, f, none = self.get_random_params()
     self.ofc.create_ofc_tenant(self.ctx, t)
     self.ofc.create_ofc_network(self.ctx, t, n)
     self.assertFalse(ndb.get_ofc_item(self.ctx.session, 'ofc_port', p))
     get_portinfo = self._mock_get_portinfo(p)
     port = {'tenant_id': t, 'network_id': n}
     if with_filter:
         _filters = ['filter1', 'filter2']
         self.plugin.get_packet_filters_for_port.return_value = _filters
     self.ofc.create_ofc_port(self.ctx, p, port)
     self.assertTrue(ndb.get_ofc_item(self.ctx.session, 'ofc_port', p))
     port = ndb.get_ofc_item(self.ctx.session, 'ofc_port', p)
     self.assertEqual(port.ofc_id, "ofc-" + p[:-4])
     get_portinfo.assert_called_once_with(mock.ANY, p)
     portval = self.ofc.driver.ofc_port_dict[port.ofc_id]
     if with_filter:
         self.assertEqual(_filters, portval['filters'])
     else:
         self.assertFalse('filters' in portval)
Example #39
0
    def _check_delete_ofc_item(self, mode, detect_mode=False):
        o, q, n = self.get_ofc_item_random_params()
        ret = ndb.add_ofc_item(self.session, 'ofc_tenant', q, o, mode)
        ofc_id = ret.ofc_id if mode == self.NEW else ret.id
        self.assertEqual(ofc_id, o)
        self.assertEqual(ret.quantum_id, q)
        ret = ndb.get_ofc_item(self.session, 'ofc_tenant', q, mode)
        ofc_id = ret.ofc_id if mode == self.NEW else ret.id
        self.assertEqual(ofc_id, o)
        self.assertEqual(ret.quantum_id, q)

        if detect_mode:
            ndb.del_ofc_item_lookup_both(self.session, 'ofc_tenant', q)
        else:
            ndb.del_ofc_item(self.session, 'ofc_tenant', q, mode)

        ret = ndb.get_ofc_item(self.session, 'ofc_tenant', q, self.NEW)
        self.assertEqual(ret, None)
        ret = ndb.get_ofc_item(self.session, 'ofc_tenant', q, self.OLD)
        self.assertEqual(ret, None)
Example #40
0
 def _test_create_ofc_port(self, with_filter=False):
     t, n, p, f, none = self.get_random_params()
     self.ofc.create_ofc_tenant(self.ctx, t)
     self.ofc.create_ofc_network(self.ctx, t, n)
     self.assertFalse(ndb.get_ofc_item(self.ctx.session, 'ofc_port', p))
     get_portinfo = self._mock_get_portinfo(p)
     port = {'tenant_id': t, 'network_id': n}
     if with_filter:
         _filters = ['filter1', 'filter2']
         self.plugin.get_packet_filters_for_port.return_value = _filters
     self.ofc.create_ofc_port(self.ctx, p, port)
     self.assertTrue(ndb.get_ofc_item(self.ctx.session, 'ofc_port', p))
     port = ndb.get_ofc_item(self.ctx.session, 'ofc_port', p)
     self.assertEqual(port.ofc_id, "ofc-" + p[:-4])
     get_portinfo.assert_called_once_with(mock.ANY, p)
     portval = self.ofc.driver.ofc_port_dict[port.ofc_id]
     if with_filter:
         self.assertEqual(_filters, portval['filters'])
     else:
         self.assertFalse('filters' in portval)
    def testc_del_ofc_item(self):
        """test delete OFC item."""
        o, q, n = self.get_ofc_item_random_params()
        ndb.add_ofc_item(self.session, 'ofc_tenant', q, o)
        ndb.del_ofc_item(self.session, 'ofc_tenant', q)

        tenant_none = ndb.get_ofc_item(self.session,
                                       'ofc_tenant', q)
        self.assertEqual(None, tenant_none)
        tenant_none = ndb.find_ofc_item(self.session,
                                        'ofc_tenant', o)
        self.assertEqual(None, tenant_none)
Example #42
0
    def test_router_route(self):
        t, r, _n = self.get_random_params()
        self.ofc.create_ofc_tenant(self.ctx, t)
        self.ofc.create_ofc_router(self.ctx, t, r)
        self.assertTrue(ndb.get_ofc_item(self.ctx.session, 'ofc_router', r))

        routes = [{'destination': '2.2.2.0/24', 'nexthop': '1.1.1.10'}]
        self.ofc.update_ofc_router_route(self.ctx, r, routes)
        self.assertEqual(len(self.ofc.driver.ofc_router_route_dict), 1)

        routes = [{'destination': '3.3.3.0/24', 'nexthop': '1.1.1.11'},
                  {'destination': '4.4.4.0/24', 'nexthop': '1.1.1.11'}]
        self.ofc.update_ofc_router_route(self.ctx, r, routes)
        self.assertEqual(len(self.ofc.driver.ofc_router_route_dict), 2)

        routes = [{'destination': '2.2.2.0/24', 'nexthop': '1.1.1.10'}]
        self.ofc.update_ofc_router_route(self.ctx, r, routes)
        self.assertEqual(len(self.ofc.driver.ofc_router_route_dict), 1)

        routes = []
        self.ofc.update_ofc_router_route(self.ctx, r, routes)
        self.assertEqual(len(self.ofc.driver.ofc_router_route_dict), 0)
Example #43
0
 def test_get_ofc_item_for_nonexisting_entry(self):
     self.assertIsNone(
         ndb.get_ofc_item(self.session, 'ofc_tenant', 'non-exist-id'))
Example #44
0
 def test_get_ofc_item(self):
     o, q, n = self.get_ofc_item_random_params()
     ndb.add_ofc_item(self.session, 'ofc_tenant', q, o)
     tenant = ndb.get_ofc_item(self.session, 'ofc_tenant', q)
     self.assertEqual(tenant.ofc_id, o)
     self.assertEqual(tenant.neutron_id, q)
Example #45
0
 def test_get_ofc_item(self):
     o, q, n = self.get_ofc_item_random_params()
     ndb.add_ofc_item(self.session, 'ofc_tenant', q, o)
     tenant = ndb.get_ofc_item(self.session, 'ofc_tenant', q)
     self.assertEqual(tenant.ofc_id, o)
     self.assertEqual(tenant.quantum_id, q)
Example #46
0
 def test_get_ofc_item_for_nonexisting_entry(self):
     self.assertIsNone(
         ndb.get_ofc_item(self.session, 'ofc_tenant', 'non-exist-id'))