Fix exception when security group rule already exists

Fixes bug 1082842

Change-Id: I5f51c3637903ff817fb47af82419c453094eb5be
This commit is contained in:
Gary Kotton 2012-11-25 15:43:21 +00:00
parent 11cdc7a146
commit eb474882d2
2 changed files with 4 additions and 3 deletions

View File

@ -372,8 +372,9 @@ class SecurityGroupDbMixin(ext_sg.SecurityGroupPluginBase):
# Check in database if rule exists
filters = self._make_security_group_rule_filter_dict(i)
if self.get_security_group_rules(context, filters):
raise ext_sg.SecurityGroupRuleExists(rule=i)
rules = self.get_security_group_rules(context, filters)
if rules:
raise ext_sg.SecurityGroupRuleExists(id=str(rules[0]['id']))
def get_security_group_rules(self, context, filters=None, fields=None):
return self._get_collection(context, SecurityGroupRule,

View File

@ -101,7 +101,7 @@ class DuplicateSecurityGroupRuleInPost(qexception.InUse):
class SecurityGroupRuleExists(qexception.InUse):
message = _("Security group rule exists %(rule)s")
message = _("Security group rule already exists. Group id is %(id)s.")
class SecurityGroupProxyMode(qexception.InUse):