def _validate_single_tenant_and_group(self, security_group_rules):
        sg_groups = set()
        tenants = set()
        for rule_dict in security_group_rules['security_group_rules']:
            rule = rule_dict['security_group_rule']
            sg_groups.add(rule['security_group_id'])
            if len(sg_groups) > 1:
                raise ext_sg.SecurityGroupNotSingleGroupRules()

            tenants.add(rule['tenant_id'])
            if len(tenants) > 1:
                raise ext_sg.SecurityGroupRulesNotSingleTenant()
        return sg_groups.pop()
Check that all rules belong to the same security group and tenant
dataset/ETHPy150Open openstack/neutron/neutron/db/securitygroups_db.py/SecurityGroupDbMixin._validate_single_tenant_and_group