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=None, limit=None, offset=None, sort_key=None, sort_dir=None)

Return messages for the given context.

The Permitted Messages Module

class Action

Bases: object

ADD_UPDATE_SECURITY_SERVICE = ('011', 'add or update security service')
ALL = (('001', 'allocate host'), ('002', 'create'), ('003', 'delete access rules'), ('004', 'promote'), ('005', 'update'), ('006', 'revert to snapshot'), ('007', 'delete'), ('008', 'extend'), ('009', 'shrink'), ('010', 'update access rules'), ('011', 'add or update security service'))
ALLOCATE_HOST = ('001', 'allocate host')
CREATE = ('002', 'create')
DELETE = ('007', 'delete')
DELETE_ACCESS_RULES = ('003', 'delete access rules')
EXTEND = ('008', 'extend')
PROMOTE = ('004', 'promote')
REVERT_TO_SNAPSHOT = ('006', 'revert to snapshot')
SHRINK = ('009', 'shrink')
UPDATE = ('005', 'update')
UPDATE_ACCESS_RULES = ('010', 'update access rules')
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."), ('015', 'Share Driver failed to extend share, The share status has been set to extending_error. This action cannot be re-attempted until the status has been rectified. Contact your administrator to determine the cause of this failure.'), ('016', "No storage could be allocated for this share request, CreateFromSnapshot filter didn't succeed."), ('017', 'Share Driver has failed to create the share from snapshot. This operation can be re-attempted by creating a new share. Contact your administrator to determine the cause of this failure.'), ('018', 'Share Driver refused to shrink the share. The size to be shrunk is smaller than the current used space. The share status has been set to available. Please select a size greater than the current used space.'), ('019', 'Share Driver does not support shrinking shares. Shrinking share operation failed.'), ('020', 'Failed to grant access to client. The client ID used may be forbidden. You may try again with a different client identifier.'), ('021', 'Failed to grant access to client. The access level or type may be unsupported. You may try again with a different access level or access type.'), ('022', 'Share driver has failed to setup one or more security services that are associated with the used share network. The security service may be unsupported or the provided parameters are invalid. You may try again with a different set of configurations.'), ('023', 'Share Driver failed to create share due to a security service authentication issue. The security service user has either insufficient privileges or wrong credentials. Please check your user, password, ou and domain.'))
DRIVER_FAILED_CREATING_FROM_SNAP = ('017', 'Share Driver has failed to create the share from snapshot. This operation can be re-attempted by creating a new share. Contact your administrator to determine the cause of this failure.')
DRIVER_FAILED_EXTEND = ('015', 'Share Driver failed to extend share, The share status has been set to extending_error. This action cannot be re-attempted until the status has been rectified. Contact your administrator to determine the cause of this failure.')
DRIVER_FAILED_SHRINK = ('019', 'Share Driver does not support shrinking shares. Shrinking share operation failed.')
DRIVER_REFUSED_SHRINK = ('018', 'Share Driver refused to shrink the share. The size to be shrunk is smaller than the current used space. The share status has been set to available. Please select a size greater than the current used space.')
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_CREATE_FROM_SNAPSHOT = ('016', "No storage could be allocated for this share request, CreateFromSnapshot 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."), 'CreateFromSnapshotFilter': ('016', "No storage could be allocated for this share request, CreateFromSnapshot 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.")
FORBIDDEN_CLIENT_ACCESS = ('020', 'Failed to grant access to client. The client ID used may be forbidden. You may try again with a different client identifier.')
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.')
SECURITY_SERVICE_FAILED_AUTH = ('023', 'Share Driver failed to create share due to a security service authentication issue. The security service user has either insufficient privileges or wrong credentials. Please check your user, password, ou and domain.')
UNEXPECTED_NETWORK = ('003', 'Driver does not expect share-network to be provided with current configuration.')
UNKNOWN_ERROR = ('001', 'An unknown error occurred.')
UNSUPPORTED_ADD_UDPATE_SECURITY_SERVICE = ('022', 'Share driver has failed to setup one or more security services that are associated with the used share network. The security service may be unsupported or the provided parameters are invalid. You may try again with a different set of configurations.')
UNSUPPORTED_CLIENT_ACCESS = ('021', 'Failed to grant access to client. The access level or type may be unsupported. You may try again with a different access level or access type.')
class Resource

Bases: object

SECURITY_SERVICE = 'SECURITY_SERVICE'
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)