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


Python utils.notify_usage_exists函数代码示例

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


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

示例1: notify_usage_exists

 def notify_usage_exists(self, context, instance, current_period,
                         ignore_missing_network_data,
                         system_metadata, extra_usage_info):
     compute_utils.notify_usage_exists(self.notifier, context, instance,
                                       current_period,
                                       ignore_missing_network_data,
                                       system_metadata, extra_usage_info)
开发者ID:VinceOnGit,项目名称:nova,代码行数:7,代码来源:manager.py

示例2: test_notify_usage_exists_instance_not_found

 def test_notify_usage_exists_instance_not_found(self):
     # Ensure 'exists' notification generates appropriate usage data.
     instance_id = self._create_instance()
     instance = instance_obj.Instance.get_by_id(self.context, instance_id,
             expected_attrs=['metadata', 'system_metadata', 'info_cache'])
     self.compute.terminate_instance(self.context, instance, [], [])
     compute_utils.notify_usage_exists(
         rpc.get_notifier('compute'), self.context, instance)
     msg = fake_notifier.NOTIFICATIONS[-1]
     self.assertEqual(msg.priority, 'INFO')
     self.assertEqual(msg.event_type, 'compute.instance.exists')
     payload = msg.payload
     self.assertEqual(payload['tenant_id'], self.project_id)
     self.assertEqual(payload['user_id'], self.user_id)
     self.assertEqual(payload['instance_id'], instance['uuid'])
     self.assertEqual(payload['instance_type'], 'm1.tiny')
     type_id = flavors.get_flavor_by_name('m1.tiny')['id']
     self.assertEqual(str(payload['instance_type_id']), str(type_id))
     flavor_id = flavors.get_flavor_by_name('m1.tiny')['flavorid']
     self.assertEqual(str(payload['instance_flavor_id']), str(flavor_id))
     for attr in ('display_name', 'created_at', 'launched_at',
                  'state', 'state_description',
                  'bandwidth', 'audit_period_beginning',
                  'audit_period_ending', 'image_meta'):
         self.assertTrue(attr in payload,
                         msg="Key %s not in payload" % attr)
     self.assertEqual(payload['image_meta'], {})
     image_ref_url = "%s/images/1" % glance.generate_glance_url()
     self.assertEqual(payload['image_ref_url'], image_ref_url)
开发者ID:ewindisch,项目名称:nova,代码行数:29,代码来源:test_compute_utils.py

示例3: test_notify_usage_exists_instance_not_found

 def test_notify_usage_exists_instance_not_found(self):
     # Ensure 'exists' notification generates appropriate usage data.
     instance_id = self._create_instance()
     instance = db.instance_get(self.context, instance_id)
     self.compute.terminate_instance(self.context, instance)
     compute_utils.notify_usage_exists(self.context, instance)
     msg = test_notifier.NOTIFICATIONS[-1]
     self.assertEquals(msg['priority'], 'INFO')
     self.assertEquals(msg['event_type'], 'compute.instance.exists')
     payload = msg['payload']
     self.assertEquals(payload['tenant_id'], self.project_id)
     self.assertEquals(payload['user_id'], self.user_id)
     self.assertEquals(payload['instance_id'], instance['uuid'])
     self.assertEquals(payload['instance_type'], 'm1.tiny')
     type_id = instance_types.get_instance_type_by_name('m1.tiny')['id']
     self.assertEquals(str(payload['instance_type_id']), str(type_id))
     for attr in ('display_name', 'created_at', 'launched_at',
                  'state', 'state_description',
                  'bandwidth', 'audit_period_beginning',
                  'audit_period_ending', 'image_meta'):
         self.assertTrue(attr in payload,
                         msg="Key %s not in payload" % attr)
     self.assertEquals(payload['image_meta'], {})
     image_ref_url = "%s/images/1" % glance.generate_glance_url()
     self.assertEquals(payload['image_ref_url'], image_ref_url)
开发者ID:CiscoAS,项目名称:nova,代码行数:25,代码来源:test_compute_utils.py

