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


Python PersistentFactory.get_client方法代码示例

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


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

示例1: get_pks

# 需要导入模块: from ovs.extensions.storage.persistentfactory import PersistentFactory [as 别名]
# 或者: from ovs.extensions.storage.persistentfactory.PersistentFactory import get_client [as 别名]
 def get_pks(namespace, name):
     """
     This method will load the primary keys for a given namespace and name
     """
     persistent = PersistentFactory.get_client()
     prefix = '{0}_{1}_'.format(namespace, name)
     return set([key.replace(prefix, '') for key in persistent.prefix(prefix, max_elements=-1)])
开发者ID:tcpcloud,项目名称:openvstorage,代码行数:9,代码来源:datalist.py

示例2: _set

# 需要导入模块: from ovs.extensions.storage.persistentfactory import PersistentFactory [as 别名]
# 或者: from ovs.extensions.storage.persistentfactory.PersistentFactory import get_client [as 别名]
    def _set(key, value, raw):
        key = EtcdConfiguration._coalesce_dashes(key=key)
        data = value
        if raw is False:
            data = json.dumps(value)

        # Unittests
        if hasattr(unittest, 'running_tests') and getattr(unittest, 'running_tests') is True:
            stripped_key = key.strip('/')
            ut_data = EtcdConfiguration._unittest_data
            for part in stripped_key.split('/')[:-1]:
                if part not in ut_data:
                    ut_data[part] = {}
                ut_data = ut_data[part]

            ut_data[stripped_key.split('/')[-1]] = data
            return

        # Real implementation
        client = EtcdConfiguration._get_client()
        client.write(key, data)
        try:
            def _escape(*args, **kwargs):
                _ = args, kwargs
                raise RuntimeError()
            from ovs.extensions.storage.persistentfactory import PersistentFactory
            client = PersistentFactory.get_client()
            signal.signal(signal.SIGALRM, _escape)
            signal.alarm(0.5)  # Wait only 0.5 seconds. This is a backup and should not slow down the system
            client.set(key, value)
            signal.alarm(0)
        except:
            pass
开发者ID:DarumasLegs,项目名称:framework,代码行数:35,代码来源:configuration.py

示例3: get_relation_set

# 需要导入模块: from ovs.extensions.storage.persistentfactory import PersistentFactory [as 别名]
# 或者: from ovs.extensions.storage.persistentfactory.PersistentFactory import get_client [as 别名]
    def get_relation_set(remote_class, remote_key, own_class, own_key, own_guid):
        """
        This method will get a DataList for a relation.
        On a cache miss, the relation DataList will be rebuild and due to the nature of the full table scan, it will
        update all relations in the mean time.
        For below parameter information, use following example: We called "my_vmachine.vdisks".
        :param remote_class: The class of the remote part of the relation (e.g. VDisk)
        :param remote_key: The key in the remote_class that points to us (e.g. vmachine)
        :param own_class: The class of the base object of the relation (e.g. VMachine)
        :param own_key: The key in this class pointing to the remote classes (e.g. vdisks)
        :param own_guid: The guid of this object instance (e.g. the guid of my_vmachine)
        """

        # Example:
        # * remote_class = VDisk
        # * remote_key = vmachine
        # * own_class = VMachine
        # * own_key = vdisks
        # Called to load the vMachine.vdisks list (resulting in a possible scan of vDisk objects)
        # * own_guid = this vMachine object's guid

        persistent = PersistentFactory.get_client()
        own_name = own_class.__name__.lower()
        datalist = DataList(remote_class, {}, '{0}_{1}_{2}'.format(own_name, own_guid, remote_key))

        reverse_key = 'ovs_reverseindex_{0}_{1}|{2}|'.format(own_name, own_guid, own_key)
        datalist._guids = [guid.replace(reverse_key, '') for guid in persistent.prefix(reverse_key)]
        return datalist
开发者ID:grimpy,项目名称:openvstorage,代码行数:30,代码来源:datalist.py

示例4: __init__

