Merge "load default pool from storage"

This commit is contained in:
Jenkins 2017-03-01 17:01:55 +00:00 committed by Gerrit Code Review
commit 051888c524
2 changed files with 8 additions and 4 deletions

View File

@ -45,9 +45,12 @@ class InDoubtDefaultPoolFilter(base.Filter):
"""
def filter(self, context, pools, zone):
if len(pools):
if len(pools) > 1:
default_pool_id = cfg.CONF['service:central'].default_pool_id
default_pool = objects.Pool(id=default_pool_id)
try:
default_pool = self.storage.get_pool(context, default_pool_id)
except Exception:
return pools
if default_pool in pools:
pools = objects.PoolList()

View File

@ -431,13 +431,14 @@ class SchedulerInDoubtDefaultPoolFilterTest(SchedulerFilterTest):
def test_pools_with_default(self):
pools = objects.PoolList.from_list(
[
{"id": "794ccc2c-d751-44fe-b57f-8894c9f5c842"},
{"id": "6c346011-e581-429b-a7a2-6cdf0aba91c3"},
{"id": "5fabcd37-262c-4cf3-8625-7f419434b6df"}
]
)
pools = self.test_filter.filter(self.context, pools, self.zone)
self.assertEqual(pools[0].id, "794ccc2c-d751-44fe-b57f-8894c9f5c842")
self.assertEqual(1, len(pools))
self.assertEqual(pools[0].id, "6c346011-e581-429b-a7a2-6cdf0aba91c3")
def test_pools_without_default(self):
pools = objects.PoolList.from_list(