Code logic inconsistency in quantum.db.securitygroups_db.py:SecurityGroupDbMixin._ensure_default_security_group

Bug #1086301 reported by Alex Xu
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
neutron
Confirmed
Low
Abishek Subramanian

Bug Description

def _ensure_default_security_group(self, context, tenant_id,
                                       security_group=None):
        """Create a default security group if one doesn't exist.

        :returns: the default security group id.
        """
        # if in proxy mode a default security group will be created by source
        if not security_group and cfg.CONF.SECURITYGROUP.proxy_mode:
            return

        filters = {'name': ['default'], 'tenant_id': [tenant_id]}
        default_group = self.get_security_groups(context, filters)
        if not default_group:
            security_group = {'security_group': {'name': 'default',
                                                 'tenant_id': tenant_id,
                                                 'description': 'default'}}
>>> >>>>
"if security_group:" never can be False. Because it security_group overlap by previous line.
And as the check, in the begin of this function:
 # if in proxy mode a default security group will be created by source
        if not security_group and cfg.CONF.SECURITYGROUP.proxy_mode:
            return
We needn't assign 'external_id' at here. Also need reference code at securitygroups_db.py:90-108
<<<<<<<
            if security_group:
                security_group['security_group']['external_id'] = (
                    security_group['security_group'].get('external_id'))
            ret = self.create_security_group(context, security_group, True)
            return ret['id']
        else:
            return default_group[0]['id']

Tags: sg-fw
Alex Xu (xuhj)
summary: Code logic inconsistency in
- quantum.db.securitygroups_db.py:_ensure_default_security_group
+ quantum.db.securitygroups_db.py:SecurityGroupDbMixin._ensure_default_security_group
description: updated
Changed in quantum:
status: New → Triaged
importance: Undecided → Medium
tags: added: sg-fw
Changed in quantum:
assignee: nobody → Abishek Subramanian (absubram)
Changed in quantum:
importance: Medium → Low
Revision history for this message
Abishek Subramanian (absubram) wrote :

This has already been fixed by Aaron Rosen via commit for bug 1130927.
Please close this out.

Changed in quantum:
status: Triaged → Invalid
Changed in quantum:
status: Invalid → Confirmed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.