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


Python db.compute_node_create函数代码示例

本文整理汇总了Python中nova.db.compute_node_create函数的典型用法代码示例。如果您正苦于以下问题:Python compute_node_create函数的具体用法?Python compute_node_create怎么用?Python compute_node_create使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了compute_node_create函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _create_compute_service

    def _create_compute_service(self, **kwargs):
        """Create a compute service."""

        dic = {"binary": "nova-compute", "topic": "compute", "report_count": 0, "availability_zone": "dummyzone"}
        dic["host"] = kwargs.get("host", "dummy")
        s_ref = db.service_create(self.context, dic)
        if "created_at" in kwargs.keys() or "updated_at" in kwargs.keys():
            t = utils.utcnow() - datetime.timedelta(0)
            dic["created_at"] = kwargs.get("created_at", t)
            dic["updated_at"] = kwargs.get("updated_at", t)
            db.service_update(self.context, s_ref["id"], dic)

        dic = {
            "service_id": s_ref["id"],
            "vcpus": 16,
            "memory_mb": 32,
            "local_gb": 100,
            "vcpus_used": 16,
            "local_gb_used": 10,
            "hypervisor_type": "qemu",
            "hypervisor_version": 12003,
            "cpu_info": "",
        }
        dic["memory_mb_used"] = kwargs.get("memory_mb_used", 32)
        dic["hypervisor_type"] = kwargs.get("hypervisor_type", "qemu")
        dic["hypervisor_version"] = kwargs.get("hypervisor_version", 12003)
        db.compute_node_create(self.context, dic)
        return db.service_get(self.context, s_ref["id"])
开发者ID:rajarammallya,项目名称:openstack-nova,代码行数:28,代码来源:test_scheduler.py

示例2: test_create

 def test_create(self, mock_get):
     self.mox.StubOutWithMock(db, 'compute_node_create')
     db.compute_node_create(
         self.context,
         {
             'service_id': 456,
             'stats': fake_stats_db_format,
             'host_ip': fake_host_ip,
             'supported_instances': fake_supported_hv_specs_db_format,
             'uuid': uuidsentinel.fake_compute_node,
         }).AndReturn(fake_compute_node)
     self.mox.ReplayAll()
     compute = compute_node.ComputeNode(context=self.context)
     compute.service_id = 456
     compute.uuid = uuidsentinel.fake_compute_node
     compute.stats = fake_stats
     # NOTE (pmurray): host_ip is coerced to an IPAddress
     compute.host_ip = fake_host_ip
     compute.supported_hv_specs = fake_supported_hv_specs
     with mock.patch('oslo_utils.uuidutils.generate_uuid') as mock_gu:
         compute.create()
         self.assertFalse(mock_gu.called)
     self.compare_obj(compute, fake_compute_node,
                      subs=self.subs(),
                      comparators=self.comparators())
开发者ID:binarycode,项目名称:nova,代码行数:25,代码来源:test_compute_node.py

示例3: _create_compute_service

    def _create_compute_service(self):
        """Create compute-manager(ComputeNode and Service record)."""
        ctxt = context.get_admin_context()
        dic = {
            "host": "dummy",
            "binary": "nova-compute",
            "topic": "compute",
            "report_count": 0,
            "availability_zone": "dummyzone",
        }
        s_ref = db.service_create(ctxt, dic)

        dic = {
            "service_id": s_ref["id"],
            "vcpus": 16,
            "memory_mb": 32,
            "local_gb": 100,
            "vcpus_used": 16,
            "memory_mb_used": 32,
            "local_gb_used": 10,
            "hypervisor_type": "qemu",
            "hypervisor_version": 12003,
            "cpu_info": "",
        }
        db.compute_node_create(ctxt, dic)

        return db.service_get(ctxt, s_ref["id"])
开发者ID:nati,项目名称:nova,代码行数:27,代码来源:test_hosts.py

