

def _format_security_group_rule(self, context, rule):
    sg_rule = {
        
    }
    sg_rule['id'] = rule.id
    sg_rule['parent_group_id'] = rule.parent_group_id
    sg_rule['ip_protocol'] = rule.protocol
    sg_rule['from_port'] = rule.from_port
    sg_rule['to_port'] = rule.to_port
    sg_rule['group'] = {
        
    }
    sg_rule['ip_range'] = {
        
    }
    if rule.group_id:
        source_group = db.security_group_get(context, self.group_id)
        sg_rule['group'] = {
            'name': source_group.name,
            'tenant_id': source_group.project_id,
        }
    else:
        sg_rule['ip_range'] = {
            'cidr': rule.cidr,
        }
    return sg_rule

dataset/ETHPy150Open nii-cloud/dodai-compute/nova/api/openstack/contrib/security_groups.py SecurityGroupController._format_security_group_rule/VarMisuse@101/158 `rule`->`self`