Skip to content

Commit

Permalink
list pool: order subnets by priority
Browse files Browse the repository at this point in the history
adjust the db model for `Pool` to return the list of subnets
sorted by priority, which prohbably is what a user expects in general

additionally, fix `assertDictSubset()` to make sure msg is a string,
as it would sometimes fail, see 1and1#198
  • Loading branch information
zeromind committed Feb 7, 2022
1 parent 2c94a08 commit 5c801fb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions dim-testsuite/tests/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,11 @@ def assertDictSubset(self, actual, expected, msg=None):
if not (missing or mismatched):
return

msg = ''
if missing:
msg = 'Missing: %s' % ','.join(safe_repr(m) for m in missing)
msg += 'Missing: %s' % ','.join(safe_repr(m) for m in missing)
if mismatched:
if msg:
if len(msg) > 0:
msg += '; '
msg += 'Mismatched values: %s' % ','.join(mismatched)
self.fail(msg)
Expand Down
2 changes: 1 addition & 1 deletion dim/dim/models/ip.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class Pool(db.Model, WithAttr):
vlan = relationship(Vlan)
owner = relationship('Group')
layer3domain = relationship(Layer3Domain)
ipblocks = relationship("Ipblock", backref="pool")
ipblocks = relationship("Ipblock", backref="pool", order_by='Ipblock.priority')
subnets = synonym('ipblocks')

@property
Expand Down

0 comments on commit 5c801fb

Please sign in to comment.