当前位置: 首页>>代码示例>>Python>>正文


Python VncCassandraClient.get_range方法代码示例

本文整理汇总了Python中cfgm_common.vnc_cassandra.VncCassandraClient.get_range方法的典型用法代码示例。如果您正苦于以下问题:Python VncCassandraClient.get_range方法的具体用法?Python VncCassandraClient.get_range怎么用?Python VncCassandraClient.get_range使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cfgm_common.vnc_cassandra.VncCassandraClient的用法示例。


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

示例1: _issu_basic_function

# 需要导入模块: from cfgm_common.vnc_cassandra import VncCassandraClient [as 别名]
# 或者: from cfgm_common.vnc_cassandra.VncCassandraClient import get_range [as 别名]
class ICCassandraClient:
    def _issu_basic_function(self, kspace, cfam, cols):
        return dict(cols)

    # end

    def __init__(self, oldversion_server_list, newversion_server_list, odb_prefix, ndb_prefix, issu_info, logger):
        self._oldversion_server_list = oldversion_server_list
        self._newversion_server_list = newversion_server_list
        self._odb_prefix = odb_prefix
        self._ndb_prefix = ndb_prefix
        self._issu_info = issu_info
        self._logger = logger
        self._ks_issu_func_info = {}
        self._nkeyspaces = {}
        self._okeyspaces = {}
        self._logger("Issu contrail cassandra initialized...", level=SandeshLevel.SYS_INFO)
        self.issu_prepare()

    # end

    def issu_prepare(self):
        self._logger("Issu contrail cassandra prepare...", level=SandeshLevel.SYS_INFO)
        for issu_func, ks, cflist in self._issu_info:

            if issu_func is None:
                issu_func = self._issu_basic_function
            ks_issu_func_info = {ks: issu_func}

            nks = {ks: cflist}
            oks = {ks: cflist}
            self._nkeyspaces.update(nks)
            self._okeyspaces.update(oks)
            self._ks_issu_func_info.update(ks_issu_func_info)

        self._oldversion_handle = VncCassandraClient(
            self._oldversion_server_list, self._odb_prefix, None, self._okeyspaces, self._logger
        )

        self._newversion_handle = VncCassandraClient(
            self._newversion_server_list, self._ndb_prefix, self._nkeyspaces, None, self._logger
        )

    # end

    def _fetch_issu_func(self, ks):
        return self._ks_issu_func_info[ks]

    # end

    # Overwrite what is seen in the newer with the old version.
    def _merge_overwrite(self, new, current):
        updated = current
        updated.update(new)
        return updated

    # end

    #  For now this function should be called for only config_db_uuid.
    #  If we separate out config_db_uuid keyspace from VncCassandraClient,
    #  then we don't need to pass keyspaces here.
    def issu_merge_copy(self, keyspaces):
        for ks, cflist in keyspaces.items():
            self._logger("Issu contrail cassandra merge copy, keyspace: " + str(ks), level=SandeshLevel.SYS_INFO)
            issu_funct = self._fetch_issu_func(ks)
            for cf in cflist:
                newList = []
                newversion_result = self._newversion_handle.get_range(cf)
                self._logger("Building New DB memory for columnfamily: " + str(cf), level=SandeshLevel.SYS_INFO)
                new_db = dict(newversion_result)

                oldversion_result = self._oldversion_handle.get_range(cf)
                self._logger("Doing ISSU copy for columnfamily: " + str(cf), level=SandeshLevel.SYS_INFO)
                for rows, columns in oldversion_result:
                    out = issu_funct(ks, cf, columns)
                    current = new_db.pop(rows, None)
                    if current is not None:
                        updated = self._merge_overwrite(out, dict(current))
                        x = self._newversion_handle.add(cf, rows, updated)
                    else:
                        updated = []
                        x = self._newversion_handle.add(cf, rows, out)
                    diff = set(updated) - set(out)
                    y = self._newversion_handle.get_cf(cf).remove(rows, diff)
                self._logger(
                    "Pruning New DB if entires don't exist in old DB column " "family: " + str(cf),
                    level=SandeshLevel.SYS_INFO,
                )
                for item in new_db:
                    # TBD should be catch exception and fail ISSU
                    self._newversion_handle.delete(cf, item)

    # end

    #  This is issu_copy function.
    def issu_copy(self, keyspaces):
        for ks, cflist in keyspaces.items():
            issu_funct = self._fetch_issu_func(ks)
            for cf in cflist:
                self._logger(
#.........这里部分代码省略.........
开发者ID:rasta-rocket,项目名称:contrail-controller,代码行数:103,代码来源:issu_contrail_common.py


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