示例4: test_notify_usage_exists_instance_not_found

 def test_notify_usage_exists_instance_not_found(self):
     # Ensure 'exists' notification generates appropriate usage data.
     instance = create_instance(self.context)
     self.compute.terminate_instance(self.context, instance, [], [])
     compute_utils.notify_usage_exists(rpc.get_notifier("compute"), self.context, instance)
     msg = fake_notifier.NOTIFICATIONS[-1]
     self.assertEqual(msg.priority, "INFO")
     self.assertEqual(msg.event_type, "compute.instance.exists")
     payload = msg.payload
     self.assertEqual(payload["tenant_id"], self.project_id)
     self.assertEqual(payload["user_id"], self.user_id)
     self.assertEqual(payload["instance_id"], instance["uuid"])
     self.assertEqual(payload["instance_type"], "m1.tiny")
     type_id = flavors.get_flavor_by_name("m1.tiny")["id"]
     self.assertEqual(str(payload["instance_type_id"]), str(type_id))
     flavor_id = flavors.get_flavor_by_name("m1.tiny")["flavorid"]
     self.assertEqual(str(payload["instance_flavor_id"]), str(flavor_id))
     for attr in (
         "display_name",
         "created_at",
         "launched_at",
         "state",
         "state_description",
         "bandwidth",
         "audit_period_beginning",
         "audit_period_ending",
         "image_meta",
     ):
         self.assertIn(attr, payload, "Key %s not in payload" % attr)
     self.assertEqual(payload["image_meta"], {})
     image_ref_url = "%s/images/1" % glance.generate_glance_url()
     self.assertEqual(payload["image_ref_url"], image_ref_url)
开发者ID:jorgevgut,项目名称:nova,代码行数:32,代码来源:test_compute_utils.py

示例5: test_notify_usage_exists_deleted_instance

 def test_notify_usage_exists_deleted_instance(self):
     # Ensure 'exists' notification generates appropriate usage data.
     instance_id = self._create_instance()
     instance = db.instance_get(self.context, instance_id)
     # Set some system metadata
     sys_metadata = {'image_md_key1': 'val1',
                     'image_md_key2': 'val2',
                     'other_data': 'meow'}
     db.instance_system_metadata_update(self.context, instance['uuid'],
             sys_metadata, False)
     self.compute.terminate_instance(self.context, instance)
     instance = db.instance_get(self.context.elevated(read_deleted='yes'),
                                instance_id)
     compute_utils.notify_usage_exists(self.context, instance)
     msg = test_notifier.NOTIFICATIONS[-1]
     self.assertEquals(msg['priority'], 'INFO')
     self.assertEquals(msg['event_type'], 'compute.instance.exists')
     payload = msg['payload']
     self.assertEquals(payload['tenant_id'], self.project_id)
     self.assertEquals(payload['user_id'], self.user_id)
     self.assertEquals(payload['instance_id'], instance['uuid'])
     self.assertEquals(payload['instance_type'], 'm1.tiny')
     type_id = instance_types.get_instance_type_by_name('m1.tiny')['id']
     self.assertEquals(str(payload['instance_type_id']), str(type_id))
     for attr in ('display_name', 'created_at', 'launched_at',
                  'state', 'state_description',
                  'bandwidth', 'audit_period_beginning',
                  'audit_period_ending', 'image_meta'):
         self.assertTrue(attr in payload,
                         msg="Key %s not in payload" % attr)
     self.assertEquals(payload['image_meta'],
             {'md_key1': 'val1', 'md_key2': 'val2'})
     image_ref_url = "%s/images/1" % glance.generate_glance_url()
     self.assertEquals(payload['image_ref_url'], image_ref_url)
开发者ID:CiscoAS,项目名称:nova,代码行数:34,代码来源:test_compute_utils.py

