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

Python utils.notify_about_aggregate_update函数代码示例

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

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



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

示例1: create

    def create(self):
        if self.obj_attr_is_set('id'):
            raise exception.ObjectActionError(action='create',
                                              reason='already created')

        # NOTE(mdoff): Once we have made it past a point where we know
        # all aggregates have been migrated, we can remove this. Ideally
        # in Ocata with a blocker migration to be sure.
        if not self._ensure_migrated(self._context):
            raise exception.ObjectActionError(
                action='create',
                reason='main database still contains aggregates')

        self._assert_no_hosts('create')
        updates = self.obj_get_changes()
        payload = dict(updates)
        if 'metadata' in updates:
            # NOTE(danms): For some reason the notification format is weird
            payload['meta_data'] = payload.pop('metadata')
        if 'uuid' not in updates:
            updates['uuid'] = uuidutils.generate_uuid()
            LOG.debug('Generated uuid %(uuid)s for aggregate',
                      dict(uuid=updates['uuid']))
        compute_utils.notify_about_aggregate_update(self._context,
                                                    "create.start",
                                                    payload)
        metadata = updates.pop('metadata', None)
        db_aggregate = _aggregate_create_in_db(self._context, updates,
                                               metadata=metadata)
        self._from_db_object(self._context, self, db_aggregate)
        payload['aggregate_id'] = self.id
        compute_utils.notify_about_aggregate_update(self._context,
                                                    "create.end",
                                                    payload)
开发者ID:4everming,项目名称:nova,代码行数:34,代码来源:aggregate.py


示例2: test_notify_about_aggregate_update_without_name_id

 def test_notify_about_aggregate_update_without_name_id(self):
     # Set empty aggregate payload
     aggregate_payload = {}
     compute_utils.notify_about_aggregate_update(self.context,
                                                 "create.start",
                                                 aggregate_payload)
     self.assertEqual(len(fake_notifier.NOTIFICATIONS), 0)
开发者ID:ewindisch,项目名称:nova,代码行数:7,代码来源:test_compute_utils.py


示例3: update_metadata

 def update_metadata(self, context, updates):
     payload = {'aggregate_id': self.id,
                'meta_data': updates}
     compute_utils.notify_about_aggregate_update(context,
                                                 "updatemetadata.start",
                                                 payload)
     to_add = {}
     for key, value in updates.items():
         if value is None:
             try:
                 db.aggregate_metadata_delete(context, self.id, key)
             except exception.AggregateMetadataNotFound:
                 pass
             try:
                 self.metadata.pop(key)
             except KeyError:
                 pass
         else:
             to_add[key] = value
             self.metadata[key] = value
     db.aggregate_metadata_add(context, self.id, to_add)
     compute_utils.notify_about_aggregate_update(context,
                                                 "updatemetadata.end",
                                                 payload)
     self.obj_reset_changes(fields=['metadata'])
开发者ID:B-Rich,项目名称:nova-1,代码行数:25,代码来源:aggregate.py


示例4: create

 def create(self):
     if self.obj_attr_is_set('id'):
         raise exception.ObjectActionError(action='create',
                                           reason='already created')
     self._assert_no_hosts('create')
     updates = self.obj_get_changes()
     payload = dict(updates)
     if 'metadata' in updates:
         # NOTE(danms): For some reason the notification format is weird
         payload['meta_data'] = payload.pop('metadata')
     if 'uuid' not in updates:
         updates['uuid'] = uuidutils.generate_uuid()
         LOG.debug('Generated uuid %(uuid)s for aggregate',
                   dict(uuid=updates['uuid']))
     compute_utils.notify_about_aggregate_update(self._context,
                                                 "create.start",
                                                 payload)
     metadata = updates.pop('metadata', None)
     db_aggregate = db.aggregate_create(self._context, updates,
                                        metadata=metadata)
     self._from_db_object(self._context, self, db_aggregate)
     payload['aggregate_id'] = self.id
     compute_utils.notify_about_aggregate_update(self._context,
                                                 "create.end",
                                                 payload)
开发者ID:unicell,项目名称:nova,代码行数:25,代码来源:aggregate.py


示例5: update_metadata

 def update_metadata(self, updates):
     payload = {'aggregate_id': self.id,
                'meta_data': updates}
     compute_utils.notify_about_aggregate_update(self._context,
                                                 "updatemetadata.start",
                                                 payload)
     compute_utils.notify_about_aggregate_action(
         context=self._context,
         aggregate=self,
         action=fields.NotificationAction.UPDATE_METADATA,
         phase=fields.NotificationPhase.START)
     to_add = {}
     for key, value in updates.items():
         if value is None:
             try:
                 _metadata_delete_from_db(self._context, self.id, key)
             except exception.AggregateMetadataNotFound:
                 pass
             try:
                 self.metadata.pop(key)
             except KeyError:
                 pass
         else:
             to_add[key] = value
             self.metadata[key] = value
     _metadata_add_to_db(self._context, self.id, to_add)
     compute_utils.notify_about_aggregate_update(self._context,
                                                 "updatemetadata.end",
                                                 payload)
     compute_utils.notify_about_aggregate_action(
         context=self._context,
         aggregate=self,
         action=fields.NotificationAction.UPDATE_METADATA,
         phase=fields.NotificationPhase.END)
     self.obj_reset_changes(fields=['metadata'])
开发者ID:arbrandes,项目名称:nova,代码行数:35,代码来源:aggregate.py


