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

Python db.aggregate_metadata_get函数代码示例

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

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



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

示例1: test_aggregate_create_delete_create_with_metadata

 def test_aggregate_create_delete_create_with_metadata(self):
     """Ensure aggregate metadata is deleted bug 1052479."""
     ctxt = context.get_admin_context()
     result = _create_aggregate(context=ctxt)
     expected_metadata = db.aggregate_metadata_get(ctxt, result['id'])
     self.assertDictMatch(expected_metadata, _get_fake_aggr_metadata())
     db.aggregate_delete(ctxt, result['id'])
     result = _create_aggregate(metadata=None)
     expected_metadata = db.aggregate_metadata_get(ctxt, result['id'])
     self.assertEqual(expected_metadata, {})
开发者ID:hadib,项目名称:nova,代码行数:10,代码来源:test_db_api.py


示例2: remove_from_aggregate

    def remove_from_aggregate(self, context, aggregate, host, **kwargs):
        """Remove a compute host from an aggregate."""
        if not pool_states.is_hv_pool(context, aggregate.id):
            return

        invalid = {pool_states.CREATED: 'no hosts to remove',
                   pool_states.CHANGING: 'setup in progress',
                   pool_states.DISMISSED: 'aggregate deleted', }
        if (db.aggregate_metadata_get(context, aggregate.id)[pool_states.KEY]
                in invalid.keys()):
            raise exception.InvalidAggregateAction(
                    action='remove host',
                    aggregate_id=aggregate.id,
                    reason=invalid[db.aggregate_metadata_get(context,
                            aggregate.id)[pool_states.KEY]])

        master_compute = db.aggregate_metadata_get(context,
                aggregate.id)['master_compute']
        if master_compute == FLAGS.host and master_compute != host:
            # this is the master -> instruct it to eject a host from the pool
            host_uuid = db.aggregate_metadata_get(context, aggregate.id)[host]
            self._eject_slave(aggregate.id,
                              kwargs.get('compute_uuid'), host_uuid)
            db.aggregate_metadata_delete(context, aggregate.id, host)
        elif master_compute == host:
            # Remove master from its own pool -> destroy pool only if the
            # master is on its own, otherwise raise fault. Destroying a
            # pool made only by master is fictional
            if len(aggregate.hosts) > 1:
                # NOTE: this could be avoided by doing a master
                # re-election, but this is simpler for now.
                raise exception.InvalidAggregateAction(
                                    aggregate_id=aggregate.id,
                                    action='remove_from_aggregate',
                                    reason=_('Unable to eject %(host)s '
                                             'from the pool; pool not empty')
                                             % locals())
            self._clear_pool(aggregate.id)
            for key in ['master_compute', host]:
                db.aggregate_metadata_delete(context, aggregate.id, key)
        elif master_compute and master_compute != host:
            # A master exists -> forward pool-eject request to master
            forward_request(context, "remove_aggregate_host", master_compute,
                            aggregate.id, host,
                            self._host_addr, self._host_uuid)
        else:
            # this shouldn't have happened
            raise exception.AggregateError(aggregate_id=aggregate.id,
                                           action='remove_from_aggregate',
                                           reason=_('Unable to eject %(host)s '
                                           'from the pool; No master found')
                                           % locals())
开发者ID:aantonov,项目名称:nova,代码行数:52,代码来源:pool.py