# 需要导入模块: from ovs.extensions.storage.persistentfactory import PersistentFactory [as 别名]
# 或者: from ovs.extensions.storage.persistentfactory.PersistentFactory import get_client [as 别名]
    def __init__(self, object_type, query, key=None):
        """
        Initializes a DataList class with a given key (used for optional caching) and a given query
        :param object_type: The type of the objects that have to be queried
        :param query: The query to execute
        :param key: A key under which the result must be cached
        """
        super(DataList, self).__init__()

        if key is not None:
            self._key = '{0}_{1}'.format(DataList.NAMESPACE, key)
        else:
            identifier = copy.deepcopy(query)
            identifier['object'] = object_type.__name__
            self._key = '{0}_{1}'.format(DataList.NAMESPACE, hashlib.sha256(json.dumps(identifier)).hexdigest())

        self._volatile = VolatileFactory.get_client()
        self._persistent = PersistentFactory.get_client()
        self._query = query
        self._can_cache = True
        self._object_type = object_type
        self._data = {}
        self._objects = {}
        self._guids = None
        self._executed = False
        self._shallow_sort = True

        self.from_cache = None
开发者ID:grimpy,项目名称:openvstorage,代码行数:30,代码来源:datalist.py

示例5: _get

# 需要导入模块: from ovs.extensions.storage.persistentfactory import PersistentFactory [as 别名]
# 或者: from ovs.extensions.storage.persistentfactory.PersistentFactory import get_client [as 别名]
 def _get(key):
     if key == 'ovs.core.storage.persistent':
         return 'arakoon'
     c = PersistentFactory.get_client()
     if c.exists(key):
         return c.get(key)
     return None
开发者ID:tcpcloud,项目名称:openvstorage,代码行数:9,代码来源:test_arakoonInstaller.py

示例6: get_pks

# 需要导入模块: from ovs.extensions.storage.persistentfactory import PersistentFactory [as 别名]
# 或者: from ovs.extensions.storage.persistentfactory.PersistentFactory import get_client [as 别名]
 def get_pks(namespace, name):
     """
     This method will load the primary keys for a given namespace and name
     """
     persistent = PersistentFactory.get_client()
     prefix = '{0}_{1}_'.format(namespace, name)
     for key in persistent.prefix(prefix):
         yield key.replace(prefix, '')
开发者ID:JasperLue,项目名称:openvstorage,代码行数:10,代码来源:datalist.py

示例7: tearDownClass

# 需要导入模块: from ovs.extensions.storage.persistentfactory import PersistentFactory [as 别名]
# 或者: from ovs.extensions.storage.persistentfactory.PersistentFactory import get_client [as 别名]
 def tearDownClass(cls):
     """
     Clean up the unittest
     """
     fakesleep.monkey_restore()
     cls.volatile = VolatileFactory.get_client()
     cls.volatile.clean()
     cls.persistent = PersistentFactory.get_client()
     cls.persistent.clean()
开发者ID:openvstorage,项目名称:framework-alba-plugin,代码行数:11,代码来源:test_alba.py

示例8: setUpClass

# 需要导入模块: from ovs.extensions.storage.persistentfactory import PersistentFactory [as 别名]
# 或者: from ovs.extensions.storage.persistentfactory.PersistentFactory import get_client [as 别名]
 def setUpClass(cls):
     """
     Sets up the unittest, mocking a certain set of 3rd party libraries and extensions.
     This makes sure the unittests can be executed without those libraries installed
     """
     cls.persistent = PersistentFactory.get_client()
     cls.persistent.clean()
     cls.volatile = VolatileFactory.get_client()
     cls.volatile.clean()
开发者ID:DarumasLegs,项目名称:framework,代码行数:11,代码来源:test_hybrids.py

示例9: __init__

# 需要导入模块: from ovs.extensions.storage.persistentfactory import PersistentFactory [as 别名]
# 或者: from ovs.extensions.storage.persistentfactory.PersistentFactory import get_client [as 别名]
 def __init__(self):
     self._works = False
     self._getepoch = lambda: int(time.time())
     self._begintime = self._getepoch()
     self._waitlimit = 1800
     self._client = PersistentFactory.get_client('arakoon')
     self._key = 'ensureworks'
     self._valueguid = str(uuid.uuid4())
     self._value = '{0}{1}'
开发者ID:BillTheBest,项目名称:openvstorage,代码行数:11,代码来源:EnsureArakoonWorks.py

示例10: __init__

# 需要导入模块: from ovs.extensions.storage.persistentfactory import PersistentFactory [as 别名]
# 或者: from ovs.extensions.storage.persistentfactory.PersistentFactory import get_client [as 别名]
 def __init__(self, *args, **kwargs):
     """
     Initializes the distributed scheduler
     """
     self._persistent = PersistentFactory.get_client()
     self._namespace = 'ovs_celery_beat'
     self._mutex = VolatileMutex('celery_beat')
     self._has_lock = False
     super(DistributedScheduler, self).__init__(*args, **kwargs)
     logger.debug('DS init')
