Skip to content

Commit

Permalink
Fix for bug 902175
Browse files Browse the repository at this point in the history
We can't use merge if we're removing a field from the port object so use add
instead.  Also, pass the session to port_get so that we don't run into the
"this port is already bound to session x" error.

Change-Id: I54a8484c8f6429ad18fb0c5e088720d21fc16299
  • Loading branch information
Brad Hall committed Dec 12, 2011
1 parent 1a048e9 commit b0652c0
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions quantum/db/api.py
Expand Up @@ -159,12 +159,13 @@ def port_list(net_id):
all()


def port_get(port_id, net_id):
def port_get(port_id, net_id, session=None):
# confirm network exists
network_get(net_id)
session = get_session()
if not session:
session = get_session()
try:
return session.query(models.Port).\
return session.query(models.Port).\
filter_by(uuid=port_id).\
filter_by(network_id=net_id).\
one()
Expand Down Expand Up @@ -222,9 +223,9 @@ def port_unset_attachment(port_id, net_id):
network_get(net_id)

session = get_session()
port = port_get(port_id, net_id)
port = port_get(port_id, net_id, session)
port.interface_id = None
session.merge(port)
session.add(port)
session.flush()


Expand Down

0 comments on commit b0652c0

Please sign in to comment.