def get_attribute(self, key, *path): if key == self.REMOVED_RSRC_LIST: return self._current_blacklist() if key == self.ATTR_ATTRIBUTES and not path: raise exception.InvalidTemplateAttribute(resource=self.name, key=key) is_resource_ref = (key.startswith("resource.") and not path and (len(key.split('.', 2)) == 2)) if is_resource_ref: output_name = self.REFS_MAP else: output_name = self._attribute_output_name(key, *path) if self.resource_id is not None: try: output = self.get_output(output_name) except (exception.NotFound, exception.TemplateOutputError) as op_err: LOG.debug('Falling back to grouputils due to %s', op_err) else: if is_resource_ref: try: target = key.split('.', 2)[1] return output[target] except KeyError: raise exception.NotFound(_("Member '%(mem)s' not " "found in group resource " "'%(grp)s'.") % {'mem': target, 'grp': self.name}) if key == self.REFS: return attributes.select_from_attribute(output, path) return output if key.startswith("resource."): return grouputils.get_nested_attrs(self, key, False, *path) names = self._resource_names() if key == self.REFS: vals = [grouputils.get_rsrc_id(self, key, False, n) for n in names] return attributes.select_from_attribute(vals, path) if key == self.REFS_MAP: refs_map = {n: grouputils.get_rsrc_id(self, key, False, n) for n in names} return refs_map if key == self.ATTR_ATTRIBUTES: return dict((n, grouputils.get_rsrc_attr( self, key, False, n, *path)) for n in names) path = [key] + list(path) return [grouputils.get_rsrc_attr(self, key, False, n, *path) for n in names]
def get_attribute(self, key, *path): if key.startswith("resource."): return grouputils.get_nested_attrs(self, key, False, *path) names = self._resource_names() if key == self.REFS: vals = [grouputils.get_rsrc_id(self, key, False, n) for n in names] return attributes.select_from_attribute(vals, path) if key == self.REFS_MAP: refs_map = {n: grouputils.get_rsrc_id(self, key, False, n) for n in names} return refs_map if key == self.ATTR_ATTRIBUTES: if not path: raise exception.InvalidTemplateAttribute( resource=self.name, key=key) return dict((n, grouputils.get_rsrc_attr( self, key, False, n, *path)) for n in names) path = [key] + list(path) return [grouputils.get_rsrc_attr(self, key, False, n, *path) for n in names]
def get_attribute(self, key, *path): if key.startswith('resource.'): return grouputils.get_nested_attrs(self, key, False, *path) resource_types = self.properties[self.RESOURCES] names = self._resource_names(resource_types) if key == self.REFS: vals = [grouputils.get_rsrc_id(self, key, False, n) for n in names] return attributes.select_from_attribute(vals, path) if key == self.ATTR_ATTRIBUTES: if not path: raise exception.InvalidTemplateAttribute( resource=self.name, key=key) return dict((n, grouputils.get_rsrc_attr( self, key, False, n, *path)) for n in names) path = [key] + list(path) return [grouputils.get_rsrc_attr(self, key, False, n, *path) for n in names]
def FnGetAtt(self, key, *path): if key.startswith("resource."): return grouputils.get_nested_attrs(self, key, False, *path) names = self._resource_names() if key == self.REFS: vals = [grouputils.get_rsrc_id(self, key, False, n) for n in names] return attributes.select_from_attribute(vals, path) if key == self.ATTR_ATTRIBUTES: if not path: raise exception.InvalidTemplateAttribute(resource=self.name, key=key) return dict( (n, grouputils.get_rsrc_attr(self, key, False, n, *path)) for n in names) path = [key] + list(path) return [ grouputils.get_rsrc_attr(self, key, False, n, *path) for n in names ]
def get_attribute(self, key, *path): if key == self.ATTR_ATTRIBUTES and not path: raise exception.InvalidTemplateAttribute(resource=self.name, key=key) try: output = self.get_output(self._attribute_output_name(key, *path)) except (exception.NotFound, exception.TemplateOutputError) as op_err: resource_types = self.properties[self.RESOURCES] names = self._resource_names(resource_types) if key.startswith('resource.'): target = key.split('.', 2)[1] if target not in names: raise exception.NotFound( _("Member '%(mem)s' not " "found in group resource " "'%(grp)s'.") % { 'mem': target, 'grp': self.name }) LOG.debug('Falling back to grouputils due to %s', op_err) else: if key == self.REFS: return attributes.select_from_attribute(output, path) return output if key.startswith('resource.'): return grouputils.get_nested_attrs(self, key, False, *path) if key == self.REFS: vals = [grouputils.get_rsrc_id(self, key, False, n) for n in names] return attributes.select_from_attribute(vals, path) if key == self.ATTR_ATTRIBUTES: return dict( (n, grouputils.get_rsrc_attr(self, key, False, n, *path)) for n in names) path = [key] + list(path) return [ grouputils.get_rsrc_attr(self, key, False, n, *path) for n in names ]
def get_attribute(self, key, *path): if key == self.ATTR_ATTRIBUTES and not path: raise exception.InvalidTemplateAttribute(resource=self.name, key=key) try: output = self.get_output(self._attribute_output_name(key, *path)) except (exception.NotFound, exception.TemplateOutputError) as op_err: resource_types = self.properties[self.RESOURCES] names = self._resource_names(resource_types) if key.startswith('resource.'): target = key.split('.', 2)[1] if target not in names: raise exception.NotFound(_("Member '%(mem)s' not " "found in group resource " "'%(grp)s'.") % {'mem': target, 'grp': self.name}) LOG.debug('Falling back to grouputils due to %s', op_err) else: if key == self.REFS: return attributes.select_from_attribute(output, path) return output if key.startswith('resource.'): return grouputils.get_nested_attrs(self, key, False, *path) if key == self.REFS: vals = [grouputils.get_rsrc_id(self, key, False, n) for n in names] return attributes.select_from_attribute(vals, path) if key == self.ATTR_ATTRIBUTES: return dict((n, grouputils.get_rsrc_attr( self, key, False, n, *path)) for n in names) path = [key] + list(path) return [grouputils.get_rsrc_attr(self, key, False, n, *path) for n in names]