Fix offline network migration for sqlalchemy 1.4+
Sqlalchemy 1.4 dropped support for RowProxy and Row now behaves like a tuple. This causes row and column iteration to fail using the RowProxy semantics as the iteration methods are no longer there. Fix this by checking which method needs to be used. This is necessary for backwards compatibility with the Xena release for the Yoga branch. Closes-Bug: #1968647 Change-Id: I6a4adbd87bd59ad3a4b0a8cef187d82f4e128084
This commit is contained in:
parent
8109de7d88
commit
d20fda9b17
@ -164,7 +164,10 @@ def allocate_segment(db_session, network_type):
|
||||
.format(vni_row, alloc_table))
|
||||
rs = db_session.execute(stmt)
|
||||
for row in rs:
|
||||
vni = next(row.itervalues())
|
||||
if hasattr(row, 'itervalues'):
|
||||
vni = next(row.itervalues())
|
||||
else:
|
||||
vni = next(iter(row))
|
||||
# A aggregated query will always provide a result, check for NULL
|
||||
if vni is None:
|
||||
raise NotFound(
|
||||
@ -215,7 +218,10 @@ def get_network_segments(db_session, network_type):
|
||||
' network_type=:network_type')
|
||||
rs = db_session.execute(stmt, {'network_type': network_type})
|
||||
for row in rs:
|
||||
yield row.values()
|
||||
if hasattr(row, 'values'):
|
||||
yield row.values()
|
||||
else:
|
||||
yield row
|
||||
|
||||
|
||||
def morph_networks(db_session, from_network_type, to_network_type):
|
||||
|
Loading…
x
Reference in New Issue
Block a user