示例4: update_available_resource

    def update_available_resource(self, ctxt, host):
        """Updates compute manager resource info on ComputeNode table.

           Since we don't have a real hypervisor, pretend we have lots of
           disk and ram.
        """

        try:
            service_ref = db.service_get_all_compute_by_host(ctxt, host)[0]
        except exception.NotFound:
            raise exception.ComputeServiceUnavailable(host=host)

        # Updating host information
        dic = {'vcpus': 1,
               'memory_mb': 4096,
               'local_gb': 1028,
               'vcpus_used': 0,
               'memory_mb_used': 0,
               'local_gb_used': 0,
               'hypervisor_type': 'fake',
               'hypervisor_version': '1.0',
                  'service_id': service_ref['id'],
                 'cpu_info': '?'}

        compute_node_ref = service_ref['compute_node']
        if not compute_node_ref:
            LOG.info(_('Compute_service record created for %s ') % host)
            db.compute_node_create(ctxt, dic)
        else:
            LOG.info(_('Compute_service record updated for %s ') % host)
            db.compute_node_update(ctxt, compute_node_ref[0]['id'], dic)
开发者ID:kopertop,项目名称:nova,代码行数:31,代码来源:fake.py

示例5: update_available_resource

    def update_available_resource(self, ctxt, host):
        """Updates compute manager resource info on ComputeNode table.

           Since we don't have a real hypervisor, pretend we have lots of
           disk and ram.
        """

        try:
            service_ref = db.service_get_all_compute_by_host(ctxt, host)[0]
        except exception.NotFound:
            raise exception.ComputeServiceUnavailable(host=host)

        # Updating host information
        dic = {
            "vcpus": 1,
            "memory_mb": 4096,
            "local_gb": 1028,
            "vcpus_used": 0,
            "memory_mb_used": 0,
            "local_gb_used": 0,
            "hypervisor_type": "fake",
            "hypervisor_version": "1.0",
            "service_id": service_ref["id"],
            "cpu_info": "?",
        }

        compute_node_ref = service_ref["compute_node"]
        if not compute_node_ref:
            LOG.info(_("Compute_service record created for %s ") % host)
            db.compute_node_create(ctxt, dic)
        else:
            LOG.info(_("Compute_service record updated for %s ") % host)
            db.compute_node_update(ctxt, compute_node_ref[0]["id"], dic)
开发者ID:erictchiu,项目名称:nova,代码行数:33,代码来源:fake.py

示例6: update_available_resource

    def update_available_resource(self, ctxt, host):
        """Updates compute manager resource info on ComputeNode table.

        This method is called when nova-coompute launches, and
        whenever admin executes "nova-manage service update_resource".

        :param ctxt: security context
        :param host: hostname that compute manager is currently running

        """

        dic = self._max_phy_resouces(ctxt)
        #dic = self._sum_phy_hosts(ctxt)
        dic['hypervisor_type'] = 'physical'
        dic['hypervisor_version'] = 1
        dic['cpu_info'] = 'physical cpu'
        
        try:
            service_ref = db.service_get_all_compute_by_host(ctxt, host)[0]
        except exception.NotFound:
            raise exception.ComputeServiceUnavailable(host=host)

        dic['service_id'] = service_ref['id']

        compute_node_ref = service_ref['compute_node']
        if not compute_node_ref:
            LOG.info(_('Compute_service record created for %s ') % host)
            db.compute_node_create(ctxt, dic)
        else:
            LOG.info(_('Compute_service record updated for %s ') % host)
            db.compute_node_update(ctxt, compute_node_ref[0]['id'], dic)
开发者ID:jeffreycoho,项目名称:nova-folsom-201204271932,代码行数:31,代码来源:driver.py

示例7: test_compute_node_create

 def test_compute_node_create(self):
     self.mox.StubOutWithMock(db, 'compute_node_create')
     db.compute_node_create(self.context, 'fake-values').AndReturn(
         'fake-result')
     self.mox.ReplayAll()
     result = self.conductor.compute_node_create(self.context,
                                                 'fake-values')
     self.assertEqual(result, 'fake-result')
