示例#1
0
    def index(self, req):
        try:
            filters = {'namespace': None}
            rs_type_repo = self.gateway.get_metadef_resource_type_repo(
                req.context, authorization_layer=False)
            # NOTE(abhishekk): Here we are just checking if user is
            # authorized to view/list metadef resource types or not.
            # Also there is no relation between list_metadef_resource_types
            # and get_metadef_resource_type policies so can not enforce
            # get_metadef_resource_type policy on individual resource
            # type here.
            api_policy.MetadefAPIPolicy(
                req.context,
                enforcer=self.policy).list_metadef_resource_types()

            db_resource_type_list = rs_type_repo.list(filters=filters)
            resource_type_list = [
                ResourceType.to_wsme_model(resource_type)
                for resource_type in db_resource_type_list
            ]
            resource_types = ResourceTypes()
            resource_types.resource_types = resource_type_list
        except exception.Forbidden as e:
            LOG.debug("User not permitted to retrieve metadata resource types "
                      "index")
            raise webob.exc.HTTPForbidden(explanation=e.msg)
        except exception.NotFound as e:
            raise webob.exc.HTTPNotFound(explanation=e.msg)
        return resource_types
 def index(self, req):
     try:
         filters = {"namespace": None}
         rs_type_repo = self.gateway.get_metadef_resource_type_repo(req.context)
         db_resource_type_list = rs_type_repo.list(filters=filters)
         resource_type_list = [ResourceType.to_wsme_model(resource_type) for resource_type in db_resource_type_list]
         resource_types = ResourceTypes()
         resource_types.resource_types = resource_type_list
     except exception.Forbidden as e:
         raise webob.exc.HTTPForbidden(explanation=e.msg)
     except exception.NotFound as e:
         raise webob.exc.HTTPNotFound(explanation=e.msg)
     except Exception as e:
         LOG.error(e)
         raise webob.exc.HTTPInternalServerError(e)
     return resource_types
 def index(self, req):
     try:
         filters = {'namespace': None}
         rs_type_repo = self.gateway.get_metadef_resource_type_repo(
             req.context)
         db_resource_type_list = rs_type_repo.list(filters=filters)
         resource_type_list = [ResourceType.to_wsme_model(
             resource_type) for resource_type in db_resource_type_list]
         resource_types = ResourceTypes()
         resource_types.resource_types = resource_type_list
     except exception.Forbidden as e:
         raise webob.exc.HTTPForbidden(explanation=e.msg)
     except exception.NotFound as e:
         raise webob.exc.HTTPNotFound(explanation=e.msg)
     except Exception as e:
         LOG.error(e)
         raise webob.exc.HTTPInternalServerError(e)
     return resource_types
 def index(self, req):
     try:
         filters = {'namespace': None}
         rs_type_repo = self.gateway.get_metadef_resource_type_repo(
             req.context)
         db_resource_type_list = rs_type_repo.list(filters=filters)
         resource_type_list = [ResourceType.to_wsme_model(
             resource_type) for resource_type in db_resource_type_list]
         resource_types = ResourceTypes()
         resource_types.resource_types = resource_type_list
     except exception.Forbidden as e:
         LOG.debug("User not permitted to retrieve metadata resource types "
                   "index")
         raise webob.exc.HTTPForbidden(explanation=e.msg)
     except exception.NotFound as e:
         raise webob.exc.HTTPNotFound(explanation=e.msg)
     except Exception as e:
         LOG.error(encodeutils.exception_to_unicode(e))
         raise webob.exc.HTTPInternalServerError(e)
     return resource_types
示例#5
0
 def index(self, req):
     try:
         filters = {}
         filters['namespace'] = None
         rs_type_repo = self.gateway.get_metadef_resource_type_repo(
             req.context)
         db_resource_type_list = rs_type_repo.list(filters=filters)
         resource_type_list = [ResourceType.to_wsme_model(
             resource_type) for resource_type in db_resource_type_list]
         resource_types = ResourceTypes()
         resource_types.resource_types = resource_type_list
     except exception.Forbidden as e:
         LOG.debug("User not permitted to retrieve metadata resource types "
                   "index")
         raise webob.exc.HTTPForbidden(explanation=e.msg)
     except exception.NotFound as e:
         raise webob.exc.HTTPNotFound(explanation=e.msg)
     except Exception as e:
         LOG.error(utils.exception_to_str(e))
         raise webob.exc.HTTPInternalServerError(e)
     return resource_types