Beispiel #1
0
    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
        ]
Beispiel #2
0
    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]
Beispiel #3
0
    def result(self):
        attribute = super(GetAttThenSelect, self).result()
        if attribute is None:
            return None

        path_components = function.resolve(self._path_components)
        return attributes.select_from_attribute(attribute, path_components)
Beispiel #4
0
    def result(self):
        attribute = super(GetAttThenSelect, self).result()
        if attribute is None:
            return None

        path_components = function.resolve(self._path_components)
        return attributes.select_from_attribute(attribute, path_components)
Beispiel #5
0
    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.REMOVED_RSRC_LIST:
            return self._current_blacklist()
        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
        ]
Beispiel #6
0
 def get_attribute(self, key, *path):
     if key and not key.startswith('Outputs.'):
         raise exception.InvalidTemplateAttribute(resource=self.name,
                                                  key=key)
     try:
         attribute = self.get_output(key.partition('.')[-1])
     except exception.NotFound:
         raise exception.InvalidTemplateAttribute(resource=self.name,
                                                  key=key)
     return attributes.select_from_attribute(attribute, path)
Beispiel #7
0
    def get_attribute(self, key, *path):
        if self.resource_id is None:
            return None

        # first look for explicit resource.x.y
        if key.startswith('resource.'):
            return grouputils.get_nested_attrs(self, key, False, *path)

        # then look for normal outputs
        return attributes.select_from_attribute(self.get_output(key), path)
Beispiel #8
0
    def get_attribute(self, key, *path):
        if self.resource_id is None:
            return None

        # first look for explicit resource.x.y
        if key.startswith('resource.'):
            return grouputils.get_nested_attrs(self, key, False, *path)

        # then look for normal outputs
        return attributes.select_from_attribute(self.get_output(key), path)
Beispiel #9
0
 def get_attribute(self, key, *path):
     if key and not key.startswith('Outputs.'):
         raise exception.InvalidTemplateAttribute(resource=self.name,
                                                  key=key)
     try:
         attribute = self.get_output(key.partition('.')[-1])
     except exception.NotFound:
         raise exception.InvalidTemplateAttribute(resource=self.name,
                                                  key=key)
     return attributes.select_from_attribute(attribute, path)
Beispiel #10
0
    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
        ]
Beispiel #11
0
    def FnGetAtt(self, key, *path):
        rg = super(SoftwareDeploymentGroup, self)
        if key == self.STDOUTS:
            n_attr = SoftwareDeployment.STDOUT
        elif key == self.STDERRS:
            n_attr = SoftwareDeployment.STDERR
        elif key == self.STATUS_CODES:
            n_attr = SoftwareDeployment.STATUS_CODE
        else:
            return None

        rg_attr = rg.FnGetAtt(rg.ATTR_ATTRIBUTES, n_attr)
        return attributes.select_from_attribute(rg_attr, path)
Beispiel #12
0
    def FnGetAtt(self, key, *path):
        rg = super(SoftwareDeploymentGroup, self)
        if key == self.STDOUTS:
            n_attr = SoftwareDeployment.STDOUT
        elif key == self.STDERRS:
            n_attr = SoftwareDeployment.STDERR
        elif key == self.STATUS_CODES:
            n_attr = SoftwareDeployment.STATUS_CODE
        else:
            return None

        rg_attr = rg.FnGetAtt(rg.ATTR_ATTRIBUTES, n_attr)
        return attributes.select_from_attribute(rg_attr, path)
Beispiel #13
0
    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]
Beispiel #14
0
    def result(self):
        attr_name = function.resolve(self._attribute)

        resource = self._resource()
        if self._result_ready(resource):
            attribute = resource.FnGetAtt(attr_name)
        else:
            attribute = None

        if attribute is None:
            return None

        path_components = function.resolve(self._path_components)
        return attributes.select_from_attribute(attribute, path_components)
Beispiel #15
0
    def get_attribute(self, key, *path):
        if self.resource_id is None:
            return None

        # first look for explicit resource.x.y
        if key.startswith('resource.'):
            return grouputils.get_nested_attrs(self, key, False, *path)

        # then look for normal outputs
        try:
            return attributes.select_from_attribute(self.get_output(key), path)
        except exception.NotFound:
            raise exception.InvalidTemplateAttribute(resource=self.name,
                                                     key=key)
Beispiel #16
0
    def get_attribute(self, key, *path):
        if self.resource_id is None:
            return None

        if key == self.ATTR_COLLECT:
            if not path:
                raise exception.InvalidTemplateAttribute(resource=self.name,
                                                         key=key)
            attrs = self.client().collect_cluster_attrs(
                self.resource_id, path[0])
            attr = [attr.attr_value for attr in attrs]
            return attributes.select_from_attribute(attr, path[1:])
        else:
            return super(Cluster, self).get_attribute(key, *path)
