def get_sec_mixin(entity):
    """
    Get the security mixin of the supplied entity.
    """
    sec_mixin_present = 0
    sec_mixin = None
    for mixin in entity.mixins:
        if os_addon.SEC_GROUP in mixin.related:
            sec_mixin = mixin
            sec_mixin_present += 1

    if not sec_mixin_present:
        # no mixin of the type security group was found
        msg = 'No security group mixin was found'
        raise AttributeError(msg)
    if sec_mixin_present > 1:
        msg = 'More than one security group mixin was found'
        raise AttributeError(msg)

    return sec_mixin
dataset/ETHPy150Open tmetsch/occi-os/occi_os_api/backends/openstack.py/get_sec_mixin/original