本文整理汇总了Python中nova.cells.utils.cell_with_item函数的典型用法代码示例。如果您正苦于以下问题:Python cell_with_item函数的具体用法?Python cell_with_item怎么用?Python cell_with_item使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cell_with_item函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_add_cell_to_compute_node
def test_add_cell_to_compute_node(self):
fake_compute = objects.ComputeNode(id=1, host='fake')
cell_path = 'fake_path'
proxy = cells_utils.add_cell_to_compute_node(fake_compute, cell_path)
self.assertIsInstance(proxy, cells_utils.ComputeNodeProxy)
self.assertEqual(cells_utils.cell_with_item(cell_path, 1), proxy.id)
self.assertEqual(cells_utils.cell_with_item(cell_path, 'fake'),
proxy.host)
示例2: test_add_cell_to_compute_node_no_service
def test_add_cell_to_compute_node_no_service(self, mock_get_by_id):
fake_compute = objects.ComputeNode(id=1, host='fake', service_id=1)
mock_get_by_id.side_effect = exception.ServiceNotFound(service_id=1)
cell_path = 'fake_path'
proxy = cells_utils.add_cell_to_compute_node(fake_compute, cell_path)
self.assertIsInstance(proxy, cells_utils.ComputeNodeProxy)
self.assertEqual(cells_utils.cell_with_item(cell_path, 1), proxy.id)
self.assertEqual(cells_utils.cell_with_item(cell_path, 'fake'),
proxy.host)
self.assertRaises(exception.ServiceNotFound, getattr, proxy, 'service')
示例3: test_add_cell_to_service_with_compute_node
def test_add_cell_to_service_with_compute_node(self):
fake_service = objects.Service(id=1, host='fake')
fake_service.compute_node = objects.ComputeNode(id=1, host='fake')
cell_path = 'fake_path'
proxy = cells_utils.add_cell_to_service(fake_service, cell_path)
self.assertIsInstance(proxy, cells_utils.ServiceProxy)
self.assertEqual(cells_utils.cell_with_item(cell_path, 1), proxy.id)
self.assertEqual(cells_utils.cell_with_item(cell_path, 'fake'),
proxy.host)
self.assertRaises(AttributeError,
getattr, proxy, 'compute_node')
示例4: test_add_cell_to_compute_node_with_service
def test_add_cell_to_compute_node_with_service(self, mock_get_by_id):
fake_compute = objects.ComputeNode(id=1, host='fake', service_id=1)
mock_get_by_id.return_value = objects.Service(id=1, host='fake-svc')
cell_path = 'fake_path'
proxy = cells_utils.add_cell_to_compute_node(fake_compute, cell_path)
self.assertIsInstance(proxy, cells_utils.ComputeNodeProxy)
self.assertEqual(cells_utils.cell_with_item(cell_path, 1), proxy.id)
self.assertEqual(cells_utils.cell_with_item(cell_path, 'fake'),
proxy.host)
self.assertIsInstance(proxy.service, cells_utils.ServiceProxy)
self.assertEqual(cells_utils.cell_with_item(cell_path, 1),
proxy.service.id)
self.assertEqual(cells_utils.cell_with_item(cell_path, 'fake-svc'),
proxy.service.host)
示例5: test_service_delete
def test_service_delete(self):
cell_service_id = cells_utils.cell_with_item('cell1', 1)
with mock.patch.object(self.host_api.cells_rpcapi,
'service_delete') as service_delete:
self.host_api.service_delete(self.ctxt, cell_service_id)
service_delete.assert_called_once_with(
self.ctxt, cell_service_id)
示例6: test_service_delete
def test_service_delete(self):
fake_cell = "fake-cell"
service_id = "1"
cell_service_id = cells_utils.cell_with_item(fake_cell, service_id)
with mock.patch.object(self.msg_runner, "service_delete") as service_delete:
self.cells_manager.service_delete(self.ctxt, cell_service_id)
service_delete.assert_called_once_with(self.ctxt, fake_cell, service_id)
示例7: test_compute_node_get_not_found
def test_compute_node_get_not_found(self):
cell_compute_uuid = cells_utils.cell_with_item('cell1', uuids.cn_uuid)
with mock.patch.object(self.host_api.cells_rpcapi, 'compute_node_get',
side_effect=exception.CellRoutingInconsistency(
reason='because_cells_v1')):
self.assertRaises(exception.ComputeHostNotFound,
self.host_api.compute_node_get,
self.ctxt, cell_compute_uuid)
示例8: test_instance_get_all_by_host
def test_instance_get_all_by_host(self, mock_get):
instances = [dict(id=1, cell_name='cell1', host='host1'),
dict(id=2, cell_name='cell2', host='host1'),
dict(id=3, cell_name='cell1', host='host2')]
mock_get.return_value = instances
expected_result = [instances[0], instances[2]]
cell_and_host = cells_utils.cell_with_item('cell1', 'fake-host')
result = self.host_api.instance_get_all_by_host(self.ctxt,
cell_and_host)
self.assertEqual(expected_result, result)
示例9: test_compute_node_get
def test_compute_node_get(self):
fake_cell = "fake-cell"
fake_response = messaging.Response(fake_cell, FAKE_COMPUTE_NODES[0], False)
expected_response = copy.deepcopy(FAKE_COMPUTE_NODES[0])
cells_utils.add_cell_to_compute_node(expected_response, fake_cell)
cell_and_id = cells_utils.cell_with_item(fake_cell, "fake-id")
self.mox.StubOutWithMock(self.msg_runner, "compute_node_get")
self.msg_runner.compute_node_get(self.ctxt, "fake-cell", "fake-id").AndReturn(fake_response)
self.mox.ReplayAll()
response = self.cells_manager.compute_node_get(self.ctxt, compute_id=cell_and_id)
self.assertEqual(expected_response, response)
示例10: test_split_cell_and_item
def test_split_cell_and_item(self):
path = 'australia', 'queensland', 'gold_coast'
cell = cells_utils._PATH_CELL_SEP.join(path)
item = 'host_5'
together = cells_utils.cell_with_item(cell, item)
self.assertEqual(cells_utils._CELL_ITEM_SEP.join([cell, item]),
together)
# Test normal usage
result_cell, result_item = cells_utils.split_cell_and_item(together)
self.assertEqual(cell, result_cell)
self.assertEqual(item, result_item)
# Test with no cell
cell = None
together = cells_utils.cell_with_item(cell, item)
self.assertEqual(item, together)
result_cell, result_item = cells_utils.split_cell_and_item(together)
self.assertEqual(cell, result_cell)
self.assertEqual(item, result_item)
示例11: test_service_get_by_compute_host
def test_service_get_by_compute_host(self):
self.mox.StubOutWithMock(self.msg_runner, "service_get_by_compute_host")
fake_cell = "fake-cell"
fake_response = messaging.Response(fake_cell, FAKE_SERVICES[0], False)
expected_response = copy.deepcopy(FAKE_SERVICES[0])
cells_utils.add_cell_to_service(expected_response, fake_cell)
cell_and_host = cells_utils.cell_with_item("fake-cell", "fake-host")
self.msg_runner.service_get_by_compute_host(self.ctxt, fake_cell, "fake-host").AndReturn(fake_response)
self.mox.ReplayAll()
response = self.cells_manager.service_get_by_compute_host(self.ctxt, host_name=cell_and_host)
self.assertEqual(expected_response, response)
示例12: test_get_host_uptime
def test_get_host_uptime(self):
fake_cell = "parent!fake-cell"
fake_host = "fake-host"
fake_cell_and_host = cells_utils.cell_with_item(fake_cell, fake_host)
host_uptime = " 08:32:11 up 93 days, 18:25, 12 users, load average:" " 0.20, 0.12, 0.14"
fake_response = messaging.Response(self.ctxt, fake_cell, host_uptime, False)
self.mox.StubOutWithMock(self.msg_runner, "get_host_uptime")
self.msg_runner.get_host_uptime(self.ctxt, fake_cell, fake_host).AndReturn(fake_response)
self.mox.ReplayAll()
response = self.cells_manager.get_host_uptime(self.ctxt, fake_cell_and_host)
self.assertEqual(host_uptime, response)
示例13: test_proxy_rpc_to_manager
def test_proxy_rpc_to_manager(self):
self.mox.StubOutWithMock(self.msg_runner, "proxy_rpc_to_manager")
fake_response = self._get_fake_response()
cell_and_host = cells_utils.cell_with_item("fake-cell", "fake-host")
topic = "%s.%s" % (CONF.compute_topic, cell_and_host)
self.msg_runner.proxy_rpc_to_manager(
self.ctxt, "fake-cell", "fake-host", topic, "fake-rpc-msg", True, -1
).AndReturn(fake_response)
self.mox.ReplayAll()
response = self.cells_manager.proxy_rpc_to_manager(
self.ctxt, topic=topic, rpc_message="fake-rpc-msg", call=True, timeout=-1
)
self.assertEqual("fake-response", response)
示例14: test_task_log_get_all_with_filters
def test_task_log_get_all_with_filters(self):
expected_response, responses = self._build_task_log_responses(1)
cell_and_host = cells_utils.cell_with_item('fake-cell', 'fake-host')
self.mox.StubOutWithMock(self.msg_runner,
'task_log_get_all')
self.msg_runner.task_log_get_all(self.ctxt, 'fake-cell',
'fake-name', 'fake-begin', 'fake-end', host='fake-host',
state='fake-state').AndReturn(responses)
self.mox.ReplayAll()
response = self.cells_manager.task_log_get_all(self.ctxt,
task_name='fake-name',
period_beginning='fake-begin', period_ending='fake-end',
host=cell_and_host, state='fake-state')
self.assertEqual(expected_response, response)
示例15: test_proxy_rpc_to_manager
def test_proxy_rpc_to_manager(self):
self.mox.StubOutWithMock(self.msg_runner,
'proxy_rpc_to_manager')
fake_response = self._get_fake_response()
cell_and_host = cells_utils.cell_with_item('fake-cell', 'fake-host')
topic = "%s.%s" % (compute_rpcapi.RPC_TOPIC, cell_and_host)
self.msg_runner.proxy_rpc_to_manager(self.ctxt, 'fake-cell',
'fake-host', topic, 'fake-rpc-msg',
True, -1).AndReturn(fake_response)
self.mox.ReplayAll()
response = self.cells_manager.proxy_rpc_to_manager(self.ctxt,
topic=topic, rpc_message='fake-rpc-msg', call=True,
timeout=-1)
self.assertEqual('fake-response', response)