Beispiel #17
0
    def result(self):
        attr_name = function.resolve(self._attribute)

        resource = self._resource()
        if self._result_ready(resource):
            attribute = resource.FnGetAtt(attr_name)
        else:
            attribute = None

        if attribute is None:
            return None

        path_components = function.resolve(self._path_components)
        return attributes.select_from_attribute(attribute, path_components)
Beispiel #18
0
    def get_attribute(self, key, *path):
        if self.resource_id is None:
            return None

        if key == self.ATTR_COLLECT:
            if not path:
                raise exception.InvalidTemplateAttribute(
                    resource=self.name, key=key)
            attrs = self.client().collect_cluster_attrs(
                self.resource_id, path[0])
            attr = [attr.attr_value for attr in attrs]
            return attributes.select_from_attribute(attr, path[1:])
        else:
            return super(Cluster, self).get_attribute(key, *path)
Beispiel #19
0
    def FnGetAtt(self, key, *path):
        """
        For the intrinsic function Fn::GetAtt.

        :param key: the attribute key.
        :param path: a list of path components to select from the attribute.
        :returns: the attribute value.
        """
        try:
            attribute = self.attributes[key]
        except KeyError:
            raise exception.InvalidTemplateAttribute(resource=self.name, key=key)
        else:
            return attributes.select_from_attribute(attribute, path)
Beispiel #20
0
    def get_attribute(self, key, *path):
        if self.resource_id is None:
            return None

        # first look for explicit resource.x.y
        if key.startswith('resource.'):
            return grouputils.get_nested_attrs(self, key, False, *path)

        # then look for normal outputs
        try:
            return attributes.select_from_attribute(self.get_output(key),
                                                    path)
        except exception.NotFound:
            raise exception.InvalidTemplateAttribute(resource=self.name,
                                                     key=key)
Beispiel #21
0
    def FnGetAtt(self, key, *path):
        '''
        For the intrinsic function Fn::GetAtt.

        :param key: the attribute key.
        :param path: a list of path components to select from the attribute.
        :returns: the attribute value.
        '''
        try:
            attribute = self.attributes[key]
        except KeyError:
            raise exception.InvalidTemplateAttribute(resource=self.name,
                                                     key=key)
        else:
            return attributes.select_from_attribute(attribute, path)
Beispiel #22
0
    def FnGetAtt(self, key, *path):
        rg = super(SoftwareDeploymentGroup, self)
        if key == self.STDOUTS:
            n_attr = SoftwareDeployment.STDOUT
        elif key == self.STDERRS:
            n_attr = SoftwareDeployment.STDERR
        elif key == self.STATUS_CODES:
            n_attr = SoftwareDeployment.STATUS_CODE
        else:
            # Allow any attribute valid for a single SoftwareDeployment
            # including arbitrary outputs, so we can't validate here
            n_attr = key

        rg_attr = rg.FnGetAtt(rg.ATTR_ATTRIBUTES, n_attr)
        return attributes.select_from_attribute(rg_attr, path)
Beispiel #23
0
    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]
Beispiel #24
0
    def get_attribute(self, key, *path):
        stack = self.nested()
        if stack is None:
            return None

        # first look for explicit resource.x.y
        if key.startswith('resource.'):
            return grouputils.get_nested_attrs(self, key, False, *path)

        # then look for normal outputs
        if key in stack.outputs:
            return attributes.select_from_attribute(self.get_output(key), path)

        # otherwise the key must be wrong.
        raise exception.InvalidTemplateAttribute(resource=self.name, key=key)
    def get_attribute(self, key, *path):
        rg = super(SoftwareDeploymentGroup, self)
        if key == self.STDOUTS:
            n_attr = SoftwareDeployment.STDOUT
        elif key == self.STDERRS:
            n_attr = SoftwareDeployment.STDERR
        elif key == self.STATUS_CODES:
            n_attr = SoftwareDeployment.STATUS_CODE
        else:
            # Allow any attribute valid for a single SoftwareDeployment
            # including arbitrary outputs, so we can't validate here
            n_attr = key

        rg_attr = rg.get_attribute(rg.ATTR_ATTRIBUTES, n_attr)
        return attributes.select_from_attribute(rg_attr, path)
