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
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): get(net_ id)
raise q_exc.StateInva lid(port_ state=kwargs[ key]) merge(port)
# confirm network exists
network_
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'):
port[key] = kwargs[key]
session.
session.flush()
return port