开发者ID:gminator,项目名称:nova,代码行数:8,代码来源:test_conductor.py

示例8: test_recreate_fails

 def test_recreate_fails(self):
     self.mox.StubOutWithMock(db, "compute_node_create")
     db.compute_node_create(self.context, {"service_id": 456}).AndReturn(fake_compute_node)
     self.mox.ReplayAll()
     compute = compute_node.ComputeNode(context=self.context)
     compute.service_id = 456
     compute.create()
     self.assertRaises(exception.ObjectActionError, compute.create, self.context)
开发者ID:mathslinux,项目名称:nova,代码行数:8,代码来源:test_compute_node.py

示例9: test_create

 def test_create(self):
     self.mox.StubOutWithMock(db, 'compute_node_create')
     db.compute_node_create(self.context, {'service_id': 456}).AndReturn(
         fake_compute_node)
     self.mox.ReplayAll()
     compute = compute_node.ComputeNode()
     compute.service_id = 456
     compute.create(self.context)
     self.compare_obj(compute, fake_compute_node)
开发者ID:674009287,项目名称:nova,代码行数:9,代码来源:test_compute_node.py

示例10: test_recreate_fails

 def test_recreate_fails(self, mock_get):
     self.mox.StubOutWithMock(db, 'compute_node_create')
     db.compute_node_create(
         self.context, {'service_id': 456,
                        'uuid': uuidsentinel.fake_compute_node}).AndReturn(
         fake_compute_node)
     self.mox.ReplayAll()
     compute = compute_node.ComputeNode(context=self.context)
     compute.service_id = 456
     compute.uuid = uuidsentinel.fake_compute_node
     compute.create()
     self.assertRaises(exception.ObjectActionError, compute.create)
开发者ID:binarycode,项目名称:nova,代码行数:12,代码来源:test_compute_node.py

示例11: test_query_allocates_uuid

 def test_query_allocates_uuid(self):
     fake = dict(fake_compute_node)
     fake.pop('uuid')
     db.compute_node_create(self.context, fake)
     with mock.patch('oslo_utils.uuidutils.generate_uuid') as mock_gu:
         mock_gu.return_value = uuidsentinel.fake_compute_node
         obj = objects.ComputeNode.get_by_id(self.context, fake['id'])
         mock_gu.assert_called_once_with()
         self.assertEqual(uuidsentinel.fake_compute_node, obj.uuid)
         self.assertNotIn('uuid', obj.obj_get_changes())
     with mock.patch('oslo_utils.uuidutils.generate_uuid') as mock_gu:
         obj = objects.ComputeNode.get_by_id(self.context, fake['id'])
         self.assertEqual(uuidsentinel.fake_compute_node, obj.uuid)
         self.assertFalse(mock_gu.called)
开发者ID:JioCloudCompute,项目名称:nova,代码行数:14,代码来源:test_compute_node.py

示例12: test_create

 def test_create(self):
     self.mox.StubOutWithMock(db, 'compute_node_create')
     db.compute_node_create(
         self.context,
         {
             'service_id': 456,
             'stats': fake_stats_db_format
         }).AndReturn(fake_compute_node)
     self.mox.ReplayAll()
     compute = compute_node.ComputeNode()
     compute.service_id = 456
     compute.stats = fake_stats
     compute.create(self.context)
     self.compare_obj(compute, fake_compute_node,
                      comparators={'stats': self.json_comparator})
开发者ID:B-Rich,项目名称:nova-1,代码行数:15,代码来源:test_compute_node.py

