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 share 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 manila import context
from manila.message import api as message_api
from manila.message import message_field

self.message_api = message_api.API()

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

self.message_api.create(
    context,
    message_field.Actions.CREATE,
    project_id,
    resource_type=message_field.Resource.SHARE,
    resource_id=SHARE_id,
    detail=message_field.Detail.NO_VALID_HOST)

Will produce the following:

GET /v2/6c430ede-9476-4128-8838-8d3929ced223/messages
{
  "messages": [
    {
     "id": "5429fffa-5c76-4d68-a671-37a8e24f37cf",
     "action_id": "001",
     "detail_id": "002",
     "user_message": "create: No storage could be allocated for this share "
                     "request. Trying again with a different size "
                     "or share type may succeed."",
     "message_level": "ERROR",
     "resource_type": "SHARE",
     "resource_id": "f292cc0c-54a7-4b3b-8174-d2ff82d87008",
     "created_at": 2015-08-27T09:49:58-05:00,
     "expires_at": 2015-09-26T09: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, project_id, resource_type=None, resource_id=None, exception=None, detail=None, level='ERROR')

Create a message with the specified information.

delete(context, id)

Delete message with the specified message id.

get(context, id)

Return message with the specified message id.

get_all(context, search_opts={}, sort_key=None, sort_dir=None)

Return messages for the given context.

The Permitted Messages Module

class Action

Bases: object

ALL = (('001', 'allocate host'), ('002', 'create'), ('003', 'delete access rules'), ('004', 'promote'), ('005', 'update'), ('006', 'revert to snapshot'), ('007', 'delete'))
ALLOCATE_HOST = ('001', 'allocate host')
CREATE = ('002', 'create')
DELETE = ('007', 'delete')
DELETE_ACCESS_RULES = ('003', 'delete access rules')
PROMOTE = ('004', 'promote')
REVERT_TO_SNAPSHOT = ('006', 'revert to snapshot')
UPDATE = ('005', 'update')
class Detail

Bases: object

ALL = (('001', 'An unknown error occurred.'), ('002', 'No storage could be allocated for this share request. Trying again with a different size or share type may succeed.'), ('003', 'Driver does not expect share-network to be provided with current configuration.'), ('004', "Could not find an existing share server or allocate one on the share network provided. You may use a different share network, or verify the network details in the share network and retry your request. If this doesn't work, contact your administrator to troubleshoot issues with your network."), ('005', "An 'active' replica must exist in 'available' state to create a new replica for share."), ('006', "Share has no replica with 'replica_state' set to 'active'."), ('007', "No storage could be allocated for this share request, AvailabilityZone filter didn't succeed."), ('008', "No storage could be allocated for this share request, Capabilities filter didn't succeed."), ('009', "No storage could be allocated for this share request, Capacity filter didn't succeed."), ('010', "No storage could be allocated for this share request, Driver filter didn't succeed."), ('011', "No storage could be allocated for this share request, IgnoreAttemptedHosts filter didn't succeed."), ('012', "No storage could be allocated for this share request, Json filter didn't succeed."), ('013', "No storage could be allocated for this share request, Retry filter didn't succeed."), ('014', "No storage could be allocated for this share request, ShareReplication filter didn't succeed."))
EXCEPTION_DETAIL_MAPPINGS = {('002', 'No storage could be allocated for this share request. Trying again with a different size or share type may succeed.'): ['NoValidHost']}
FILTER_AVAILABILITY = ('007', "No storage could be allocated for this share request, AvailabilityZone filter didn't succeed.")
FILTER_CAPABILITIES = ('008', "No storage could be allocated for this share request, Capabilities filter didn't succeed.")
FILTER_CAPACITY = ('009', "No storage could be allocated for this share request, Capacity filter didn't succeed.")
FILTER_DETAIL_MAPPINGS = {'AvailabilityZoneFilter': ('007', "No storage could be allocated for this share request, AvailabilityZone filter didn't succeed."), 'CapabilitiesFilter': ('008', "No storage could be allocated for this share request, Capabilities filter didn't succeed."), 'CapacityFilter': ('009', "No storage could be allocated for this share request, Capacity filter didn't succeed."), 'DriverFilter': ('010', "No storage could be allocated for this share request, Driver filter didn't succeed."), 'IgnoreAttemptedHostsFilter': ('011', "No storage could be allocated for this share request, IgnoreAttemptedHosts filter didn't succeed."), 'JsonFilter': ('012', "No storage could be allocated for this share request, Json filter didn't succeed."), 'RetryFilter': ('013', "No storage could be allocated for this share request, Retry filter didn't succeed."), 'ShareReplicationFilter': ('014', "No storage could be allocated for this share request, ShareReplication filter didn't succeed.")}
FILTER_DRIVER = ('010', "No storage could be allocated for this share request, Driver filter didn't succeed.")
FILTER_IGNORE = ('011', "No storage could be allocated for this share request, IgnoreAttemptedHosts filter didn't succeed.")
FILTER_JSON = ('012', "No storage could be allocated for this share request, Json filter didn't succeed.")
FILTER_MSG = "No storage could be allocated for this share request, %s filter didn't succeed."
FILTER_REPLICATION = ('014', "No storage could be allocated for this share request, ShareReplication filter didn't succeed.")
FILTER_RETRY = ('013', "No storage could be allocated for this share request, Retry filter didn't succeed.")
NO_ACTIVE_AVAILABLE_REPLICA = ('005', "An 'active' replica must exist in 'available' state to create a new replica for share.")
NO_ACTIVE_REPLICA = ('006', "Share has no replica with 'replica_state' set to 'active'.")
NO_SHARE_SERVER = ('004', "Could not find an existing share server or allocate one on the share network provided. You may use a different share network, or verify the network details in the share network and retry your request. If this doesn't work, contact your administrator to troubleshoot issues with your network.")
NO_VALID_HOST = ('002', 'No storage could be allocated for this share request. Trying again with a different size or share type may succeed.')
UNEXPECTED_NETWORK = ('003', 'Driver does not expect share-network to be provided with current configuration.')
UNKNOWN_ERROR = ('001', 'An unknown error occurred.')
class Resource

Bases: object

SHARE = 'SHARE'
SHARE_GROUP = 'SHARE_GROUP'
SHARE_REPLICA = 'SHARE_REPLICA'
SHARE_SNAPSHOT = 'SHARE_SNAPSHOT'
translate_action(action_id)
translate_detail(detail_id)
translate_detail_id(excep, detail)
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.