Merge "Adding additional details to notification logs"

This commit is contained in:
Jenkins 2017-02-16 13:25:14 +00:00 committed by Gerrit Code Review
commit dddbb63633
3 changed files with 17 additions and 4 deletions

View File

@ -154,7 +154,7 @@ function create_watcher_conf {
setup_colorized_logging $WATCHER_CONF DEFAULT
else
# Show user_name and project_name instead of user_id and project_id
iniset $WATCHER_CONF DEFAULT logging_context_format_string "%(asctime)s.%(msecs)03d %(levelname)s %(name)s [%(request_id)s %(user_name)s %(project_name)s] %(instance)s%(message)s"
iniset $WATCHER_CONF DEFAULT logging_context_format_string "%(asctime)s.%(msecs)03d %(levelname)s %(name)s [%(request_id)s %(project_domain)s %(user_name)s %(project_name)s] %(instance)s%(message)s"
fi
# Register SSL certificates if provided

View File

@ -17,7 +17,6 @@
# limitations under the License.
from oslo_log import log
from watcher._i18n import _LI, _LW
from watcher.common import exception
from watcher.common import nova_helper
@ -220,6 +219,8 @@ class ServiceUpdated(VersionedNotificationEndpoint):
)
def info(self, ctxt, publisher_id, event_type, payload, metadata):
ctxt.request_id = metadata['message_id']
ctxt.project_domain = event_type
LOG.info(_LI("Event '%(event)s' received from %(publisher)s "
"with metadata %(metadata)s") %
dict(event=event_type,
@ -262,6 +263,8 @@ class InstanceCreated(VersionedNotificationEndpoint):
)
def info(self, ctxt, publisher_id, event_type, payload, metadata):
ctxt.request_id = metadata['message_id']
ctxt.project_domain = event_type
LOG.info(_LI("Event '%(event)s' received from %(publisher)s "
"with metadata %(metadata)s") %
dict(event=event_type,
@ -269,7 +272,6 @@ class InstanceCreated(VersionedNotificationEndpoint):
metadata=metadata))
LOG.debug(payload)
instance_data = payload['nova_object.data']
instance_uuid = instance_data['uuid']
node_uuid = instance_data.get('host')
instance = self.get_or_create_instance(instance_uuid, node_uuid)
@ -296,6 +298,8 @@ class InstanceUpdated(VersionedNotificationEndpoint):
)
def info(self, ctxt, publisher_id, event_type, payload, metadata):
ctxt.request_id = metadata['message_id']
ctxt.project_domain = event_type
LOG.info(_LI("Event '%(event)s' received from %(publisher)s "
"with metadata %(metadata)s") %
dict(event=event_type,
@ -321,6 +325,8 @@ class InstanceDeletedEnd(VersionedNotificationEndpoint):
)
def info(self, ctxt, publisher_id, event_type, payload, metadata):
ctxt.request_id = metadata['message_id']
ctxt.project_domain = event_type
LOG.info(_LI("Event '%(event)s' received from %(publisher)s "
"with metadata %(metadata)s") %
dict(event=event_type,
@ -354,6 +360,8 @@ class LegacyInstanceUpdated(UnversionedNotificationEndpoint):
)
def info(self, ctxt, publisher_id, event_type, payload, metadata):
ctxt.request_id = metadata['message_id']
ctxt.project_domain = event_type
LOG.info(_LI("Event '%(event)s' received from %(publisher)s "
"with metadata %(metadata)s") %
dict(event=event_type,
@ -379,6 +387,8 @@ class LegacyInstanceCreatedEnd(UnversionedNotificationEndpoint):
)
def info(self, ctxt, publisher_id, event_type, payload, metadata):
ctxt.request_id = metadata['message_id']
ctxt.project_domain = event_type
LOG.info(_LI("Event '%(event)s' received from %(publisher)s "
"with metadata %(metadata)s") %
dict(event=event_type,
@ -404,6 +414,8 @@ class LegacyInstanceDeletedEnd(UnversionedNotificationEndpoint):
)
def info(self, ctxt, publisher_id, event_type, payload, metadata):
ctxt.request_id = metadata['message_id']
ctxt.project_domain = event_type
LOG.info(_LI("Event '%(event)s' received from %(publisher)s "
"with metadata %(metadata)s") %
dict(event=event_type,
@ -435,6 +447,8 @@ class LegacyLiveMigratedEnd(UnversionedNotificationEndpoint):
)
def info(self, ctxt, publisher_id, event_type, payload, metadata):
ctxt.request_id = metadata['message_id']
ctxt.project_domain = event_type
LOG.info(_LI("Event '%(event)s' received from %(publisher)s "
"with metadata %(metadata)s") %
dict(event=event_type,

View File

@ -199,7 +199,6 @@ class TestNovaNotifications(NotificationTestCase):
m_nova_helper_cls.return_value = mock.Mock(
get_compute_node_by_hostname=m_get_compute_node_by_hostname,
name='m_nova_helper')
compute_model = self.fake_cdmc.generate_scenario_3_with_2_nodes()
self.fake_cdmc.cluster_data_model = compute_model
handler = novanotification.InstanceUpdated(self.fake_cdmc)