The cinder.message.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.

class Action(valid_values, **kwargs)

Bases: oslo_versionedobjects.fields.Enum

ALL = ((‘001’, u’schedule allocate volume’), (‘002’, u’attach volume’), (‘003’, u’copy volume to image’), (‘004’, u’update attachment’))
ATTACH_VOLUME = (‘002’, u’attach volume’)
COPY_VOLUME_TO_IMAGE = (‘003’, u’copy volume to image’)
SCHEDULE_ALLOCATE_VOLUME = (‘001’, u’schedule allocate volume’)
UPDATE_ATTACHMENT = (‘004’, u’update attachment’)
class Detail(valid_values, **kwargs)

Bases: oslo_versionedobjects.fields.Enum

ALL = ((‘001’, u’An unknown error occurred.’), (‘002’, u’Driver is not initialized at present.’), (‘003’, u’Could not found any available weighted backend.’), (‘004’, u’Failed to upload volume to image at backend.’), (‘005’, u”Volume’s attach mode is invalid.”), (‘006’, u’Not enough quota resource for operation.’))
DRIVER_NOT_INITIALIZED = (‘002’, u’Driver is not initialized at present.’)
EXCEPTION_DETAIL_MAPPINGS = {(‘002’, u’Driver is not initialized at present.’): [‘DriverNotInitialized’], (‘005’, u”Volume’s attach mode is invalid.”): [‘InvalidVolumeAttachMode’], (‘006’, u’Not enough quota resource for operation.’): [‘ImageLimitExceeded’, ‘BackupLimitExceeded’, ‘SnapshotLimitExceeded’], (‘003’, u’Could not found any available weighted backend.’): [‘NoValidBackend’]}
FAILED_TO_UPLOAD_VOLUME = (‘004’, u’Failed to upload volume to image at backend.’)
NO_BACKEND_AVAILABLE = (‘003’, u’Could not found any available weighted backend.’)
QUOTA_EXCEED = (‘006’, u’Not enough quota resource for operation.’)
UNKNOWN_ERROR = (‘001’, u’An unknown error occurred.’)
VOLUME_ATTACH_MODE_INVALID = (‘005’, u”Volume’s attach mode is invalid.”)
class Resource(valid_values, **kwargs)

Bases: oslo_versionedobjects.fields.Enum

VOLUME = ‘VOLUME’
translate_action(action_id)
translate_detail(detail_id)
translate_detail_id(exception, detail)