Skip to content

Commit

Permalink
Check against security group rules in all groups while checking for q…
Browse files Browse the repository at this point in the history
…uota

Change-Id: If654d928dfecdbc4ab3464777cb9e4cba17b7333
Closes-Bug: 1365463
(cherry picked from commit 0b0f714)
  • Loading branch information
Sachin Bansal committed Oct 2, 2014
1 parent 20d5fba commit d30e52e
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/config/api-server/vnc_cfg_types.py
Expand Up @@ -839,12 +839,23 @@ def http_put(cls, id, fq_name, obj_dict, db_conn):
if not ok:
return (False, (500, 'Bad Project error : ' + pformat(proj_dict)))

obj_type = 'security-group-rule'
if 'security_group_entries' in obj_dict:
quota_count = len(obj_dict['security_group_entries']['policy_rule'])
(ok, quota_limit) = QuotaHelper.check_quota_limit(proj_dict, obj_type, quota_count)
if not ok:
return (False, (403, pformat(fq_name) + ' : ' + quota_limit))
rule_count = len(obj_dict['security_group_entries']['policy_rule'])
obj_type = 'security-group-rule'
for sg in proj_dict.get('security_groups', []):
if sg['uuid'] == sec_dict['uuid']:
continue
ok, sg_dict = db_conn.dbe_read('security-group', sg)
if not ok:
continue
sge = sg_dict.get('security_group_entries', {})
rule_count += len(sge.get('policy_rule', []))

if sec_dict['id_perms'].get('user_visible', True) is not False:
(ok, quota_limit) = QuotaHelper.check_quota_limit(proj_dict, obj_type,
rule_count-1)
if not ok:
return (False, (403, pformat(fq_name) + ' : ' + quota_limit))

_check_policy_rule_uuid(obj_dict.get('security_group_entries'))
return True, ""
Expand Down

0 comments on commit d30e52e

Please sign in to comment.