示例3: add_to_aggregate

    def add_to_aggregate(self, context, aggregate, host, **kwargs):
        """Add a compute host to an aggregate."""
        if not pool_states.is_hv_pool(context, aggregate.id):
            return

        invalid = {pool_states.CHANGING: 'setup in progress',
                   pool_states.DISMISSED: 'aggregate deleted',
                   pool_states.ERROR: 'aggregate in error'}

        if (db.aggregate_metadata_get(context, aggregate.id)[pool_states.KEY]
                in invalid.keys()):
            raise exception.InvalidAggregateAction(
                    action='add host',
                    aggregate_id=aggregate.id,
                    reason=invalid[db.aggregate_metadata_get(context,
                            aggregate.id)
                    [pool_states.KEY]])

        if (db.aggregate_metadata_get(context, aggregate.id)[pool_states.KEY]
                == pool_states.CREATED):
            db.aggregate_metadata_add(context, aggregate.id,
                    {pool_states.KEY: pool_states.CHANGING})
        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
            metadata = {'master_compute': host,
                        host: self._host_uuid,
                        pool_states.KEY: pool_states.ACTIVE}
            db.aggregate_metadata_add(context, aggregate.id, metadata)
        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 = db.aggregate_metadata_get(context,
                    aggregate.id)['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:aantonov,项目名称:nova,代码行数:51,代码来源:pool.py


示例4: test_aggregate_create_with_metadata

 def test_aggregate_create_with_metadata(self):
     """Ensure aggregate can be created with metadata."""
     ctxt = context.get_admin_context()
     result = _create_aggregate(context=ctxt)
     expected_metadata = db.aggregate_metadata_get(ctxt, result['id'])
     self.assertThat(expected_metadata,
                     matchers.DictMatches(_get_fake_aggr_metadata()))
开发者ID:mapleoin,项目名称:nova,代码行数:7,代码来源:test_db_api.py


示例5: test_aggregate_metadata_add

 def test_aggregate_metadata_add(self):
     """Ensure we can add metadata for the aggregate."""
     ctxt = context.get_admin_context()
     result = _create_aggregate(context=ctxt, metadata=None)
     metadata = _get_fake_aggr_metadata()
     db.aggregate_metadata_add(ctxt, result.id, metadata)
     expected = db.aggregate_metadata_get(ctxt, result.id)
     self.assertDictMatch(metadata, expected)
开发者ID:matiu2,项目名称:nova,代码行数:8,代码来源:test_db_api.py


示例6: 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


示例7: 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


示例8: test_aggregate_metadata_delete

 def test_aggregate_metadata_delete(self):
     """Ensure we can delete metadata for the aggregate."""
     ctxt = context.get_admin_context()
     result = _create_aggregate(context=ctxt, metadata=None)
     metadata = _get_fake_aggr_metadata()
     db.aggregate_metadata_add(ctxt, result.id, metadata)
     db.aggregate_metadata_delete(ctxt, result.id, metadata.keys()[0])
     expected = db.aggregate_metadata_get(ctxt, result.id)
     del metadata[metadata.keys()[0]]
     self.assertThat(metadata, matchers.DictMatches(expected))
开发者ID:mapleoin,项目名称:nova,代码行数:10,代码来源:test_db_api.py


示例9: test_aggregate_metadata_update

 def test_aggregate_metadata_update(self):
     """Ensure we can update metadata for the aggregate."""
     ctxt = context.get_admin_context()
     result = _create_aggregate(context=ctxt)
     metadata = _get_fake_aggr_metadata()
     key = metadata.keys()[0]
     db.aggregate_metadata_delete(ctxt, result.id, key)
     new_metadata = {key: 'foo'}
     db.aggregate_metadata_add(ctxt, result.id, new_metadata)
     expected = db.aggregate_metadata_get(ctxt, result.id)
     metadata[key] = 'foo'
     self.assertDictMatch(metadata, expected)
开发者ID:matiu2,项目名称:nova,代码行数:12,代码来源:test_db_api.py


示例10: aggregate_metadata_get

 def aggregate_metadata_get(self, context, aggregate_id):
     return db.aggregate_metadata_get(context, aggregate_id)
开发者ID:gajen,项目名称:nova,代码行数:2,代码来源:fake.py


示例11: _is_hv_pool

 def _is_hv_pool(self, context, aggregate_id):
     """Checks if aggregate is a hypervisor_pool"""
     metadata = db.aggregate_metadata_get(context, aggregate_id)
     return pool_states.POOL_FLAG in metadata.keys()
开发者ID:SimiPro,项目名称:nova,代码行数:4,代码来源:pool.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python db.aggregate_metadata_get_by_host函数代码示例发布时间:2022-05-27
下一篇:
Python db.aggregate_metadata_delete函数代码示例发布时间: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