当前位置: 首页>>代码示例>>Python>>正文


Python utils.cell_with_item函数代码示例

本文整理汇总了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)
开发者ID:Francis-Liu,项目名称:animated-broccoli,代码行数:10,代码来源:test_cells_utils.py

示例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')
开发者ID:aeng,项目名称:nova,代码行数:12,代码来源:test_cells_utils.py

示例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')
开发者ID:aeng,项目名称:nova,代码行数:13,代码来源:test_cells_utils.py

示例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)
开发者ID:aeng,项目名称:nova,代码行数:16,代码来源:test_cells_utils.py

示例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)
开发者ID:akashgangil,项目名称:nova,代码行数:7,代码来源:test_host_api.py

示例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)
开发者ID:anantk,项目名称:nova,代码行数:8,代码来源:test_cells_manager.py

示例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)
开发者ID:Juniper,项目名称:nova,代码行数:8,代码来源:test_host_api.py

示例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)
开发者ID:akashgangil,项目名称:nova,代码行数:11,代码来源:test_host_api.py

示例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)
开发者ID:kbijon,项目名称:OpenStack-CVRM,代码行数:11,代码来源:test_cells_manager.py

示例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)
开发者ID:DavidYan,项目名称:nova,代码行数:20,代码来源:test_cells_utils.py

示例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)
开发者ID:kbijon,项目名称:OpenStack-CVRM,代码行数:12,代码来源:test_cells_manager.py

示例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)
开发者ID:anantk,项目名称:nova,代码行数:13,代码来源:test_cells_manager.py

示例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)
开发者ID:anantk,项目名称:nova,代码行数:13,代码来源:test_cells_manager.py

示例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)
开发者ID:aeng,项目名称:nova,代码行数:14,代码来源:test_cells_manager.py

示例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)
开发者ID:Juniper,项目名称:nova,代码行数:14,代码来源:test_cells_manager.py


注:本文中的nova.cells.utils.cell_with_item函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。