Comment 1 for bug 1807483

Revision history for this message
yeshen (yeshen1) wrote :

The revised method is as follows:

@db_api.context_manager.writer
def clear_binding_levels(context, port_id, host):
    if host:
        for l in (context.session.query(models.PortBindingLevel).
                  filter_by(port_id=port_id, host=host)):
            from neutron.db.models.segment import NetworkSegment
            for s in (context.session.query(NetworkSegment).
                      filter_by(id=l.segment_id, is_dynamic=1)):
                context.session.delete(s)
            context.session.delete(l)
        LOG.debug("For port %(port_id)s, host %(host)s, "
                  "cleared binding levels",
                  {'port_id': port_id,
                   'host': host})