Fixes handling of duplicate share access rule creation
Closes: bug 1274163 Change-Id: Id6d649dcf03c5be9ce6fd7204dfa725d59582412
This commit is contained in:
parent
7eca7e3d7d
commit
b103503d07
|
@ -116,8 +116,11 @@ class ShareActionsController(wsgi.Controller):
|
|||
else:
|
||||
exc_str = "Only 'ip' or 'sid' access types are supported"
|
||||
raise webob.exc.HTTPBadRequest(explanation=exc_str)
|
||||
access = self.share_api.allow_access(
|
||||
context, share, access_type, access_to)
|
||||
try:
|
||||
access = self.share_api.allow_access(
|
||||
context, share, access_type, access_to)
|
||||
except exception.ShareAccessExists as e:
|
||||
raise webob.exc.HTTPBadRequest(explanation=e.msg)
|
||||
return {'access': access}
|
||||
|
||||
@wsgi.action('os-deny_access')
|
||||
|
|
|
@ -360,8 +360,8 @@ class API(base.Base):
|
|||
values = {'share_id': share['id'],
|
||||
'access_type': access_type,
|
||||
'access_to': access_to}
|
||||
access = self.db.share_access_get_all_by_type_and_access(
|
||||
ctx, share['id'], access_type, access_to)
|
||||
access = [a for a in self.db.share_access_get_all_by_type_and_access(
|
||||
ctx, share['id'], access_type, access_to) if a['state'] != 'error']
|
||||
if access:
|
||||
raise exception.ShareAccessExists(access_type=access_type,
|
||||
access=access_to)
|
||||
|
|
Loading…
Reference in New Issue