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


Python Cluster.authenticate方法代码示例

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


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

示例1: create_xattr_data

# 需要导入模块: from couchbase.cluster import Cluster [as 别名]
# 或者: from couchbase.cluster.Cluster import authenticate [as 别名]
    def create_xattr_data(self, type="system"):
        cluster = Cluster('couchbase://'+str(self.master.ip))
        authenticator = PasswordAuthenticator(self.username, self.password)
        cluster.authenticate(authenticator)
        cb = cluster.open_bucket('default')
        docs = self.get_meta_ids()
        self.log.info("Docs: " + str(docs[0:5]))
        xattr_data = []
        self.log.info("Adding xattrs to data")
        val = 0
        for doc in docs:
            if type == "system":
                rv = cb.mutate_in(doc["id"], SD.upsert('_system1', val, xattr=True, create_parents=True))
                xattr_data.append({'_system1': val})
                rv = cb.mutate_in(doc["id"], SD.upsert('_system2', {'field1': val, 'field2': val*val}, xattr=True, create_parents=True))
                xattr_data.append({'_system2': {'field1': val, 'field2': val*val}})
                rv = cb.mutate_in(doc["id"], SD.upsert('_system3', {'field1': {'sub_field1a': val, 'sub_field1b': val*val}, 'field2': {'sub_field2a': 2*val, 'sub_field2b': 2*val*val}}, xattr=True, create_parents=True))
                xattr_data.append({'_system3': {'field1': {'sub_field1a': val, 'sub_field1b': val*val}, 'field2': {'sub_field2a': 2*val, 'sub_field2b': 2*val*val}}})
            if type == "user":
                rv = cb.mutate_in(doc["id"], SD.upsert('user1', val, xattr=True, create_parents=True))
                xattr_data.append({'user1': val})
                rv = cb.mutate_in(doc["id"], SD.upsert('user2', {'field1': val, 'field2': val*val}, xattr=True, create_parents=True))
                xattr_data.append({'user2': {'field1': val, 'field2': val*val}})
                rv = cb.mutate_in(doc["id"], SD.upsert('user3', {'field1': {'sub_field1a': val, 'sub_field1b': val*val}, 'field2': {'sub_field2a': 2*val, 'sub_field2b': 2*val*val}}, xattr=True, create_parents=True))
                xattr_data.append({'user3': {'field1': {'sub_field1a': val, 'sub_field1b': val*val}, 'field2': {'sub_field2a': 2*val, 'sub_field2b': 2*val*val}}})
            val = val + 1

        self.log.info("Completed adding " + type + "xattrs to data to " + str(val) + " docs")
        return xattr_data
开发者ID:ritamcouchbase,项目名称:testrunner,代码行数:31,代码来源:n1ql_upgrade.py

示例2: _createConn

# 需要导入模块: from couchbase.cluster import Cluster [as 别名]
# 或者: from couchbase.cluster.Cluster import authenticate [as 别名]
 def _createConn(self):
     try:
         cluster = Cluster(self.connection_string, bucket_class=CouchbaseBucket)
         cluster.authenticate(PasswordAuthenticator(self.bucket, 'password'))
         self.cb = cluster.open_bucket(self.bucket)
     except BucketNotFoundError:
          raise
开发者ID:membase,项目名称:testrunner,代码行数:9,代码来源:sdk_client.py

示例3: _create_cluster

# 需要导入模块: from couchbase.cluster import Cluster [as 别名]
# 或者: from couchbase.cluster.Cluster import authenticate [as 别名]
    def _create_cluster(self):
        connargs = self.make_connargs()
        connstr = ConnectionString.parse(str(connargs.pop('connection_string')))
        connstr.clear_option('username')
        bucket = connstr.bucket
        connstr.bucket = None
        password = connargs.get('password', '')

        # Can I open a new bucket via open_bucket?
        cluster = Cluster(connstr, bucket_class=self.factory)
        cluster.authenticate(ClassicAuthenticator(buckets={bucket: password},cluster_password=self.cluster_info.admin_password, cluster_username=self.cluster_info.admin_username))
        return cluster, bucket
开发者ID:couchbase,项目名称:couchbase-python-client,代码行数:14,代码来源:cluster_t.py

示例4: _create_cluster_clean

