本文整理汇总了Python中nova.cells.utils.add_cell_to_compute_node函数的典型用法代码示例。如果您正苦于以下问题:Python add_cell_to_compute_node函数的具体用法?Python add_cell_to_compute_node怎么用?Python add_cell_to_compute_node使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了add_cell_to_compute_node函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: compute_node_get
def compute_node_get(self, ctxt, compute_id):
"""Get a compute node by ID in a specific cell."""
cell_name, compute_id = cells_utils.split_cell_and_item(compute_id)
response = self.msg_runner.compute_node_get(ctxt, cell_name, compute_id)
node = response.value_or_raise()
cells_utils.add_cell_to_compute_node(node, cell_name)
return node
示例2: test_compute_node_get_all
def test_compute_node_get_all(self):
responses = []
expected_response = []
# 3 cells... so 3 responses. Each response is a list of computes.
# Manager should turn these into a single list of responses.
for i in range(3):
cell_name = 'path!to!cell%i' % i
compute_nodes = []
for compute_node in FAKE_COMPUTE_NODES:
fake_compute = objects.ComputeNode(**compute_node)
fake_compute._cached_service = None
compute_nodes.append(fake_compute)
expected_compute_node = cells_utils.ComputeNodeProxy(
fake_compute, cell_name)
expected_response.append(
(cell_name, expected_compute_node, fake_compute))
response = messaging.Response(self.ctxt, cell_name, compute_nodes,
False)
responses.append(response)
self.mox.StubOutWithMock(self.msg_runner,
'compute_node_get_all')
self.mox.StubOutWithMock(cells_utils, 'add_cell_to_compute_node')
self.msg_runner.compute_node_get_all(self.ctxt,
hypervisor_match='fake-match').AndReturn(responses)
# Calls are done by cells, so we need to sort the list by the cell name
expected_response.sort(key=lambda k: k[0])
for cell_name, compute_proxy, compute_node in expected_response:
cells_utils.add_cell_to_compute_node(
compute_node, cell_name).AndReturn(compute_proxy)
self.mox.ReplayAll()
response = self.cells_manager.compute_node_get_all(self.ctxt,
hypervisor_match='fake-match')
self.assertEqual([proxy for cell, proxy, compute in expected_response],
response)
示例3: 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)
示例4: compute_node_get_all
def compute_node_get_all(self, ctxt, hypervisor_match=None):
"""Return list of compute nodes in all cells."""
responses = self.msg_runner.compute_node_get_all(ctxt, hypervisor_match=hypervisor_match)
# 1 response per cell. Each response is a list of compute_node
# entries.
ret_nodes = []
for response in responses:
nodes = response.value_or_raise()
for node in nodes:
cells_utils.add_cell_to_compute_node(node, response.cell_name)
ret_nodes.append(node)
return ret_nodes
示例5: test_compute_node_get
def test_compute_node_get(self):
fake_cell = "fake-cell"
fake_compute = objects.ComputeNode(**FAKE_COMPUTE_NODES[0])
fake_compute._cached_service = None
fake_response = messaging.Response(self.ctxt, fake_cell, fake_compute, False)
expected_response = cells_utils.ComputeNodeProxy(fake_compute, fake_cell)
cell_and_id = cells_utils.cell_with_item(fake_cell, "fake-id")
self.mox.StubOutWithMock(self.msg_runner, "compute_node_get")
self.mox.StubOutWithMock(cells_utils, "add_cell_to_compute_node")
self.msg_runner.compute_node_get(self.ctxt, "fake-cell", "fake-id").AndReturn(fake_response)
cells_utils.add_cell_to_compute_node(fake_compute, fake_cell).AndReturn(expected_response)
self.mox.ReplayAll()
response = self.cells_manager.compute_node_get(self.ctxt, compute_id=cell_and_id)
self.assertEqual(expected_response, response)
示例6: 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)
示例7: test_compute_node_get_all
def test_compute_node_get_all(self):
responses = []
expected_response = []
# 3 cells... so 3 responses. Each response is a list of computes.
# Manager should turn these into a single list of responses.
for i in xrange(3):
cell_name = "path!to!cell%i" % i
compute_nodes = []
for compute_node in FAKE_COMPUTE_NODES:
compute_nodes.append(copy.deepcopy(compute_node))
expected_compute_node = copy.deepcopy(compute_node)
cells_utils.add_cell_to_compute_node(expected_compute_node, cell_name)
expected_response.append(expected_compute_node)
response = messaging.Response(cell_name, compute_nodes, False)
responses.append(response)
self.mox.StubOutWithMock(self.msg_runner, "compute_node_get_all")
self.msg_runner.compute_node_get_all(self.ctxt, hypervisor_match="fake-match").AndReturn(responses)
self.mox.ReplayAll()
response = self.cells_manager.compute_node_get_all(self.ctxt, hypervisor_match="fake-match")
self.assertEqual(expected_response, response)
示例8: 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')
示例9: 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)