Пример #1
0
 def _get_tenant_id_for_create(self, context, resource):
     if context.is_admin and 'tenant_id' in resource:
         tenant_id = resource['tenant_id']
     elif ('tenant_id' in resource and
           resource['tenant_id'] != context.tenant_id):
         reason = _('Cannot create resource for another tenant')
         raise q_exc.AdminRequired(reason=reason)
     else:
         tenant_id = context.tenant_id
     return tenant_id
Пример #2
0
 def _check_admin(self,
                  context,
                  reason=_("Only admin can view or configure quota")):
     if not context.is_admin:
         raise q_exc.AdminRequired(reason=reason)