def notify_about_instance_usage(context, instance, event_suffix, network_info=None, system_metadata=None, extra_usage_info=None, host=None): """ Send a notification about an instance. :param event_suffix: Event type like "delete.start" or "exists" :param network_info: Networking information, if provided. :param system_metadata: system_metadata DB entries for the instance, if provided. :param extra_usage_info: Dictionary containing extra values to add or override in the notification. :param host: Compute host for the instance, if specified. Default is FLAGS.host """ if not host: host = FLAGS.host if not extra_usage_info: extra_usage_info = {} usage_info = notifications.usage_from_instance(context, instance, network_info, system_metadata, **extra_usage_info) notifier_api.notify(context, 'compute.%s' % host, 'compute.instance.%s' % event_suffix, notifier_api.INFO, usage_info)
def notify_about_instance_usage( context, instance, event_suffix, network_info=None, system_metadata=None, extra_usage_info=None, host=None ): """ Send a notification about an instance. :param event_suffix: Event type like "delete.start" or "exists" :param network_info: Networking information, if provided. :param system_metadata: system_metadata DB entries for the instance, if provided. :param extra_usage_info: Dictionary containing extra values to add or override in the notification. :param host: Compute host for the instance, if specified. Default is FLAGS.host """ if not host: host = FLAGS.host if not extra_usage_info: extra_usage_info = {} usage_info = notifications.usage_from_instance(context, instance, network_info, system_metadata, **extra_usage_info) notifier_api.notify( context, "compute.%s" % host, "compute.instance.%s" % event_suffix, notifier_api.INFO, usage_info )
def test_payload_has_fixed_ip_labels(self): usage = notifications.usage_from_instance(self.context, self.instance, self.net_info, None) self.assertTrue("fixed_ips" in usage) self.assertEquals(usage["fixed_ips"][0]["label"], "test1")