示例6: 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)
        compute_utils.notify_about_aggregate_action(
            context=self._context,
            aggregate=self,
            action=fields.NotificationAction.UPDATE_PROP,
            phase=fields.NotificationPhase.START)
        updates.pop('id', None)
        db_aggregate = _aggregate_update_to_db(self._context,
                                               self.id, updates)
        compute_utils.notify_about_aggregate_update(self._context,
                                                    "updateprop.end",
                                                    payload)
        compute_utils.notify_about_aggregate_action(
            context=self._context,
            aggregate=self,
            action=fields.NotificationAction.UPDATE_PROP,
            phase=fields.NotificationPhase.END)
        self._from_db_object(self._context, self, db_aggregate)
开发者ID:arbrandes,项目名称:nova,代码行数:27,代码来源:aggregate.py


示例7: test_notify_about_aggregate_update_with_name

 def test_notify_about_aggregate_update_with_name(self):
     # Set aggregate payload
     aggregate_payload = {"name": "fakegroup"}
     compute_utils.notify_about_aggregate_update(self.context, "create.start", aggregate_payload)
     self.assertEqual(len(fake_notifier.NOTIFICATIONS), 1)
     msg = fake_notifier.NOTIFICATIONS[0]
     self.assertEqual(msg.priority, "INFO")
     self.assertEqual(msg.event_type, "aggregate.create.start")
     payload = msg.payload
     self.assertEqual(payload["name"], "fakegroup")
开发者ID:jorgevgut,项目名称:nova,代码行数:10,代码来源:test_compute_utils.py


示例8: test_notify_about_aggregate_update_with_id

 def test_notify_about_aggregate_update_with_id(self):
     # Set aggregate payload
     aggregate_payload = {"aggregate_id": 1}
     compute_utils.notify_about_aggregate_update(self.context, "create.end", aggregate_payload)
     self.assertEqual(len(fake_notifier.NOTIFICATIONS), 1)
     msg = fake_notifier.NOTIFICATIONS[0]
     self.assertEqual(msg.priority, "INFO")
     self.assertEqual(msg.event_type, "aggregate.create.end")
     payload = msg.payload
     self.assertEqual(payload["aggregate_id"], 1)
开发者ID:jorgevgut,项目名称:nova,代码行数:10,代码来源:test_compute_utils.py


示例9: test_notify_about_aggregate_update_with_name

 def test_notify_about_aggregate_update_with_name(self):
     # Set aggregate payload
     aggregate_payload = {'name': 'fakegroup'}
     compute_utils.notify_about_aggregate_update(self.context,
                                                 "create.start",
                                                 aggregate_payload)
     self.assertEqual(len(fake_notifier.NOTIFICATIONS), 1)
     msg = fake_notifier.NOTIFICATIONS[0]
     self.assertEqual(msg.priority, 'INFO')
     self.assertEqual(msg.event_type, 'aggregate.create.start')
     payload = msg.payload
     self.assertEqual(payload['name'], 'fakegroup')
开发者ID:ewindisch,项目名称:nova,代码行数:12,代码来源:test_compute_utils.py


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


示例11: test_notify_about_aggregate_update_with_id

 def test_notify_about_aggregate_update_with_id(self):
     # Set aggregate payload
     aggregate_payload = {'aggregate_id': 1}
     compute_utils.notify_about_aggregate_update(self.context,
                                                 "create.end",
                                                 aggregate_payload)
     self.assertEquals(len(fake_notifier.NOTIFICATIONS), 1)
     msg = fake_notifier.NOTIFICATIONS[0]
     self.assertEquals(msg.priority, 'INFO')
     self.assertEquals(msg.event_type, 'aggregate.create.end')
     payload = msg.payload
     self.assertEquals(payload['aggregate_id'], 1)
开发者ID:prometheanfire,项目名称:nova,代码行数:12,代码来源:test_compute_utils.py


示例12: create

 def create(self, context):
     self._assert_no_hosts("create")
     updates = self.obj_get_changes()
     payload = dict(updates)
     if "metadata" in updates:
         # NOTE(danms): For some reason the notification format is weird
         payload["meta_data"] = payload.pop("metadata")
     compute_utils.notify_about_aggregate_update(context, "create.start", payload)
     metadata = updates.pop("metadata", None)
     db_aggregate = db.aggregate_create(context, updates, metadata=metadata)
     self._from_db_object(context, self, db_aggregate)
     payload["aggregate_id"] = self.id
     compute_utils.notify_about_aggregate_update(context, "create.end", payload)
开发者ID:ubuntuserver,项目名称:nova,代码行数:13,代码来源:aggregate.py


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


示例14: create

 def create(self, context):
     self._assert_no_hosts('create')
     updates = {}
     for key in self.obj_what_changed():
         updates[key] = self[key]
     payload = dict(updates)
     if 'metadata' in updates:
         # NOTE(danms): For some reason the notification format is weird
         payload['meta_data'] = payload.pop('metadata')
     compute_utils.notify_about_aggregate_update(context,
                                                 "create.start",
                                                 payload)
     metadata = updates.pop('metadata', None)
     db_aggregate = db.aggregate_create(context, updates, metadata=metadata)
     self._from_db_object(context, self, db_aggregate)
     payload['aggregate_id'] = self.id
     compute_utils.notify_about_aggregate_update(context,
                                                 "create.end",
                                                 payload)
开发者ID:prometheanfire,项目名称:nova,代码行数:19,代码来源:aggregate.py


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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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