Exemplo n.º 1
0
    def test_convert_network_id(self):
        t_id, ofc_t_id, ofc_n_id = self.generate_random_ids(3)
        ndb.get_ofc_id_lookup_both(
            self.ctx.session, 'ofc_tenant', t_id).AndReturn(ofc_t_id)
        self.mox.ReplayAll()

        ret = self.driver.convert_ofc_network_id(self.ctx, ofc_n_id, t_id)
        self.assertEqual(ret, ('/tenants/%(tenant)s/networks/%(network)s' %
                               {'tenant': ofc_t_id, 'network': ofc_n_id}))
        self.mox.VerifyAll()
Exemplo n.º 2
0
    def _test_convert_port_id(self, port_path_template):
        t_id, n_id = generate_random_ids(2)
        ofc_n_id, ofc_p_id = generate_random_ids(2)

        ndb.get_ofc_id_lookup_both(
            self.ctx.session, 'ofc_network', n_id).AndReturn(ofc_n_id)
        self.mox.ReplayAll()

        ret = self.driver.convert_ofc_port_id(self.ctx, ofc_p_id, t_id, n_id)
        exp = port_path_template % {'network': ofc_n_id, 'port': ofc_p_id}
        self.assertEqual(ret, exp)
        self.mox.VerifyAll()
Exemplo n.º 3
0
    def test_convert_port_id_with_new_network_id(self):
        t_id, n_id = self.generate_random_ids(2)
        ofc_t_id, ofc_n_id, ofc_p_id = self.generate_random_ids(3)

        ofc_n_path = ('/tenants/%(tenant)s/networks/%(network)s' %
                      {'tenant': ofc_t_id, 'network': ofc_n_id})
        ndb.get_ofc_id_lookup_both(
            self.ctx.session, 'ofc_network', n_id).AndReturn(ofc_n_path)
        self.mox.ReplayAll()

        ret = self.driver.convert_ofc_port_id(self.ctx, ofc_p_id, t_id, n_id)
        exp = ('/tenants/%(tenant)s/networks/%(network)s/ports/%(port)s' %
               {'tenant': ofc_t_id, 'network': ofc_n_id, 'port': ofc_p_id})
        self.assertEqual(ret, exp)
        self.mox.VerifyAll()
Exemplo n.º 4
0
    def convert_ofc_network_id(self, context, ofc_network_id, tenant_id):
        # If ofc_network_id starts with '/', it is already new-style
        if ofc_network_id[0] == '/':
            return ofc_network_id

        ofc_tenant_id = ndb.get_ofc_id_lookup_both(
            context.session, 'ofc_tenant', tenant_id)
        ofc_tenant_id = self.convert_ofc_tenant_id(context, ofc_tenant_id)
        params = dict(tenant=ofc_tenant_id, network=ofc_network_id)
        return '%(tenant)s/networks/%(network)s' % params
Exemplo n.º 5
0
    def convert_ofc_network_id(self, context, ofc_network_id, tenant_id):
        # If ofc_network_id starts with '/', it is already new-style
        if ofc_network_id[0] == '/':
            return ofc_network_id

        ofc_tenant_id = ndb.get_ofc_id_lookup_both(context.session,
                                                   'ofc_tenant', tenant_id)
        ofc_tenant_id = self.convert_ofc_tenant_id(context, ofc_tenant_id)
        params = dict(tenant=ofc_tenant_id, network=ofc_network_id)
        return '%(tenant)s/networks/%(network)s' % params
Exemplo n.º 6
0
    def convert_ofc_port_id(self, context, ofc_port_id, tenant_id, network_id):
        # If ofc_port_id  starts with '/', it is already new-style
        if ofc_port_id[0] == '/':
            return ofc_port_id

        ofc_network_id = ndb.get_ofc_id_lookup_both(
            context.session, 'ofc_network', network_id)
        ofc_network_id = self.convert_ofc_network_id(
            context, ofc_network_id, tenant_id)
        return self.attachment_path % {'network': ofc_network_id,
                                       'attachment': ofc_port_id}
Exemplo n.º 7
0
    def convert_ofc_port_id(self, context, ofc_port_id, tenant_id, network_id):
        # If ofc_port_id  starts with '/', it is already new-style
        if ofc_port_id[0] == '/':
            return ofc_port_id

        ofc_network_id = ndb.get_ofc_id_lookup_both(
            context.session, 'ofc_network', network_id)
        ofc_network_id = self.convert_ofc_network_id(
            context, ofc_network_id, tenant_id)
        return self.attachment_path % {'network': ofc_network_id,
                                       'attachment': ofc_port_id}
 def test_get_ofc_id_old(self):
     o, q, n = self.get_ofc_item_random_params()
     ndb.add_ofc_item(self.session, 'ofc_tenant', q, o, self.OLD)
     self._check_new_old_item(ndb.get_ofc_id, q, None, o)
     ret = ndb.get_ofc_id_lookup_both(self.session, 'ofc_tenant', q)
     self.assertEqual(ret, o)
Exemplo n.º 9
0
 def test_get_ofc_id_old(self):
     o, q, n = self.get_ofc_item_random_params()
     ndb.add_ofc_item(self.session, 'ofc_tenant', q, o, self.OLD)
     self._check_new_old_item(ndb.get_ofc_id, q, None, o)
     ret = ndb.get_ofc_id_lookup_both(self.session, 'ofc_tenant', q)
     self.assertEqual(ret, o)
Exemplo n.º 10
0
 def _get_ofc_id(self, context, resource, neutron_id):
     return ndb.get_ofc_id_lookup_both(context.session,
                                       resource, neutron_id)