def _assert_non_public_share_group_type(self, context, type_id): try: share_group_type = share_group_types.get(context, type_id) if share_group_type['is_public']: msg = _("Type access modification is not applicable to " "public share group type.") raise webob.exc.HTTPConflict(explanation=msg) except exception.ShareGroupTypeNotFound as err: raise webob.exc.HTTPNotFound(explanation=six.text_type(err))
def _assert_non_public_share_group_type(self, context, type_id): try: share_group_type = share_group_types.get( context, type_id) if share_group_type['is_public']: msg = _("Type access modification is not applicable to " "public share group type.") raise webob.exc.HTTPConflict(explanation=msg) except exception.ShareGroupTypeNotFound as err: raise webob.exc.HTTPNotFound(explanation=six.text_type(err))
def _show(self, req, id): """Return a single share group type item.""" context = req.environ['manila.context'] try: share_group_type = share_group_types.get(context, id) except exception.NotFound: msg = _("Share group type with id %s not found.") raise exc.HTTPNotFound(explanation=msg % id) share_group_type['id'] = six.text_type(share_group_type['id']) return self._view_builder.show(req, share_group_type)
def show(self, req, id): """Return a single share group type item.""" context = req.environ['manila.context'] try: share_group_type = share_group_types.get(context, id) except exception.NotFound: msg = _("Share group type with id %s not found.") raise exc.HTTPNotFound(explanation=msg % id) share_group_type['id'] = six.text_type(share_group_type['id']) return self._view_builder.show(req, share_group_type)
def _delete(self, req, id): """Deletes an existing group type.""" context = req.environ['manila.context'] try: share_group_type = share_group_types.get(context, id) share_group_types.destroy(context, share_group_type['id']) except exception.ShareGroupTypeInUse: msg = _('Target share group type with id %s is still in use.') raise webob.exc.HTTPBadRequest(explanation=msg % id) except exception.NotFound: raise webob.exc.HTTPNotFound() return webob.Response(status_int=http_client.NO_CONTENT)
def _delete(self, req, id): """Deletes an existing group type.""" context = req.environ['manila.context'] try: share_group_type = share_group_types.get(context, id) share_group_types.destroy(context, share_group_type['id']) except exception.ShareGroupTypeInUse: msg = _('Target share group type with id %s is still in use.') raise webob.exc.HTTPBadRequest(explanation=msg % id) except exception.NotFound: raise webob.exc.HTTPNotFound() return webob.Response(status_int=204)
def _share_group_type_access(self, req, id): context = req.environ['manila.context'] try: share_group_type = share_group_types.get( context, id, expected_fields=['projects']) except exception.ShareGroupTypeNotFound: explanation = _("Share group type %s not found.") % id raise webob.exc.HTTPNotFound(explanation=explanation) if share_group_type['is_public']: expl = _("Access list not available for public share group types.") raise webob.exc.HTTPNotFound(explanation=expl) projects = [] for project_id in share_group_type['projects']: projects.append({ 'share_group_type_id': share_group_type['id'], 'project_id': project_id }) return {'share_group_type_access': projects}
def share_group_type_access(self, req, id): context = req.environ['manila.context'] try: share_group_type = share_group_types.get( context, id, expected_fields=['projects']) except exception.ShareGroupTypeNotFound: explanation = _("Share group type %s not found.") % id raise webob.exc.HTTPNotFound(explanation=explanation) if share_group_type['is_public']: expl = _("Access list not available for public share group types.") raise webob.exc.HTTPNotFound(explanation=expl) projects = [] for project_id in share_group_type['projects']: projects.append( {'share_group_type_id': share_group_type['id'], 'project_id': project_id} ) return {'share_group_type_access': projects}
def _assert_share_group_type_exists(self, context, type_id): try: share_group_types.get(context, type_id) except exception.NotFound as ex: raise webob.exc.HTTPNotFound(explanation=ex.msg)
def _assert_share_group_type_exists(self, context, type_id): try: share_group_types.get(context, type_id) except exception.NotFound as ex: raise webob.exc.HTTPNotFound(explanation=ex.msg)