示例13: _create_compute_service

    def _create_compute_service(self):
        """Create compute-manager(ComputeNode and Service record)."""
        ctxt = context.get_admin_context()
        dic = {'host': 'dummy', 'binary': 'nova-compute', 'topic': 'compute',
               'report_count': 0, 'availability_zone': 'dummyzone'}
        s_ref = db.service_create(ctxt, dic)

        dic = {'service_id': s_ref['id'],
               'vcpus': 16, 'memory_mb': 32, 'local_gb': 100,
               'vcpus_used': 16, 'memory_mb_used': 32, 'local_gb_used': 10,
               'hypervisor_type': 'qemu', 'hypervisor_version': 12003,
               'cpu_info': '', 'stats': {}}
        db.compute_node_create(ctxt, dic)

        return db.service_get(ctxt, s_ref['id'])
开发者ID:gajen,项目名称:nova,代码行数:15,代码来源:test_hosts.py

示例14: create

    def create(self):
        if self.obj_attr_is_set('id'):
            raise exception.ObjectActionError(action='create',
                                              reason='already created')
        updates = self.obj_get_changes()
        if 'uuid' not in updates:
            updates['uuid'] = uuidutils.generate_uuid()
            self.uuid = updates['uuid']

        self._convert_stats_to_db_format(updates)
        self._convert_host_ip_to_db_format(updates)
        self._convert_supported_instances_to_db_format(updates)
        self._convert_pci_stats_to_db_format(updates)

        if self._should_manage_inventory():
            self._create_inventory(updates)

        db_compute = db.compute_node_create(self._context, updates)
        # NOTE(danms): compute_node_create() operates on (and returns) the
        # compute node model only. We need to get the full inventory-based
        # result in order to satisfy _from_db_object(). So, we do a double
        # query here. This can be removed in Newton once we're sure that all
        # compute nodes are inventory-based
        db_compute = db.compute_node_get(self._context, db_compute['id'])
        self._from_db_object(self._context, self, db_compute)
开发者ID:BeyondTheClouds,项目名称:nova,代码行数:25,代码来源:compute_node.py

示例15: update_available_resource

    def update_available_resource(self, ctxt, host):
        """Updates compute manager resource info on ComputeNode table.

        This method is called when nova-coompute launches, and
        whenever admin executes "nova-manage service update_resource".

        :param ctxt: security context
        :param host: hostname that compute manager is currently running

        """

        try:
            service_ref = db.service_get_all_compute_by_host(ctxt, host)[0]
        except exception.NotFound:
            raise exception.ComputeServiceUnavailable(host=host)

        # Updating host information
        dic = {
            "vcpus": self.get_vcpu_total(),
            "memory_mb": self.get_memory_mb_total(),
            "local_gb": self.get_local_gb_total(),
            "vcpus_used": self.get_vcpu_used(),
            "memory_mb_used": self.get_memory_mb_used(),
            "local_gb_used": self.get_local_gb_used(),
            "hypervisor_type": self.get_hypervisor_type(),
            "hypervisor_version": self.get_hypervisor_version(),
            "cpu_info": self.get_cpu_info(),
            "cpu_arch": FLAGS.cpu_arch,
            "xpu_arch": FLAGS.xpu_arch,
            "xpus": FLAGS.xpus,
            "xpu_info": FLAGS.xpu_info,
            "net_arch": FLAGS.net_arch,
            "net_info": FLAGS.net_info,
            "net_mbps": FLAGS.net_mbps,
            "service_id": service_ref["id"],
        }

        compute_node_ref = service_ref["compute_node"]
        LOG.info(_("#### RLK: cpu_arch = %s ") % FLAGS.cpu_arch)
        if not compute_node_ref:
            LOG.info(_("Compute_service record created for %s ") % host)
            dic["service_id"] = service_ref["id"]
            db.compute_node_create(ctxt, dic)
        else:
            LOG.info(_("Compute_service record updated for %s ") % host)
            db.compute_node_update(ctxt, compute_node_ref[0]["id"], dic)
开发者ID:OpenStack-Kha,项目名称:nova,代码行数:46,代码来源:proxy.py


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