'Check that all security groups on port belong to tenant.
:returns: all security groups IDs on port belonging to tenant.'

def _get_security_groups_on_port(self, context, port):

    port = port['port']
    if (not validators.is_attr_set(port.get(ext_sg.SECURITYGROUPS))):
        return
    if (port.get('device_owner') and net.is_port_trusted(port)):
        return
    port_sg = port.get(ext_sg.SECURITYGROUPS, [])
    filters = {'id': port_sg}
    tenant_id = port.get('tenant_id')
    if tenant_id:
        filters['tenant_id'] = [tenant_id]
    valid_groups = set((g['id'] for g in self.get_security_groups(context, fields=['id'], filters=filters)))
    requested_groups = set(port_sg)
    port_sg_missing = (requested_groups - valid_groups)
    if port_sg_missing:
        raise ext_sg.SecurityGroupNotFound(id=',    '.join(port_sg_missing))
    return list(requested_groups)