# 需要导入模块: from couchbase.cluster import Cluster [as 别名]
# 或者: from couchbase.cluster.Cluster import authenticate [as 别名]
 def _create_cluster_clean(self, authenticator):
     connargs = self.make_connargs()
     connstr = ConnectionString.parse(str(connargs.pop('connection_string')))
     connstr.clear_option('username')
     bucket = connstr.bucket
     connstr.bucket = None
     password = connargs.get('password', None)
     keys_to_skip = authenticator.get_credentials(bucket)['options'].keys()
     for entry in keys_to_skip:
         connstr.clear_option(entry)
     cluster = Cluster(connstr, bucket_class=self.factory)
     cluster.authenticate(ClassicAuthenticator(buckets={bucket: password}))
     return cluster, bucket
开发者ID:couchbase,项目名称:couchbase-python-client,代码行数:15,代码来源:cluster_t.py

示例5: _createConn

# 需要导入模块: from couchbase.cluster import Cluster [as 别名]
# 或者: from couchbase.cluster.Cluster import authenticate [as 别名]
 def _createConn(self):
     try:
         cluster = Cluster(self.connection_string, bucket_class=CouchbaseBucket)
         cluster.authenticate(PasswordAuthenticator(self.bucket, 'password'))
         self.cb = cluster.open_bucket(self.bucket)
     except BucketNotFoundError:
          raise
     except AuthError:
         # Try using default user created by the tests, if any, in case there is no user with bucket name in the
         # cluster.
         try:
             cluster = Cluster(self.connection_string, bucket_class=CouchbaseBucket)
             cluster.authenticate(PasswordAuthenticator("cbadminbucket", 'password'))
             self.cb = cluster.open_bucket(self.bucket)
         except AuthError:
             raise
开发者ID:arod1987,项目名称:testrunner,代码行数:18,代码来源:sdk_client.py

示例6: create_connections

# 需要导入模块: from couchbase.cluster import Cluster [as 别名]
# 或者: from couchbase.cluster.Cluster import authenticate [as 别名]
 def create_connections(self):
     """
     Create bucket connections. 5 bucket connections are created per instance.
     :return: Nothing
     """
     for i in range(0, self.threads):
         if self.cb_version > '5':
             cluster = Cluster(self.spec)
             auth = PasswordAuthenticator(self.user, self.password)
             cluster.authenticate(auth)
             bucket = cluster.open_bucket(self.bucket_name, lockmode=LOCKMODE_WAIT)
             bucket.timeout = self.timeout
             self.connections.append(bucket)
         else:
             bucket = Bucket('{0}/{1}'.format(self.spec, self.bucket_name), lockmode=LOCKMODE_WAIT)
             bucket.timeout = self.timeout
             self.connections.append(bucket)
开发者ID:ritamcouchbase,项目名称:testrunner,代码行数:19,代码来源:thanosied.py

示例7: _connect

# 需要导入模块: from couchbase.cluster import Cluster [as 别名]
# 或者: from couchbase.cluster.Cluster import authenticate [as 别名]
 def _connect(self):
     """Establish a connection to the Couchbase cluster."""
     cluster = Cluster('http://{}:{}'.format(self.host, self.port))
     authenticator = PasswordAuthenticator('Administrator', self.password)
     cluster.authenticate(authenticator)
     self.client = cluster.open_bucket(self.bucket)
开发者ID:couchbase,项目名称:perfrunner,代码行数:8,代码来源:keyFragger.py

示例8: tst

# 需要导入模块: from couchbase.cluster import Cluster [as 别名]
# 或者: from couchbase.cluster.Cluster import authenticate [as 别名]
#!/usr/bin/env python

from couchbase.cluster import Cluster, PasswordAuthenticator
from couchbase.exceptions import NotFoundError

def tst(cb, key):
    try:
        cb.remove(key)
    except NotFoundError:
        print ('Nothing to delete')

    rv = cb.upsert(key, {'hello': 'world'})
    cas = rv.cas
    print(rv)

    item = cb.get(key)
    print(item)

cluster = Cluster('couchbase://localhost:12000')
cluster.authenticate(PasswordAuthenticator('Administrator', 'asdasd'))
cb = cluster.open_bucket('test')

tst(cb, 'blah')
开发者ID:vzasade,项目名称:cbmisc,代码行数:25,代码来源:tst.py


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