Comment 2 for bug 919265

Revision history for this message
dan wendlandt (danwent) wrote :

Yeah, the right thing would probably be to take the logic from the port_update call in db/api.py and use it in port_create:

def port_update(port_id, net_id, **kwargs):
    # confirm network exists
    network_get(net_id)
    port = port_get(port_id, net_id)
    session = get_session()
    for key in kwargs.keys():
        if key == "state":
            if kwargs[key] not in ('ACTIVE', 'DOWN'):
                raise q_exc.StateInvalid(port_state=kwargs[key])
        port[key] = kwargs[key]
    session.merge(port)
    session.flush()
    return port