Beispiel #26
0
    def get_attribute(self, key, *path):
        stack = self.nested()
        if stack is None:
            return None

        # first look for explicit resource.x.y
        if key.startswith('resource.'):
            return grouputils.get_nested_attrs(self, key, False, *path)

        # then look for normal outputs
        if key in stack.outputs:
            return attributes.select_from_attribute(self.get_output(key), path)

        # otherwise the key must be wrong.
        raise exception.InvalidTemplateAttribute(resource=self.name,
                                                 key=key)
Beispiel #27
0
    def FnGetAtt(self, key, *path):
        '''
        Resource attributes map to deployment outputs values
        '''
        sd = self.heat().software_deployments.get(self.resource_id)
        if key in sd.output_values:
            attribute = sd.output_values.get(key)
            return attributes.select_from_attribute(attribute, path)

        # Since there is no value for this key yet, check the output schemas
        # to find out if the key is valid
        sc = self.heat().software_configs.get(self.properties[self.CONFIG])
        output_keys = [output['name'] for output in sc.outputs]
        if key not in output_keys and key not in self.ATTRIBUTES:
            raise exception.InvalidTemplateAttribute(resource=self.name,
                                                     key=key)
        return None
Beispiel #28
0
    def FnGetAtt(self, key, *path):
        """
        Resource attributes map to deployment outputs values
        """
        sd = self.rpc_client().show_software_deployment(self.context, self.resource_id)
        ov = sd[rpc_api.SOFTWARE_DEPLOYMENT_OUTPUT_VALUES] or {}
        if key in ov:
            attribute = ov.get(key)
            return attributes.select_from_attribute(attribute, path)

        # Since there is no value for this key yet, check the output schemas
        # to find out if the key is valid
        sc = self.rpc_client().show_software_config(self.context, self.properties[self.CONFIG])
        outputs = sc[rpc_api.SOFTWARE_CONFIG_OUTPUTS] or []
        output_keys = [output["name"] for output in outputs]
        if key not in output_keys and key not in self.ATTRIBUTES:
            raise exception.InvalidTemplateAttribute(resource=self.name, key=key)
        return None
Beispiel #29
0
    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):
        """Resource attributes map to deployment outputs values."""
        sd = self.rpc_client().show_software_deployment(
            self.context, self.resource_id)
        ov = sd[rpc_api.SOFTWARE_DEPLOYMENT_OUTPUT_VALUES] or {}
        if key in ov:
            attribute = ov.get(key)
            return attributes.select_from_attribute(attribute, path)

        # Since there is no value for this key yet, check the output schemas
        # to find out if the key is valid
        sc = self.rpc_client().show_software_config(
            self.context, self.properties[self.CONFIG])
        outputs = sc[rpc_api.SOFTWARE_CONFIG_OUTPUTS] or []
        output_keys = [output['name'] for output in outputs]
        if key not in output_keys and key not in self.ATTRIBUTES:
            raise exception.InvalidTemplateAttribute(resource=self.name,
                                                     key=key)
        return None
Beispiel #31
0
    def FnGetAtt(self, key, *path):
        '''
        For the intrinsic function Fn::GetAtt.

        :param key: the attribute key.
        :param path: a list of path components to select from the attribute.
        :returns: the attribute value.
        '''
        if self.stack.has_cache_data():
            # Load from cache for lightweight resources.
            attribute = self.stack.cache_data_resource_attribute(
                self.name, key)
        else:
            try:
                attribute = self.attributes[key]
            except KeyError:
                raise exception.InvalidTemplateAttribute(resource=self.name,
                                                         key=key)

        return attributes.select_from_attribute(attribute, path)
Beispiel #32
0
    def get_attribute(self, key, *path):
        def _collect_cluster_attrs(attr_path):
            parser = parse(attr_path)
            cluster = self.client().get_cluster(self.resource_id)
            nodes_attrs = []
            for node_id in cluster.node_ids:
                node = self.client().get_node(node_id, details=True)
                node_info = node.to_dict()
                matches = [m.value for m in parser.find(node_info)]
                nodes_attrs.append(matches[0])
            return nodes_attrs

        if key == self.ATTR_COLLECT:
            if not path:
                raise exception.InvalidTemplateAttribute(
                    resource=self.name, key=key)
            attrs = _collect_cluster_attrs(path[0])
            return attributes.select_from_attribute(attrs, path[1:])
        else:
            return super(Cluster, self).get_attribute(key, *path)
Beispiel #33
0
    def FnGetAtt(self, key, *path):
        '''
        For the intrinsic function Fn::GetAtt.

        :param key: the attribute key.
        :param path: a list of path components to select from the attribute.
        :returns: the attribute value.
        '''
        if self.stack.has_cache_data():
            # Load from cache for lightweight resources.
            attribute = self.stack.cache_data_resource_attribute(
                self.name, key)
        else:
            try:
                attribute = self.attributes[key]
            except KeyError:
                raise exception.InvalidTemplateAttribute(resource=self.name,
                                                         key=key)

        return attributes.select_from_attribute(attribute, path)
