當前位置: 首頁>>代碼示例>>Python>>正文


Python Release.get_all_components方法代碼示例

本文整理匯總了Python中nailgun.objects.Release.get_all_components方法的典型用法代碼示例。如果您正苦於以下問題:Python Release.get_all_components方法的具體用法?Python Release.get_all_components怎麽用?Python Release.get_all_components使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在nailgun.objects.Release的用法示例。


在下文中一共展示了Release.get_all_components方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: GET

# 需要導入模塊: from nailgun.objects import Release [as 別名]
# 或者: from nailgun.objects.Release import get_all_components [as 別名]
    def GET(self, release_id):
        """:returns: JSONized component data for release and releated plugins.

        :http: * 200 (OK)
               * 404 (release not found in db)
        """
        release = self.get_object_or_404(Release, release_id)
        components = Release.get_all_components(release)

        return [ComponentSerializer.serialize(c) for c in components]
開發者ID:dnikishov,項目名稱:fuel-web,代碼行數:12,代碼來源:component.py

示例2: get_cluster_attributes_by_components

# 需要導入模塊: from nailgun.objects import Release [as 別名]
# 或者: from nailgun.objects.Release import get_all_components [as 別名]
    def get_cluster_attributes_by_components(cls, components, release_id):
        """Enable cluster attributes by given components

        :param components: list of component names
        :type components: list of strings
        :param release_id: Release model id
        :type release_id: str
        :returns: dict -- objects with enabled attributes for cluster
        """

        def _update_attributes_dict_by_binds_exp(bind_exp, value):
            """Update cluster and attributes data with bound values

            :param bind_exp: path to specific attribute for model in format
                             model:some.attribute.value. Model can be
                             settings|cluster
            :type bind_exp: str
            :param value: value for specific attribute
            :type value: bool|str|int
            :returns: None
            """
            model, attr_expr = bind_exp.split(':')
            if model not in ('settings', 'cluster'):
                return

            path_items = attr_expr.split('.')
            path_items.insert(0, model)
            attributes = cluster_attributes
            for i in six.moves.range(0, len(path_items) - 1):
                attributes = attributes.setdefault(path_items[i], {})
            attributes[path_items[-1]] = value

        release = Release.get_by_uid(release_id)
        cluster_attributes = {}
        for component in Release.get_all_components(release):
            if component['name'] in components:
                for bind_item in component.get('bind', []):
                    if isinstance(bind_item, six.string_types):
                        _update_attributes_dict_by_binds_exp(bind_item, True)
                    elif isinstance(bind_item, list):
                        _update_attributes_dict_by_binds_exp(bind_item[0],
                                                             bind_item[1])
        return {
            'editable': cluster_attributes.get('settings', {}),
            'cluster': cluster_attributes.get('cluster', {})
        }
開發者ID:ansumanbebarta,項目名稱:fuel-web,代碼行數:48,代碼來源:cluster.py


注:本文中的nailgun.objects.Release.get_all_components方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。