本文整理汇总了Python中quantum.plugins.nec.db.api.get_ofc_id_lookup_both函数的典型用法代码示例。如果您正苦于以下问题:Python get_ofc_id_lookup_both函数的具体用法?Python get_ofc_id_lookup_both怎么用?Python get_ofc_id_lookup_both使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_ofc_id_lookup_both函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_convert_network_id
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()
示例2: _test_convert_port_id
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()
示例3: test_convert_network_id_with_new_tenant_id
def test_convert_network_id_with_new_tenant_id(self):
t_id, ofc_t_id, ofc_n_id = self.generate_random_ids(3)
ofc_t_path = '/tenants/%s' % ofc_t_id
ndb.get_ofc_id_lookup_both(
self.ctx.session, 'ofc_tenant', t_id).AndReturn(ofc_t_path)
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()
示例4: test_convert_port_id
def test_convert_port_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)
ndb.get_ofc_id_lookup_both(
self.ctx.session, 'ofc_network', n_id).AndReturn(ofc_n_id)
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_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()
示例5: _test_convert_port_id_with_new_network_id
def _test_convert_port_id_with_new_network_id(self, port_path_template):
t_id, n_id = generate_random_ids(2)
ofc_n_id, ofc_p_id = generate_random_ids(2)
ofc_n_path = '/networks/%s' % 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 = port_path_template % {'network': ofc_n_id, 'port': ofc_p_id}
print 'exp=', exp
print 'ret=', ret
self.assertEqual(ret, exp)
self.mox.VerifyAll()
示例6: test_convert_port_id_with_new_network_id
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()
示例7: convert_ofc_network_id
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
示例8: convert_ofc_port_id
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}
示例9: test_get_ofc_id_old
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)
示例10: _get_ofc_id
def _get_ofc_id(self, context, resource, quantum_id):
return ndb.get_ofc_id_lookup_both(context.session,
resource, quantum_id)