Beispiel #34
0
    def FnGetAtt(self, key, *path):
        nested_stack = self.nested()

        def get_rsrc_attr(resource_name, *attr_path):
            try:
                resource = nested_stack[resource_name]
            except KeyError:
                raise exception.InvalidTemplateAttribute(resource=self.name,
                                                         key=key)
            if not attr_path:
                return resource.FnGetRefId()
            else:
                return resource.FnGetAtt(*attr_path)

        if key.startswith("resource."):
            path = key.split(".", 2)[1:] + list(path)
            return get_rsrc_attr(*path)
        else:
            count = self.properties[self.COUNT]
            attr = [] if key == self.REFS else [key]
            attribute = [get_rsrc_attr(str(n), *attr) for n in range(count)]
            return attributes.select_from_attribute(attribute, path)
Beispiel #35
0
    def FnGetAtt(self, key, *path):
        stack = self.nested()
        if stack is None:
            return None

        def _get_inner_resource(resource_name):
            if self.nested() is not None:
                try:
                    return self.nested()[resource_name]
                except KeyError:
                    raise exception.ResourceNotFound(
                        resource_name=resource_name,
                        stack_name=self.nested().name)

        def get_rsrc_attr(resource_name, *attr_path):
            resource = _get_inner_resource(resource_name)
            return resource.FnGetAtt(*attr_path)

        def get_rsrc_id(resource_name):
            resource = _get_inner_resource(resource_name)
            return resource.FnGetRefId()

        # first look for explicit resource.x.y
        if key.startswith('resource.'):
            npath = key.split(".", 2)[1:] + list(path)
            if len(npath) > 1:
                return get_rsrc_attr(*npath)
            else:
                return get_rsrc_id(*npath)

        # then look for normal outputs
        if key in stack.outputs:
            return attributes.select_from_attribute(stack.output(key), path)

        # otherwise the key must be wrong.
        raise exception.InvalidTemplateAttribute(resource=self.name,
                                                 key=key)
Beispiel #36
0
    def FnGetAtt(self, key, *path):
        stack = self.nested()
        if stack is None:
            return None

        def _get_inner_resource(resource_name):
            if self.nested() is not None:
                try:
                    return self.nested()[resource_name]
                except KeyError:
                    raise exception.ResourceNotFound(
                        resource_name=resource_name,
                        stack_name=self.nested().name)

        def get_rsrc_attr(resource_name, *attr_path):
            resource = _get_inner_resource(resource_name)
            return resource.FnGetAtt(*attr_path)

        def get_rsrc_id(resource_name):
            resource = _get_inner_resource(resource_name)
            return resource.FnGetRefId()

        # first look for explicit resource.x.y
        if key.startswith('resource.'):
            npath = key.split(".", 2)[1:] + list(path)
            if len(npath) > 1:
                return get_rsrc_attr(*npath)
            else:
                return get_rsrc_id(*npath)

        # then look for normal outputs
        if key in stack.outputs:
            return attributes.select_from_attribute(stack.output(key), path)

        # otherwise the key must be wrong.
        raise exception.InvalidTemplateAttribute(resource=self.name,
                                                 key=key)
Beispiel #37
0
    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.REMOVED_RSRC_LIST:
            return self._current_blacklist()
        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]
Beispiel #38
0
    def get_attribute(self, key, *path):
        rg = super(SoftwareDeploymentGroup, self)
        n_attr = self._member_attribute_name(key)

        rg_attr = rg.get_attribute(rg.ATTR_ATTRIBUTES, n_attr)
        return attributes.select_from_attribute(rg_attr, path)
Beispiel #39
0
 def FnGetAtt(self, key, *path):
     if key and not key.startswith("Outputs."):
         raise exception.InvalidTemplateAttribute(resource=self.name, key=key)
     attribute = self.get_output(key.partition(".")[-1])
     return attributes.select_from_attribute(attribute, path)
Beispiel #40
0
 def get_attribute(self, key, *path):
     if key == self.OS_COLLECT_CONFIG:
         occ = self.metadata_get().get('os-collect-config', {})
         return attributes.select_from_attribute(occ, path)
     else:
         return super(BaseServer, self).get_attribute(key, *path)
    def get_attribute(self, key, *path):
        rg = super(SoftwareDeploymentGroup, self)
        n_attr = self._member_attribute_name(key)

        rg_attr = rg.get_attribute(rg.ATTR_ATTRIBUTES, n_attr)
        return attributes.select_from_attribute(rg_attr, path)