示例6: test_notify_usage_exists

 def test_notify_usage_exists(self):
     """Ensure 'exists' notification generates appropriate usage data."""
     instance_id = self._create_instance()
     instance = db.instance_get(self.context, instance_id)
     # Set some system metadata
     sys_metadata = {"image_md_key1": "val1", "image_md_key2": "val2", "other_data": "meow"}
     db.instance_system_metadata_update(self.context, instance["uuid"], sys_metadata, False)
     compute_utils.notify_usage_exists(self.context, instance)
     self.assertEquals(len(test_notifier.NOTIFICATIONS), 1)
     msg = test_notifier.NOTIFICATIONS[0]
     self.assertEquals(msg["priority"], "INFO")
     self.assertEquals(msg["event_type"], "compute.instance.exists")
     payload = msg["payload"]
     self.assertEquals(payload["tenant_id"], self.project_id)
     self.assertEquals(payload["user_id"], self.user_id)
     self.assertEquals(payload["instance_id"], instance.uuid)
     self.assertEquals(payload["instance_type"], "m1.tiny")
     type_id = instance_types.get_instance_type_by_name("m1.tiny")["id"]
     self.assertEquals(str(payload["instance_type_id"]), str(type_id))
     for attr in (
         "display_name",
         "created_at",
         "launched_at",
         "state",
         "state_description",
         "bandwidth",
         "audit_period_beginning",
         "audit_period_ending",
         "image_meta",
     ):
         self.assertTrue(attr in payload, msg="Key %s not in payload" % attr)
     self.assertEquals(payload["image_meta"], {"md_key1": "val1", "md_key2": "val2"})
     image_ref_url = "%s/images/1" % utils.generate_glance_url()
     self.assertEquals(payload["image_ref_url"], image_ref_url)
     self.compute.terminate_instance(self.context, instance["uuid"])
开发者ID:Nesrine85,项目名称:nova,代码行数:35,代码来源:test_compute_utils.py

示例7: test_notify_usage_exists_deleted_instance

 def test_notify_usage_exists_deleted_instance(self):
     # Ensure 'exists' notification generates appropriate usage data.
     instance = create_instance(self.context)
     # Set some system metadata
     sys_metadata = {'image_md_key1': 'val1',
                     'image_md_key2': 'val2',
                     'other_data': 'meow'}
     instance.system_metadata.update(sys_metadata)
     instance.save()
     self.compute.terminate_instance(self.context, instance, [], [])
     compute_utils.notify_usage_exists(
         rpc.get_notifier('compute'), self.context, instance)
     msg = fake_notifier.NOTIFICATIONS[-1]
     self.assertEqual(msg.priority, 'INFO')
     self.assertEqual(msg.event_type, 'compute.instance.exists')
     payload = msg.payload
     self.assertEqual(payload['tenant_id'], self.project_id)
     self.assertEqual(payload['user_id'], self.user_id)
     self.assertEqual(payload['instance_id'], instance['uuid'])
     self.assertEqual(payload['instance_type'], 'm1.tiny')
     type_id = flavors.get_flavor_by_name('m1.tiny')['id']
     self.assertEqual(str(payload['instance_type_id']), str(type_id))
     flavor_id = flavors.get_flavor_by_name('m1.tiny')['flavorid']
     self.assertEqual(str(payload['instance_flavor_id']), str(flavor_id))
     for attr in ('display_name', 'created_at', 'launched_at',
                  'state', 'state_description',
                  'bandwidth', 'audit_period_beginning',
                  'audit_period_ending', 'image_meta'):
         self.assertIn(attr, payload, "Key %s not in payload" % attr)
     self.assertEqual(payload['image_meta'],
             {'md_key1': 'val1', 'md_key2': 'val2'})
     image_ref_url = "%s/images/%s" % (glance.generate_glance_url(),
                                       uuids.fake_image_ref)
     self.assertEqual(payload['image_ref_url'], image_ref_url)
开发者ID:binarycode,项目名称:nova,代码行数:34,代码来源:test_compute_utils.py

示例8: notify_usage_exists

 def notify_usage_exists(
     self,
     context,
     instance,
     current_period=False,
     ignore_missing_network_data=True,
     system_metadata=None,
     extra_usage_info=None,
 ):
     compute_utils.notify_usage_exists(
         context, instance, current_period, ignore_missing_network_data, system_metadata, extra_usage_info
     )
开发者ID:habuka036,项目名称:nova,代码行数:12,代码来源:manager.py

示例9: notify_usage_exists

 def notify_usage_exists(self, context, instance, current_period,
                         ignore_missing_network_data,
                         system_metadata, extra_usage_info):
     if not isinstance(instance, objects.Instance):
         attrs = ['metadata', 'system_metadata']
         instance = objects.Instance._from_db_object(context,
                                                     objects.Instance(),
                                                     instance,
                                                     expected_attrs=attrs)
     compute_utils.notify_usage_exists(self.notifier, context, instance,
                                       current_period,
                                       ignore_missing_network_data,
                                       system_metadata, extra_usage_info)