开发者ID:JasperLue,项目名称:openvstorage,代码行数:12,代码来源:celery_beat.py

示例11: tearDownClass

# 需要导入模块: from ovs.extensions.storage.persistentfactory import PersistentFactory [as 别名]
# 或者: from ovs.extensions.storage.persistentfactory.PersistentFactory import get_client [as 别名]
    def tearDownClass(cls):
        """
        Tear down changes made during setUpClass
        """
        Configuration._unittest_data = {}

        cls.persistent = PersistentFactory.get_client()
        cls.persistent.clean()

        cls.volatile = VolatileFactory.get_client()
        cls.volatile.clean()
开发者ID:grimpy,项目名称:openvstorage,代码行数:13,代码来源:test_arakooninstaller.py

示例12: __init__

# 需要导入模块: from ovs.extensions.storage.persistentfactory import PersistentFactory [as 别名]
# 或者: from ovs.extensions.storage.persistentfactory.PersistentFactory import get_client [as 别名]
 def __init__(self, *args, **kwargs):
     """
     Initializes the distributed scheduler
     """
     self._logger = LogHandler.get('celery', name='celery beat')
     self._persistent = PersistentFactory.get_client()
     self._namespace = 'ovs_celery_beat'
     self._mutex = volatile_mutex('celery_beat', 10)
     self._schedule_info = {}
     self._has_lock = False
     super(DistributedScheduler, self).__init__(*args, **kwargs)
     self._logger.debug('DS init')
开发者ID:grimpy,项目名称:openvstorage,代码行数:14,代码来源:celery_beat.py

示例13: _set

# 需要导入模块: from ovs.extensions.storage.persistentfactory import PersistentFactory [as 别名]
# 或者: from ovs.extensions.storage.persistentfactory.PersistentFactory import get_client [as 别名]
 def _set(key, value, raw):
     client = EtcdConfiguration._get_client()
     data = value
     if raw is False:
         data = json.dumps(value)
     client.write(key, data)
     try:
         from ovs.extensions.storage.persistentfactory import PersistentFactory
         client = PersistentFactory.get_client()
         client.set(key, value)
     except:
         pass
开发者ID:jeroenmaelbrancke,项目名称:openvstorage,代码行数:14,代码来源:configuration.py

示例14: setUpClass

# 需要导入模块: from ovs.extensions.storage.persistentfactory import PersistentFactory [as 别名]
# 或者: from ovs.extensions.storage.persistentfactory.PersistentFactory import get_client [as 别名]
    def setUpClass(cls):
        """
        Sets up the unittest, mocking a certain set of 3rd party libraries and extensions.
        This makes sure the unittests can be executed without those libraries installed
        """
        cls.persistent = PersistentFactory.get_client()
        cls.persistent.clean()
        cls.volatile = VolatileFactory.get_client()
        cls.volatile.clean()
        StorageRouterClient.clean()

        fakesleep.monkey_patch()
        Configuration.set('/ovs/framework/arakoon_clusters|voldrv', 'voldrv')
        Configuration.set('/ovs/framework/hosts/1/ports', {'arakoon': [10000, 10100]})
        Configuration.set('/ovs/framework/rdma', False)
开发者ID:openvstorage,项目名称:framework,代码行数:17,代码来源:test_node_configs.py

示例15: setUpClass

# 需要导入模块: from ovs.extensions.storage.persistentfactory import PersistentFactory [as 别名]
# 或者: from ovs.extensions.storage.persistentfactory.PersistentFactory import get_client [as 别名]
    def setUpClass(cls):
        """
        Sets up the unittest, mocking a certain set of 3rd party libraries and extensions.
        This makes sure the unittests can be executed without those libraries installed
        """
        cls.persistent = PersistentFactory.get_client()
        cls.persistent.clean()
        cls.volatile = VolatileFactory.get_client()
        cls.volatile.clean()
        StorageRouterClient.clean()

        fakesleep.monkey_patch()
        Configuration.set('/ovs/framework/storagedriver|mds_tlogs', 100)
        Configuration.set('/ovs/framework/storagedriver|mds_maxload', 75)
        Configuration.set('/ovs/framework/storagedriver|mds_safety', 2)
开发者ID:grimpy,项目名称:openvstorage,代码行数:17,代码来源:test_get_set_config_params.py


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