Merge "Handle errors calculating dep_attrs for nested get_attr"
This commit is contained in:
commit
d74bb6d146
|
@ -16,6 +16,7 @@ import hashlib
|
||||||
import itertools
|
import itertools
|
||||||
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
|
from oslo_log import log as logging
|
||||||
from oslo_serialization import jsonutils
|
from oslo_serialization import jsonutils
|
||||||
import six
|
import six
|
||||||
from six.moves.urllib import parse as urlparse
|
from six.moves.urllib import parse as urlparse
|
||||||
|
@ -27,6 +28,9 @@ from heat.common.i18n import _
|
||||||
from heat.engine import attributes
|
from heat.engine import attributes
|
||||||
from heat.engine import function
|
from heat.engine import function
|
||||||
|
|
||||||
|
|
||||||
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
opts = [
|
opts = [
|
||||||
cfg.IntOpt('limit_iterators',
|
cfg.IntOpt('limit_iterators',
|
||||||
default=200,
|
default=200,
|
||||||
|
@ -182,9 +186,17 @@ class GetAttThenSelect(function.Function):
|
||||||
raise exception.InvalidTemplateReference(resource=resource_name,
|
raise exception.InvalidTemplateReference(resource=resource_name,
|
||||||
key=path)
|
key=path)
|
||||||
|
|
||||||
|
def _attr_path(self):
|
||||||
|
return function.resolve(self._attribute)
|
||||||
|
|
||||||
def dep_attrs(self, resource_name):
|
def dep_attrs(self, resource_name):
|
||||||
if self._res_name() == resource_name:
|
if self._res_name() == resource_name:
|
||||||
attrs = [function.resolve(self._attribute)]
|
try:
|
||||||
|
attrs = [self._attr_path()]
|
||||||
|
except Exception as exc:
|
||||||
|
LOG.debug("Ignoring exception calculating required attributes"
|
||||||
|
": %s %s", type(exc).__name__, six.text_type(exc))
|
||||||
|
attrs = []
|
||||||
else:
|
else:
|
||||||
attrs = []
|
attrs = []
|
||||||
return itertools.chain(super(GetAttThenSelect,
|
return itertools.chain(super(GetAttThenSelect,
|
||||||
|
@ -266,18 +278,13 @@ class GetAtt(GetAttThenSelect):
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def dep_attrs(self, resource_name):
|
def _attr_path(self):
|
||||||
if self._res_name() == resource_name:
|
path = function.resolve(self._path_components)
|
||||||
path = function.resolve(self._path_components)
|
attr = function.resolve(self._attribute)
|
||||||
attr = [function.resolve(self._attribute)]
|
if path:
|
||||||
if path:
|
return tuple([attr] + path)
|
||||||
attrs = [tuple(attr + path)]
|
|
||||||
else:
|
|
||||||
attrs = attr
|
|
||||||
else:
|
else:
|
||||||
attrs = []
|
return attr
|
||||||
return itertools.chain(function.dep_attrs(self.args, resource_name),
|
|
||||||
attrs)
|
|
||||||
|
|
||||||
|
|
||||||
class GetAttAllAttributes(GetAtt):
|
class GetAttAllAttributes(GetAtt):
|
||||||
|
@ -311,16 +318,10 @@ class GetAttAllAttributes(GetAtt):
|
||||||
raise TypeError(_('Argument to "%s" must be a list') %
|
raise TypeError(_('Argument to "%s" must be a list') %
|
||||||
self.fn_name)
|
self.fn_name)
|
||||||
|
|
||||||
def dep_attrs(self, resource_name):
|
def _attr_path(self):
|
||||||
"""Check if there is no attribute_name defined, return empty chain."""
|
if self._attribute is None:
|
||||||
if self._attribute is not None:
|
return attributes.ALL_ATTRIBUTES
|
||||||
return super(GetAttAllAttributes, self).dep_attrs(resource_name)
|
return super(GetAttAllAttributes, self)._attr_path()
|
||||||
elif self._res_name() == resource_name:
|
|
||||||
attrs = [attributes.ALL_ATTRIBUTES]
|
|
||||||
else:
|
|
||||||
attrs = []
|
|
||||||
return itertools.chain(function.dep_attrs(self.args,
|
|
||||||
resource_name), attrs)
|
|
||||||
|
|
||||||
def result(self):
|
def result(self):
|
||||||
if self._attribute is None:
|
if self._attribute is None:
|
||||||
|
|
Loading…
Reference in New Issue