• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python db.aggregate_update函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: add_to_aggregate

 def add_to_aggregate(self, context, aggregate, host, **kwargs):
     """Add a compute host to an aggregate."""
     if len(aggregate.hosts) == 1:
         # this is the first host of the pool -> make it master
         self._init_pool(aggregate.id, aggregate.name)
         # save metadata so that we can find the master again
         values = {
             'operational_state': aggregate_states.ACTIVE,
             'metadata': {'master_compute': host,
                          host: self._host_uuid},
             }
         db.aggregate_update(context, aggregate.id, values)
     else:
         # the pool is already up and running, we need to figure out
         # whether we can serve the request from this host or not.
         master_compute = aggregate.metadetails['master_compute']
         if master_compute == FLAGS.host and master_compute != host:
             # this is the master ->  do a pool-join
             # To this aim, nova compute on the slave has to go down.
             # NOTE: it is assumed that ONLY nova compute is running now
             self._join_slave(aggregate.id, host,
                              kwargs.get('compute_uuid'),
                              kwargs.get('url'), kwargs.get('user'),
                              kwargs.get('passwd'))
             metadata = {host: kwargs.get('xenhost_uuid'), }
             db.aggregate_metadata_add(context, aggregate.id, metadata)
         elif master_compute and master_compute != host:
             # send rpc cast to master, asking to add the following
             # host with specified credentials.
             forward_request(context, "add_aggregate_host", master_compute,
                             aggregate.id, host,
                             self._host_addr, self._host_uuid)
开发者ID:MirantisDellCrowbar,项目名称:nova,代码行数:32,代码来源:pool.py


示例2: test_aggregate_update_with_metadata

 def test_aggregate_update_with_metadata(self):
     """Ensure an aggregate can be updated with metadata."""
     ctxt = context.get_admin_context()
     result = _create_aggregate(context=ctxt, metadata=None)
     values = _get_fake_aggr_values()
     values['metadata'] = _get_fake_aggr_metadata()
     db.aggregate_update(ctxt, 1, values)
     expected = db.aggregate_metadata_get(ctxt, result.id)
     self.assertDictMatch(_get_fake_aggr_metadata(), expected)
开发者ID:matiu2,项目名称:nova,代码行数:9,代码来源:test_db_api.py


示例3: test_save

 def test_save(self):
     self.mox.StubOutWithMock(db, "aggregate_update")
     db.aggregate_update(self.context, 123, {"name": "baz"}).AndReturn(fake_aggregate)
     self.mox.ReplayAll()
     agg = aggregate.Aggregate(context=self.context)
     agg.id = 123
     agg.name = "baz"
     agg.save()
     self.compare_obj(agg, fake_aggregate, subs=SUBS)
开发者ID:wenlongwljs,项目名称:nova,代码行数:9,代码来源:test_aggregate.py


示例4: test_aggregate_update_with_existing_metadata

 def test_aggregate_update_with_existing_metadata(self):
     """Ensure an aggregate can be updated with existing metadata."""
     ctxt = context.get_admin_context()
     result = _create_aggregate(context=ctxt)
     values = _get_fake_aggr_values()
     values['metadata'] = _get_fake_aggr_metadata()
     values['metadata']['fake_key1'] = 'foo'
     db.aggregate_update(ctxt, 1, values)
     expected = db.aggregate_metadata_get(ctxt, result.id)
     self.assertDictMatch(values['metadata'], expected)
开发者ID:matiu2,项目名称:nova,代码行数:10,代码来源:test_db_api.py


示例5: test_save

 def test_save(self):
     self.mox.StubOutWithMock(db, 'aggregate_update')
     db.aggregate_update(self.context, 123, {'name': 'baz'}).AndReturn(
         fake_aggregate)
     self.mox.ReplayAll()
     agg = aggregate.Aggregate()
     agg.id = 123
     agg.name = 'baz'
     agg.save(self.context)
     self.compare_obj(agg, fake_aggregate, subs=SUBS)
开发者ID:CrazyTeaFs,项目名称:nova,代码行数:10,代码来源:test_aggregate.py


示例6: test_aggregate_update

 def test_aggregate_update(self):
     """Ensure an aggregate can be updated."""
     ctxt = context.get_admin_context()
     result = _create_aggregate(context=ctxt, metadata=None)
     new_values = _get_fake_aggr_values()
     new_values["availability_zone"] = "different_avail_zone"
     updated = db.aggregate_update(ctxt, 1, new_values)
     self.assertNotEqual(result.availability_zone, updated.availability_zone)
开发者ID:hiteshwadekar,项目名称:nova,代码行数:8,代码来源:test_db_api.py


示例7: save

    def save(self, context):
        self._assert_no_hosts("save")
        updates = self.obj_get_changes()

        payload = {"aggregate_id": self.id}
        if "metadata" in updates:
            payload["meta_data"] = updates["metadata"]
        compute_utils.notify_about_aggregate_update(context, "updateprop.start", payload)
        updates.pop("id", None)
        db_aggregate = db.aggregate_update(context, self.id, updates)
        compute_utils.notify_about_aggregate_update(context, "updateprop.end", payload)
        return self._from_db_object(context, self, db_aggregate)
开发者ID:gilmeir,项目名称:nova,代码行数:12,代码来源:aggregate.py


示例8: save

    def save(self, context):
        self._assert_no_hosts('save')
        updates = self.obj_get_changes()

        payload = {'aggregate_id': self.id}
        if 'metadata' in updates:
            payload['meta_data'] = updates['metadata']
        compute_utils.notify_about_aggregate_update(context,
                                                    "updateprop.start",
                                                    payload)
        updates.pop('id', None)
        db_aggregate = db.aggregate_update(context, self.id, updates)
        compute_utils.notify_about_aggregate_update(context,
                                                    "updateprop.end",
                                                    payload)
        return self._from_db_object(context, self, db_aggregate)
开发者ID:B-Rich,项目名称:nova-1,代码行数:16,代码来源:aggregate.py


示例9: save

    def save(self):
        self._assert_no_hosts('save')
        updates = self.obj_get_changes()

        payload = {'aggregate_id': self.id}
        if 'metadata' in updates:
            payload['meta_data'] = updates['metadata']
        compute_utils.notify_about_aggregate_update(self._context,
                                                    "updateprop.start",
                                                    payload)
        updates.pop('id', None)
        try:
            db_aggregate = _aggregate_update_to_db(self._context,
                                                   self.id, updates)
        except exception.AggregateNotFound:
            db_aggregate = db.aggregate_update(self._context, self.id, updates)

        compute_utils.notify_about_aggregate_update(self._context,
                                                    "updateprop.end",
                                                    payload)
        self._from_db_object(self._context, self, db_aggregate)
开发者ID:4everming,项目名称:nova,代码行数:21,代码来源:aggregate.py


示例10: _update_az

 def _update_az(self, aggregate, az_name):
     metadata = {'availability_zone': az_name}
     db.aggregate_update(self.context, aggregate['id'], metadata)
开发者ID:Juniper,项目名称:nova,代码行数:3,代码来源:test_availability_zones.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python db.block_device_mapping_create函数代码示例发布时间:2022-05-27
下一篇:
Python db.aggregate_metadata_get_by_host函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap