• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python utils.dict_merge函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中nailgun.utils.dict_merge函数的典型用法代码示例。如果您正苦于以下问题:Python dict_merge函数的具体用法?Python dict_merge怎么用?Python dict_merge使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了dict_merge函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: get_common_attrs

    def get_common_attrs(cls, cluster):
        """Cluster attributes."""
        attrs = objects.Attributes.merged_attrs_values(
            cluster.attributes
        )
        release = objects.Release.get_by_uid(cluster.pending_release_id) \
            if cluster.status == consts.CLUSTER_STATUSES.update \
            else cluster.release
        attrs['deployment_mode'] = cluster.mode
        attrs['deployment_id'] = cluster.id
        attrs['openstack_version'] = release.version
        attrs['fuel_version'] = cluster.fuel_version
        attrs.update(
            objects.Release.get_orchestrator_data_dict(release)
        )
        attrs['nodes'] = cls.node_list(get_nodes_not_for_deletion(cluster))

        for node in attrs['nodes']:
            if node['role'] in 'cinder':
                attrs['use_cinder'] = True

        cls.set_storage_parameters(cluster, attrs)
        cls.set_primary_mongo(attrs['nodes'])

        attrs = dict_merge(
            attrs,
            cls.get_net_provider_serializer(cluster).get_common_attrs(cluster,
                                                                      attrs))

        return attrs
开发者ID:iberezovskiy,项目名称:fuel-web,代码行数:30,代码来源:deployment_serializers.py


示例2: create_attributes

    def create_attributes(cls, instance, editable_attributes=None):
        """Create attributes for Cluster instance, generate their values

        (see :func:`Attributes.generate_fields`)

        :param instance: Cluster instance
        :param editable_attributes: key-value dictionary represents editable
            attributes that will be merged with default editable attributes
        :returns: None
        """
        merged_editable_attributes = \
            cls.get_default_editable_attributes(instance)
        if editable_attributes:
            merged_editable_attributes = dict_merge(
                merged_editable_attributes, editable_attributes)
        attributes = Attributes.create(
            {
                "editable": merged_editable_attributes,
                "generated": instance.release.attributes_metadata.get(
                    "generated"
                ),
                "cluster_id": instance.id
            }
        )
        Attributes.generate_fields(attributes)
        db().flush()
        return attributes
开发者ID:ansumanbebarta,项目名称:fuel-web,代码行数:27,代码来源:cluster.py


示例3: serialize_generated

    def serialize_generated(self, cluster, nodes):
        nodes = self.serialize_nodes(nodes)
        common_attrs = self.get_common_attrs(cluster)

        self.set_deployment_priorities(nodes)
        self.set_critical_nodes(nodes)
        return [utils.dict_merge(node, common_attrs) for node in nodes]
开发者ID:tek-life,项目名称:fuel-web,代码行数:7,代码来源:deployment_serializers.py


示例4: get_common_attrs

    def get_common_attrs(self, cluster):
        """Cluster attributes."""
        attrs = objects.Attributes.merged_attrs_values(cluster.attributes)
        release = self.current_release(cluster)

        attrs['deployment_mode'] = cluster.mode
        attrs['deployment_id'] = cluster.id
        attrs['openstack_version_prev'] = getattr(
            self.previous_release(cluster), 'version', None)
        attrs['openstack_version'] = release.version
        attrs['fuel_version'] = cluster.fuel_version
        attrs['nodes'] = self.node_list(
            objects.Cluster.get_nodes_not_for_deletion(cluster))

        # Adding params to workloads_collector
        if 'workloads_collector' not in attrs:
            attrs['workloads_collector'] = {}
        attrs['workloads_collector']['create_user'] = \
            objects.MasterNodeSettings.must_send_stats()
        username = attrs['workloads_collector'].pop('user', None)
        attrs['workloads_collector']['username'] = username

        for node in attrs['nodes']:
            if node['role'] in 'cinder':
                attrs['use_cinder'] = True

        self.set_storage_parameters(cluster, attrs)

        net_serializer = self.get_net_provider_serializer(cluster)
        net_common_attrs = net_serializer.get_common_attrs(cluster, attrs)
        attrs = utils.dict_merge(attrs, net_common_attrs)

        self.inject_list_of_plugins(attrs, cluster)

        return attrs
开发者ID:dnikishov,项目名称:fuel-web,代码行数:35,代码来源:deployment_serializers.py


示例5: patch_attributes

 def patch_attributes(cls, instance, data):
     PluginManager.process_cluster_attributes(instance, data['editable'])
     instance.attributes.editable = dict_merge(
         instance.attributes.editable, data['editable'])
     cls.add_pending_changes(instance, "attributes")
     cls.get_network_manager(instance).update_restricted_networks(instance)
     db().flush()
开发者ID:gdyuldin,项目名称:fuel-web,代码行数:7,代码来源:cluster.py


示例6: get_common_attrs

    def get_common_attrs(self, cluster):
        """Cluster attributes."""
        attrs = objects.Attributes.merged_attrs_values(cluster.attributes)
        release = self.current_release(cluster)

        attrs['deployment_mode'] = cluster.mode
        attrs['deployment_id'] = cluster.id
        attrs['openstack_version_prev'] = getattr(
            self.previous_release(cluster), 'version', None)
        attrs['openstack_version'] = release.version
        attrs['fuel_version'] = cluster.fuel_version
        attrs.update(
            objects.Release.get_orchestrator_data_dict(release)
        )
        attrs['nodes'] = self.node_list(get_nodes_not_for_deletion(cluster))

        for node in attrs['nodes']:
            if node['role'] in 'cinder':
                attrs['use_cinder'] = True

        self.set_storage_parameters(cluster, attrs)
        self.set_primary_mongo(attrs['nodes'])

        attrs = dict_merge(
            attrs,
            self.get_net_provider_serializer(cluster).get_common_attrs(cluster,
                                                                       attrs))

        return attrs
开发者ID:romcheg,项目名称:fuel-web,代码行数:29,代码来源:deployment_serializers.py


示例7: get_common_attrs

    def get_common_attrs(self, cluster):
        """Cluster attributes."""

        # tests call this method directly.
        # and we need this workaround to avoid refactoring a lot of tests.
        self._ensure_initialized_for(cluster)
        attrs = objects.Cluster.get_attributes(cluster)
        attrs = objects.Attributes.merged_attrs_values(attrs)

        attrs['deployment_mode'] = cluster.mode
        attrs['deployment_id'] = cluster.id
        attrs['openstack_version'] = cluster.release.version
        attrs['fuel_version'] = cluster.fuel_version
        attrs['nodes'] = self.node_list(self.all_nodes)

        # Adding params to workloads_collector
        if 'workloads_collector' not in attrs:
            attrs['workloads_collector'] = {}
        attrs['workloads_collector']['create_user'] = \
            objects.MasterNodeSettings.must_send_stats()
        username = attrs['workloads_collector'].pop('user', None)
        attrs['workloads_collector']['username'] = username

        if self.role_resolver.resolve(['cinder']):
            attrs['use_cinder'] = True

        net_serializer = self.get_net_provider_serializer(cluster)
        net_common_attrs = net_serializer.get_common_attrs(cluster, attrs)
        attrs = utils.dict_merge(attrs, net_common_attrs)

        self.inject_list_of_plugins(attrs, cluster)

        return attrs
开发者ID:huyupeng,项目名称:fuel-web,代码行数:33,代码来源:deployment_serializers.py


示例8: get_common_attrs

    def get_common_attrs(self, cluster):
        """Cluster attributes."""
        attrs = objects.Attributes.merged_attrs_values(cluster.attributes)
        release = self.current_release(cluster)

        attrs["deployment_mode"] = cluster.mode
        attrs["deployment_id"] = cluster.id
        attrs["openstack_version_prev"] = getattr(self.previous_release(cluster), "version", None)
        attrs["openstack_version"] = release.version
        attrs["fuel_version"] = cluster.fuel_version
        attrs["nodes"] = self.node_list(objects.Cluster.get_nodes_not_for_deletion(cluster))

        # Adding params to workloads_collector
        if "workloads_collector" not in attrs:
            attrs["workloads_collector"] = {}
        attrs["workloads_collector"]["create_user"] = objects.MasterNodeSettings.must_send_stats()
        username = attrs["workloads_collector"].pop("user", None)
        attrs["workloads_collector"]["username"] = username

        for node in attrs["nodes"]:
            if node["role"] in "cinder":
                attrs["use_cinder"] = True

        self.set_storage_parameters(cluster, attrs)

        net_serializer = self.get_net_provider_serializer(cluster)
        net_common_attrs = net_serializer.get_common_attrs(cluster, attrs)
        attrs = utils.dict_merge(attrs, net_common_attrs)

        return attrs
开发者ID:blkart,项目名称:fuel-web,代码行数:30,代码来源:deployment_serializers.py


示例9: get_default_attributes

    def get_default_attributes(cls, instance):
        """Get default attributes for interface.

        :param instance: NodeNICInterface instance
        :type instance: NodeNICInterface model
        :returns: dict -- Dict object of NIC attributes
        """
        attributes = cls._get_default_attributes(instance)
        attributes = utils.dict_merge(
            attributes,
            PluginManager.get_nic_attributes(instance))
        attributes = utils.dict_merge(
            attributes,
            PluginManager.get_nic_default_attributes(
                instance.node.cluster))

        return attributes
开发者ID:openstack,项目名称:fuel-web,代码行数:17,代码来源:interface.py


示例10: get_updated_editable_attributes

    def get_updated_editable_attributes(cls, instance, data):
        """Same as get_editable_attributes but also merges given data.

        :param instance: Cluster object
        :param data: dict
        :return: dict
        """
        return {"editable": dict_merge(cls.get_editable_attributes(instance)["editable"], data.get("editable", {}))}
开发者ID:anbangr,项目名称:fuel-web,代码行数:8,代码来源:cluster.py


示例11: _get_network_role_metadata

    def _get_network_role_metadata(self, **kwargs):
        network_role = {
            "id": "test_network_role",
            "default_mapping": consts.NETWORKS.public,
            "properties": {"subnet": True, "gateway": False, "vip": [{"name": "test_vip_a"}]},
        }

        return dict_merge(network_role, kwargs)
开发者ID:gitfred,项目名称:fuel-web,代码行数:8,代码来源:test_objects.py


示例12: merged_attrs

    def merged_attrs(cls, instance):
        """Generates merged dict which includes generated Cluster
        attributes recursively updated by new values from editable
        attributes.

        :param instance: Attributes instance
        :returns: dict of merged attributes
        """
        return dict_merge(instance.generated, instance.editable)
开发者ID:anbangr,项目名称:fuel-web,代码行数:9,代码来源:cluster.py


示例13: POST

    def POST(self, cluster_id):
        """Create a clone of the cluster.

        Creates a new cluster with specified name and release_id. The
        new cluster are created with parameters that are copied from the
        cluster with cluster_id. The values of the generated and
        editable attributes are just copied from one to the other.

        :param cluster_id: ID of the cluster to copy parameters from it
        :returns: JSON representation of the created cluster

        :http: * 200 (OK)
               * 404 (cluster or release did not found in db)
        """
        data = self.checked_data()
        orig_cluster = self.get_object_or_404(self.single, cluster_id)
        release = self.get_object_or_404(objects.Release, data["release_id"])
        # TODO(ikharin): Here should be more elegant code that verifies
        #                release versions of the original cluster and
        #                the future cluster. The upgrade process itself
        #                is meaningful only to upgrade the cluster
        #                between the major releases.
        # TODO(ikharin): This method should properly handle the upgrade
        #                from one major release to another but now it's
        #                hardcoded to perform the upgrade from 5.1.1 to
        #                6.1 release.
        data = {
            "name": data["name"],
            "mode": orig_cluster.mode,
            "status": consts.CLUSTER_STATUSES.new,
            "net_provider": orig_cluster.net_provider,
            "grouping": consts.CLUSTER_GROUPING.roles,
            "release_id": release.id,
        }
        if orig_cluster.net_provider == consts.CLUSTER_NET_PROVIDERS.neutron:
            data["net_segment_type"] = \
                orig_cluster.network_config.segmentation_type
            data["net_l23_provider"] = \
                orig_cluster.network_config.net_l23_provider
        new_cluster = self.single.create(data)
        new_cluster.attributes.generated = utils.dict_merge(
            new_cluster.attributes.generated,
            orig_cluster.attributes.generated)
        new_cluster.attributes.editable = self.merge_attributes(
            orig_cluster.attributes.editable,
            new_cluster.attributes.editable)
        nets_serializer = self.network_serializers[orig_cluster.net_provider]
        nets = self.merge_nets(
            nets_serializer.serialize_for_cluster(orig_cluster),
            nets_serializer.serialize_for_cluster(new_cluster))
        net_manager = self.single.get_network_manager(instance=new_cluster)
        net_manager.update(new_cluster, nets)
        self.copy_vips(orig_cluster, new_cluster)
        net_manager.assign_vips_for_net_groups(new_cluster)
        logger.debug("The cluster %s was created as a clone of the cluster %s",
                     new_cluster.id, orig_cluster.id)
        return self.single.to_json(new_cluster)
