コード例 #1
0
ファイル: resource_group.py プロジェクト: zosocanuck/heat
    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
        ]
コード例 #2
0
ファイル: resource_group.py プロジェクト: openstack/heat
    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]
コード例 #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)
コード例 #4
0
ファイル: functions.py プロジェクト: aawm/heat
    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)
コード例 #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
        ]
コード例 #6
0
ファイル: stack.py プロジェクト: okozachenko1203/heat
 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)
コード例 #7
0
ファイル: template_resource.py プロジェクト: hongbin/heat
    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)
コード例 #8
0
ファイル: template_resource.py プロジェクト: rrasouli/heat
    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)
コード例 #9
0
ファイル: stack.py プロジェクト: noironetworks/heat
 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)
コード例 #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
        ]
コード例 #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)
コード例 #12
0
ファイル: software_deployment.py プロジェクト: junxu/heat
    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)
コード例 #13
0
ファイル: resource_chain.py プロジェクト: noironetworks/heat
    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]
コード例 #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)
コード例 #15
0
ファイル: template_resource.py プロジェクト: zosocanuck/heat
    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)
コード例 #16
0
ファイル: cluster.py プロジェクト: odmanV2/heat
    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)
コード例 #17
0
ファイル: functions.py プロジェクト: xglhjk6/heat
    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)
コード例 #18
0
ファイル: cluster.py プロジェクト: aaratn/heat
    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)
コード例 #19
0
ファイル: resource.py プロジェクト: rmery/heat
    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)
コード例 #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)
コード例 #21
0
ファイル: resource.py プロジェクト: sirushtim/heat
    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)
コード例 #22
0
ファイル: software_deployment.py プロジェクト: frank6866/heat
    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)
コード例 #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]
コード例 #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)
コード例 #25
0
    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)
コード例 #26
0
ファイル: template_resource.py プロジェクト: rabi/heat
    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)
コード例 #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
コード例 #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
コード例 #29
0
ファイル: resource_group.py プロジェクト: pratikmallya/heat
    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]
コード例 #30
0
    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
コード例 #31
0
ファイル: resource.py プロジェクト: aawm/heat
    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)
コード例 #32
0
ファイル: cluster.py プロジェクト: lsuchanek95/templates
    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)
コード例 #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)
コード例 #34
0
ファイル: resource_group.py プロジェクト: arbylee/heat
    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)
コード例 #35
0
ファイル: template_resource.py プロジェクト: BeenzSyed/heat
    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)
コード例 #36
0
ファイル: template_resource.py プロジェクト: dfsis/heat
    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)
コード例 #37
0
ファイル: resource_group.py プロジェクト: rabi/heat
    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]
コード例 #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)
コード例 #39
0
ファイル: stack.py プロジェクト: sizowie/heat
 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)
コード例 #40
0
ファイル: server_base.py プロジェクト: dulek/heat
 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)
コード例 #41
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)