开发者ID:tomatoXu,项目名称:nova,代码行数:13,代码来源:manager.py

示例10: test_notify_usage_exists_deleted_instance

 def test_notify_usage_exists_deleted_instance(self):
     # Ensure 'exists' notification generates appropriate usage data.
     instance_id = self._create_instance()
     instance = instance_obj.Instance.get_by_id(
         self.context, instance_id, expected_attrs=["metadata", "system_metadata", "info_cache"]
     )
     # Set some system metadata
     sys_metadata = {"image_md_key1": "val1", "image_md_key2": "val2", "other_data": "meow"}
     instance.system_metadata.update(sys_metadata)
     instance.save()
     self.compute.terminate_instance(self.context, instance, [], [])
     instance = instance_obj.Instance.get_by_id(
         self.context.elevated(read_deleted="yes"), instance_id, expected_attrs=["system_metadata"]
     )
     compute_utils.notify_usage_exists(rpc.get_notifier("compute"), self.context, instance)
     msg = fake_notifier.NOTIFICATIONS[-1]
     self.assertEqual(msg.priority, "INFO")
     self.assertEqual(msg.event_type, "compute.instance.exists")
     payload = msg.payload
     self.assertEqual(payload["tenant_id"], self.project_id)
     self.assertEqual(payload["user_id"], self.user_id)
     self.assertEqual(payload["instance_id"], instance["uuid"])
     self.assertEqual(payload["instance_type"], "m1.tiny")
     type_id = flavors.get_flavor_by_name("m1.tiny")["id"]
     self.assertEqual(str(payload["instance_type_id"]), str(type_id))
     flavor_id = flavors.get_flavor_by_name("m1.tiny")["flavorid"]
     self.assertEqual(str(payload["instance_flavor_id"]), str(flavor_id))
     for attr in (
         "display_name",
         "created_at",
         "launched_at",
         "state",
         "state_description",
         "bandwidth",
         "audit_period_beginning",
         "audit_period_ending",
         "image_meta",
     ):
         self.assertTrue(attr in payload, msg="Key %s not in payload" % attr)
     self.assertEqual(payload["image_meta"], {"md_key1": "val1", "md_key2": "val2"})
     image_ref_url = "%s/images/1" % glance.generate_glance_url()
     self.assertEqual(payload["image_ref_url"], image_ref_url)
开发者ID:jacobwagner,项目名称:nova,代码行数:42,代码来源:test_compute_utils.py

示例11: test_notify_usage_exists

 def test_notify_usage_exists(self):
     """Ensure 'exists' notification generates apropriate usage data."""
     instance_id = self._create_instance()
     instance = db.instance_get(self.context, instance_id)
     compute_utils.notify_usage_exists(instance)
     self.assertEquals(len(test_notifier.NOTIFICATIONS), 1)
     msg = test_notifier.NOTIFICATIONS[0]
     self.assertEquals(msg['priority'], 'INFO')
     self.assertEquals(msg['event_type'], 'compute.instance.exists')
     payload = msg['payload']
     self.assertEquals(payload['tenant_id'], self.project_id)
     self.assertEquals(payload['user_id'], self.user_id)
     self.assertEquals(payload['instance_id'], instance_id)
     self.assertEquals(payload['instance_type'], 'm1.tiny')
     type_id = instance_types.get_instance_type_by_name('m1.tiny')['id']
     self.assertEquals(str(payload['instance_type_id']), str(type_id))
     for attr in ('display_name', 'created_at', 'launched_at',
                  'state', 'state_description', 'fixed_ips',
                  'bandwidth', 'audit_period_begining',
                  'audit_period_ending'):
         self.assertTrue(attr in payload,
                         msg="Key %s not in payload" % attr)
     self.assertEquals(payload['image_ref'], '1')
     self.compute.terminate_instance(self.context, instance_id)
开发者ID:dankim,项目名称:nova-stable-folsom,代码行数:24,代码来源:test_compute_utils.py


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