开发者ID:zhadaevfm,项目名称:octane,代码行数:57,代码来源:handlers.py


示例14: serialize

    def serialize(cls, cluster, nodes):
        """Method generates facts which
        through an orchestrator passes to puppet
        """
        nodes = cls.serialize_nodes(nodes)
        common_attrs = cls.get_common_attrs(cluster)

        cls.set_deployment_priorities(nodes)

        return [dict_merge(node, common_attrs) for node in nodes]
开发者ID:sk4lf,项目名称:fuel-web,代码行数:10,代码来源:deployment_serializers.py


示例15: test_bond_slaves_not_available_dpdk

    def test_bond_slaves_not_available_dpdk(self):
        self._create_bond_data()
        nic_3 = self.node.nic_interfaces[2]

        dpdk_settings = {'dpdk': {'available': False}, 'pci_id': ''}
        objects.NIC.update(nic_3, {'interface_properties': utils.dict_merge(
            nic_3.interface_properties, dpdk_settings)})

        self.assertRaisesRegexp(
            errors.InvalidData,
            "DPDK is not available .*",
            self.validator, self.data)
开发者ID:ogelbukh,项目名称:fuel-web,代码行数:12,代码来源:test_verify_node_interface_update.py


示例16: validate

    def validate(cls, data, node, cluster):
        data = cls.validate_json(data)
        full_data = utils.dict_merge(objects.Node.get_attributes(node), data)

        models = objects.Cluster.get_restrictions_models(cluster)

        attrs = cls.validate_attributes(full_data, models=models)

        cls._validate_cpu_pinning(node, attrs)
        cls._validate_hugepages(node, attrs)

        return data
开发者ID:huyupeng,项目名称:fuel-web,代码行数:12,代码来源:node.py


示例17: get_attributes

    def get_attributes(cls, instance):
        """Get all attributes for interface.

        :param instance: NodeNICInterface instance
        :type instance: NodeNICInterface model
        :returns: dict -- Object of interface attributes
        """
        attributes = copy.deepcopy(instance.attributes)
        attributes = utils.dict_merge(
            attributes,
            PluginManager.get_nic_attributes(instance))

        return attributes
开发者ID:openstack,项目名称:fuel-web,代码行数:13,代码来源:interface.py


示例18: get_default_attributes

    def get_default_attributes(cls, cluster):
        """Get native and plugin default attributes for bond.

        :param cluster: A cluster instance
        :type cluster: Cluster model
        :returns: dict -- Object of bond default attributes
        """
        default_attributes = cluster.release.bond_attributes
        default_attributes = utils.dict_merge(
            default_attributes,
            PluginManager.get_bond_default_attributes(cluster))

        return default_attributes
开发者ID:openstack,项目名称:fuel-web,代码行数:13,代码来源:bond.py


示例19: get_attributes

    def get_attributes(cls, instance):
        """Get native and plugin attributes for bond.

        :param instance: NodeBondInterface instance
        :type instance: NodeBondInterface model
        :returns: dict -- Object of bond attributes
        """
        attributes = copy.deepcopy(instance.attributes)
        attributes = utils.dict_merge(
            attributes,
            PluginManager.get_bond_attributes(instance))

        return attributes
开发者ID:openstack,项目名称:fuel-web,代码行数:13,代码来源:bond.py


示例20: serialize_generated

    def serialize_generated(self, common_attrs, nodes):
        serialized_nodes = self.serialize_nodes(common_attrs, nodes)
        nodes_map = {n.uid: n for n in nodes}

        self.set_deployment_priorities(serialized_nodes)
        for node_data in serialized_nodes:
            # the serialized nodes may contain fake nodes like master node
            # which does not have related db object. it shall be excluded.
            if node_data['uid'] in nodes_map:
                extensions.fire_callback_on_node_serialization_for_deployment(
                    nodes_map[node_data['uid']], node_data
                )
            yield utils.dict_merge(common_attrs, node_data)
开发者ID:mmalchuk,项目名称:openstack-fuel-web,代码行数:13,代码来源:deployment_serializers.py



注:本文中的nailgun.utils.dict_merge函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils.reverse函数代码示例发布时间:2022-05-27
下一篇:
Python base.reverse函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap