User Messages

User Messages

User messages are a way to inform users about the state of asynchronous operations. One example would be notifying the user of why a volume provisioning request failed. These messages can be requested via the /messages API. All user visible messages must be defined in the permitted messages module in order to prevent sharing sensitive information with users.

Example message generation:

from cinder import context
from cinder.message import api as message_api
from cinder.message import defined_messages
from cinder.message import resource_types

self.message_api = message_api.API()

context = context.RequestContext()
project_id = '6c430ede-9476-4128-8838-8d3929ced223'
volume_id = 'f292cc0c-54a7-4b3b-8174-d2ff82d87008'

self.message_api.create(
    context,
    defined_messages.EventIds.UNABLE_TO_ALLOCATE,
    project_id,
    resource_type=resource_types.VOLUME,
    resource_uuid=volume_id)

Will produce the following:

GET /v3/6c430ede-9476-4128-8838-8d3929ced223/messages
{
  "messages": [
    {
     "id": "5429fffa-5c76-4d68-a671-37a8e24f37cf",
     "event_id": "000002",
     "user_message": "No storage could be allocated for this volume request.",
     "message_level": "ERROR",
     "resource_type": "VOLUME",
     "resource_uuid": "f292cc0c-54a7-4b3b-8174-d2ff82d87008",
     "created_at": 2015-08-27T09:49:58-05:00,
     "guaranteed_until": 2015-09-27T09:49:58-05:00,
     "request_id": "req-936666d2-4c8f-4e41-9ac9-237b43f8b848",
    }
  ]
}

The Message API Module

Handles all requests related to user facing messages.

class API(db_driver=None)

API for handling user messages.

cleanup_expired_messages(context)
create(context, action, resource_type='VOLUME', resource_uuid=None, exception=None, detail=None, level='ERROR')

Create a message with the specified information.

delete(context, id)

Delete message with the specified id.

get(context, id)

Return message with the specified id.

get_all(context, filters=None, marker=None, limit=None, offset=None, sort_keys=None, sort_dirs=None)

Return all messages for the given context.

The Message Field Module

Message Resource, Action, Detail and user visible message.

Use Resource, Action and Detail’s combination to indicate the Event in the format of:

EVENT: VOLUME_RESOURCE_ACTION_DETAIL

Also, use exception-to-detail mapping to decrease the workload of classifying event in cinder’s task code.

The Permitted Messages Module

Event ID and user visible message mapping.

Event IDs are used to look up the message to be displayed for an API Message object. All defined messages should be appropriate for any API user to see and not contain any sensitive information. A good rule-of-thumb is to be very general in error messages unless the issue is due to a bad user action, then be specific.

class EventIds

Bases: object

ATTACH_READONLY_VOLUME = 'VOLUME_000003'
IMAGE_FROM_VOLUME_OVER_QUOTA = 'VOLUME_000004'
UNABLE_TO_ALLOCATE = 'VOLUME_000002'
UNKNOWN_ERROR = 'VOLUME_000001'
get_message_text(event_id)
Creative Commons Attribution 3.0 License

Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.