Allow for zones / pools with no attributes
if a zone or a pool with no attributes use passed to the `attribute` filter, we can get a RelationNotLoaded error, this catches the error, and adds an empty dict in place. Change-Id: Iac405643d119feb95f6d0931c5ba6935e899a9f6 Closes-Bug: #1639748
This commit is contained in:
parent
4e02eb8600
commit
438e39eb8c
|
@ -15,6 +15,7 @@ import six
|
|||
from oslo_log import log as logging
|
||||
from oslo_utils.strutils import bool_from_string
|
||||
|
||||
from designate import exceptions
|
||||
from designate.objects import PoolAttributeList
|
||||
from designate.scheduler.filters import base
|
||||
|
||||
|
@ -57,11 +58,16 @@ class AttributeFilter(base.Filter):
|
|||
|
||||
def filter(self, context, pools, zone):
|
||||
|
||||
zone_attributes = zone.attributes.to_dict()
|
||||
try:
|
||||
zone_attributes = zone.attributes.to_dict()
|
||||
except exceptions.RelationNotLoaded:
|
||||
zone_attributes = {}
|
||||
|
||||
def evaluate_pool(pool):
|
||||
|
||||
pool_attributes = pool.attributes.to_dict()
|
||||
try:
|
||||
pool_attributes = pool.attributes.to_dict()
|
||||
except exceptions.RelationNotLoaded:
|
||||
pool_attributes = {}
|
||||
|
||||
# Check if the keys requested exist in this pool
|
||||
if not {key for key in six.iterkeys(pool_attributes)}.issuperset(
|
||||
|
|
Loading…
Reference in New Issue