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


Python MemcachedClient.sasl_auth_plain方法代码示例

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


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

示例1: wait_for_mc_stats_no_timeout

# 需要导入模块: from mc_bin_client import MemcachedClient [as 别名]
# 或者: from mc_bin_client.MemcachedClient import sasl_auth_plain [as 别名]
    def wait_for_mc_stats_no_timeout(master, bucket, stat_key, stat_value, timeout_in_seconds=-1, verbose=True):
        log.info(
            "waiting for bucket {0} stat : {1} to match {2} on {3}".format(bucket, stat_key, stat_value, master.ip)
        )
        # keep retrying until reaches the server
        stats = {}
        while not stats:
            try:
                c = MemcachedClient(master.ip, 11210)
                c.sasl_auth_plain(bucket, "")
                stats = c.stats()
            except Exception as e:
                log.info("Exception: {0}, retry in 2 seconds ...".format(str(e)))
                stats = {}
                time.sleep(2)
            finally:
                c.close()

        while str(stats[stat_key]) != str(stat_value):
            c = MemcachedClient(master.ip, 11210)
            c.sasl_auth_plain(bucket, "")
            stats = c.stats()
            c.close()
            if verbose:
                log.info("{0} : {1}".format(stat_key, stats[stat_key]))
            time.sleep(5)
        return True
开发者ID:ketakigangal,项目名称:cbsystest,代码行数:29,代码来源:rebalance_helper.py

示例2: verify_revid

# 需要导入模块: from mc_bin_client import MemcachedClient [as 别名]
# 或者: from mc_bin_client.MemcachedClient import sasl_auth_plain [as 别名]
 def verify_revid(self):
     missing_keys = False
     src_node = self.get_active_vb0_node(self.src_master)
     dest_node = self.get_active_vb0_node(self.dest_master)
     src_client = MemcachedClient(src_node.ip, 11210)
     dest_client = MemcachedClient(dest_node.ip, 11210)
     src_client.sasl_auth_plain("cbadminbucket","password")
     src_client.bucket_select("default")
     dest_client.sasl_auth_plain("cbadminbucket","password")
     dest_client.bucket_select("default")
     for key in self.keys_loaded:
         try:
             src_meta = src_client.getMeta(key)
             dest_meta = dest_client.getMeta(key)
             self.log.info("deleted, flags, exp, rev_id, cas for key from Source({0}) {1} = {2}"
                            .format(src_node.ip, key, src_meta))
             self.log.info("deleted, flags, exp, rev_id, cas for key from Destination({0}) {1} = {2}"
                            .format(dest_node.ip, key, dest_meta))
             if src_meta == dest_meta:
                 self.log.info("RevID verification successful for key {0}".format(key))
             else:
                 self.fail("RevID verification failed for key {0}".format(key))
         except MemcachedError as e:
             self.log.error("Key {0} threw {1} on getMeta()".format(key, e))
             missing_keys = True
     if missing_keys:
         self.fail("Some keys are missing at destination")
开发者ID:arod1987,项目名称:testrunner,代码行数:29,代码来源:checkpointXDCR.py

示例3: direct_client

# 需要导入模块: from mc_bin_client import MemcachedClient [as 别名]
# 或者: from mc_bin_client.MemcachedClient import sasl_auth_plain [as 别名]
    def direct_client(server, bucket, timeout=30):
        log = logger.Logger.get_logger()
        rest = RestConnection(server)
        node = None
        try:
            node = rest.get_nodes_self()
        except ValueError as e:
            log.info("could not connect to server {0}, will try scanning all nodes".format(server))
        if not node:
            nodes = rest.get_nodes()
            for n in nodes:
                if n.ip == server.ip and n.port == server.port:
                    node = n

        if isinstance(server, dict):
            log.info("dict:{0}".format(server))
            log.info("creating direct client {0}:{1} {2}".format(server["ip"], node.memcached, bucket))
        else:
            log.info("creating direct client {0}:{1} {2}".format(server.ip, node.memcached, bucket))
        RestHelper(rest).vbucket_map_ready(bucket, 60)
        vBuckets = RestConnection(server).get_vbuckets(bucket)
        if isinstance(server, dict):
            client = MemcachedClient(server["ip"], node.memcached, timeout=timeout)
        else:
            client = MemcachedClient(server.ip, node.memcached, timeout=timeout)
        client.vbucket_count = len(vBuckets)
        bucket_info = rest.get_bucket(bucket)
        # todo raise exception for not bucket_info
        client.sasl_auth_plain(bucket_info.name.encode("ascii"), bucket_info.saslPassword.encode("ascii"))
        return client
开发者ID:steveyen,项目名称:testrunner,代码行数:32,代码来源:data_helper.py

示例4: wait_for_vbuckets_ready_state

# 需要导入模块: from mc_bin_client import MemcachedClient [as 别名]
# 或者: from mc_bin_client.MemcachedClient import sasl_auth_plain [as 别名]
    def wait_for_vbuckets_ready_state(node, bucket, timeout_in_seconds=300, log_msg=''):
        log = logger.Logger.get_logger()
        start_time = time.time()
        end_time = start_time + timeout_in_seconds
        ready_vbuckets = {}
        rest = RestConnection(node)
        servers = rest.get_nodes()
        RestHelper(rest).vbucket_map_ready(bucket, 60)
        vbucket_count = len(rest.get_vbuckets(bucket))
        vbuckets = rest.get_vbuckets(bucket)
        obj = VBucketAwareMemcached(rest, bucket)
        memcacheds, vbucket_map, vbucket_map_replica = obj.request_map(rest, bucket)
        #Create dictionary with key:"ip:port" and value: a list of vbuckets
        server_dict = defaultdict(list)
        for everyID in range(0, vbucket_count):
            memcached_ip_port = str(vbucket_map[everyID])
            server_dict[memcached_ip_port].append(everyID)
        while time.time() < end_time and len(ready_vbuckets) < vbucket_count:
            for every_ip_port in server_dict:
                #Retrieve memcached ip and port
                ip, port = every_ip_port.split(":")
                client = MemcachedClient(ip, int(port), timeout=30)
                client.vbucket_count = len(vbuckets)
                bucket_info = rest.get_bucket(bucket)
                client.sasl_auth_plain(bucket_info.name.encode('ascii'),
                                    bucket_info.saslPassword.encode('ascii'))
                for i in server_dict[every_ip_port]:
                    try:
                        (a, b, c) = client.get_vbucket_state(i)
                    except mc_bin_client.MemcachedError as e:
                        ex_msg = str(e)
                        if "Not my vbucket" in log_msg:
                            log_msg = log_msg[:log_msg.find("vBucketMap") + 12] + "..."
                        if e.status == memcacheConstants.ERR_NOT_MY_VBUCKET:
                            # May receive this while waiting for vbuckets, continue and retry...S
                            continue
                        log.error("%s: %s" % (log_msg, ex_msg))
                        continue
                    except exceptions.EOFError:
                        # The client was disconnected for some reason. This can
                        # happen just after the bucket REST API is returned (before
                        # the buckets are created in each of the memcached processes.)
                        # See here for some details: http://review.couchbase.org/#/c/49781/
                        # Longer term when we don't disconnect clients in this state we
                        # should probably remove this code.
                        log.error("got disconnected from the server, reconnecting")
                        client.reconnect()
                        client.sasl_auth_plain(bucket_info.name.encode('ascii'),
                                               bucket_info.saslPassword.encode('ascii'))
                        continue

                    if c.find("\x01") > 0 or c.find("\x02") > 0:
                        ready_vbuckets[i] = True
                    elif i in ready_vbuckets:
                        log.warning("vbucket state changed from active to {0}".format(c))
                        del ready_vbuckets[i]
                client.close()
        return len(ready_vbuckets) == vbucket_count
开发者ID:EricACooper,项目名称:testrunner,代码行数:60,代码来源:bucket_helper.py

示例5: connection

# 需要导入模块: from mc_bin_client import MemcachedClient [as 别名]
# 或者: from mc_bin_client.MemcachedClient import sasl_auth_plain [as 别名]
 def connection(self, client_ip, bucket_name, user,password, port=11210):
     log.info("Bucket name for connection is ---- {0}, username -- {1}, ----- password -- {2}".format(bucket_name,user, \
                                                                                                      password))
     try:
         mc = MemcachedClient(host=client_ip, port=port)
         mc.sasl_auth_plain(user,password)
         mc.bucket_select(bucket_name)
         return mc, True
     except Exception as e:
         log.info( "Exception is from connection function {0}".format(e))
         return False, False
开发者ID:arod1987,项目名称:testrunner,代码行数:13,代码来源:testmemcached.py

示例6: load_one_mutation_into_source_vb0

# 需要导入模块: from mc_bin_client import MemcachedClient [as 别名]
# 或者: from mc_bin_client.MemcachedClient import sasl_auth_plain [as 别名]
 def load_one_mutation_into_source_vb0(self, vb0_active_src_node):
     key = self.vb0_keys[self.key_counter]
     memc_client = MemcachedClient(vb0_active_src_node.ip, 11210)
     memc_client.sasl_auth_plain("cbadminbucket","password")
     memc_client.bucket_select("default")
     try:
         memc_client.set(key, exp=0, flags=0, val="dummy val")
         self.key_counter += 1
         self.keys_loaded.append(key)
         self.log.info("Loaded key {0} onto vb0 in {1}".format(key, vb0_active_src_node.ip))
         self.log.info ("deleted, flags, exp, rev_id, cas for key {0} = {1}".format(key, memc_client.getMeta(key)))
     except MemcachedError as e:
         self.log.error(e)
开发者ID:arod1987,项目名称:testrunner,代码行数:15,代码来源:checkpointXDCR.py

示例7: wait_for_vbuckets_ready_state

# 需要导入模块: from mc_bin_client import MemcachedClient [as 别名]
# 或者: from mc_bin_client.MemcachedClient import sasl_auth_plain [as 别名]
 def wait_for_vbuckets_ready_state(node, bucket, timeout_in_seconds=300, log_msg=''):
     log = logger.Logger.get_logger()
     start_time = time.time()
     end_time = start_time + timeout_in_seconds
     ready_vbuckets = {}
     rest = RestConnection(node)
     servers = rest.get_nodes()
     RestHelper(rest).vbucket_map_ready(bucket, 60)
     vbucket_count = len(rest.get_vbuckets(bucket))
     vbuckets = rest.get_vbuckets(bucket)
     obj = VBucketAwareMemcached(rest, bucket)
     memcacheds, vbucket_map, vbucket_map_replica = obj.request_map(rest, bucket)
     #Create dictionary with key:"ip:port" and value: a list of vbuckets
     server_dict = defaultdict(list)
     for everyID in range(0, vbucket_count):
         memcached_ip_port = str(vbucket_map[everyID])
         server_dict[memcached_ip_port].append(everyID)
     while time.time() < end_time and len(ready_vbuckets) < vbucket_count:
         for every_ip_port in server_dict:
             #Retrieve memcached ip and port
             ip, port = every_ip_port.split(":")
             client = MemcachedClient(ip, int(port), timeout=30)
             client.vbucket_count = len(vbuckets)
             bucket_info = rest.get_bucket(bucket)
             client.sasl_auth_plain(bucket_info.name.encode('ascii'),
                                 bucket_info.saslPassword.encode('ascii'))
             for i in server_dict[every_ip_port]:
                 try:
                     (a, b, c) = client.get_vbucket_state(i)
                 except mc_bin_client.MemcachedError as e:
                     ex_msg = str(e)
                     if "Not my vbucket" in log_msg:
                         log_msg = log_msg[:log_msg.find("vBucketMap") + 12] + "..."
                     if "Not my vbucket" in ex_msg:
                         #reduce output
                         ex_msg = str(e)[:str(e).find('Not my vbucket') + 14] + "..."
                     log.error("%s: %s" % (log_msg, ex_msg))
                     continue
                 if c.find("\x01") > 0 or c.find("\x02") > 0:
                     ready_vbuckets[i] = True
                 elif i in ready_vbuckets:
                     log.warning("vbucket state changed from active to {0}".format(c))
                     del ready_vbuckets[i]
             client.close()
     return len(ready_vbuckets) == vbucket_count
开发者ID:ashvindersingh,项目名称:testrunner,代码行数:47,代码来源:bucket_helper.py

示例8: direct_client

# 需要导入模块: from mc_bin_client import MemcachedClient [as 别名]
# 或者: from mc_bin_client.MemcachedClient import sasl_auth_plain [as 别名]
 def direct_client(server, bucket, timeout=30):
     rest = RestConnection(server)
     node = rest.get_nodes_self()
     log = logger.Logger.get_logger()
     if isinstance(server, dict):
         log.info("dict:{0}".format(server))
         log.info("creating direct client {0}:{1} {2}".format(server["ip"], node.memcached, bucket))
     else:
         log.info("creating direct client {0}:{1} {2}".format(server.ip, node.memcached, bucket))
     RestHelper(rest).vbucket_map_ready(bucket, 60)
     vBuckets = RestConnection(server).get_vbuckets(bucket)
     if isinstance(server, dict):
         client = MemcachedClient(server["ip"], node.memcached, timeout=timeout)
     else:
         client = MemcachedClient(server.ip, node.memcached, timeout=timeout)
     client.vbucket_count = len(vBuckets)
     bucket_info = rest.get_bucket(bucket)
     #todo raise exception for not bucket_info
     client.sasl_auth_plain(bucket_info.name.encode('ascii'),
                            bucket_info.saslPassword.encode('ascii'))
     return client
开发者ID:vmx,项目名称:testrunner,代码行数:23,代码来源:data_helper.py

示例9: getDirectMC

# 需要导入模块: from mc_bin_client import MemcachedClient [as 别名]
# 或者: from mc_bin_client.MemcachedClient import sasl_auth_plain [as 别名]
def getDirectMC(key, ip, port = 8091, bucket = "default", password = ""):

    real_mc_client = None

    # get initial mc client
    client = MemcachedClient(ip, int(port))
    vbId = (((zlib.crc32(key)) >> 16) & 0x7fff) & (client.vbucket_count - 1)

    # get vbucket map
    rest = create_rest(ip, port)
    vbuckets = rest.get_vbuckets(bucket)

    # find vbucket responsible to this key and mapping host
    if vbuckets is not None:

        vbucket = [vbucket for vbucket in vbuckets if vbucket.id == vbId]

        if len(vbucket) == 1:
            mc_ip, mc_port = vbucket[0].master.split(":")
            real_mc_client = MemcachedClient(mc_ip, int(mc_port))
            real_mc_client.sasl_auth_plain(bucket, password)

    return real_mc_client
开发者ID:Boggypop,项目名称:testrunner,代码行数:25,代码来源:sdk_client_tasks.py

示例10: do_auth

# 需要导入模块: from mc_bin_client import MemcachedClient [as 别名]
# 或者: from mc_bin_client.MemcachedClient import sasl_auth_plain [as 别名]
 def do_auth(self, bucket, password):
     """ default self.auth_mech is 'PLAIN' """
     self.log.info("Authenticate with {0} to {1}:{2}".format(self.auth_mech,
                                                             bucket,
                                                             password))
     ret = None
     nodes = RestConnection(self.master).get_nodes()
     for n in nodes:
         if n.ip == self.master.ip and n.port == self.master.port:
             node = n
     client = MemcachedClient(self.master.ip, node.memcached)
     try:
         if self.auth_mech == "PLAIN":
             ret = client.sasl_auth_plain(bucket, password)[2]
         else:
             self.fail("Invalid auth mechanism {0}".format(self.auth_mech))
     except MemcachedError, e:
         ret = e[0].split(' for vbucket')[0]
开发者ID:arod1987,项目名称:testrunner,代码行数:20,代码来源:sasl_tests.py

示例11: flushctl_stop

# 需要导入模块: from mc_bin_client import MemcachedClient [as 别名]
# 或者: from mc_bin_client.MemcachedClient import sasl_auth_plain [as 别名]
 def flushctl_stop(servers, username=None, password=None):
     for server in servers:
         c = MemcachedClient(server.ip, 11210)
         if username:
             c.sasl_auth_plain(username, password)
         c.stop_persistence()
开发者ID:ronniedada,项目名称:testrunner,代码行数:8,代码来源:cluster_helper.py

示例12: poll

# 需要导入模块: from mc_bin_client import MemcachedClient [as 别名]
# 或者: from mc_bin_client.MemcachedClient import sasl_auth_plain [as 别名]
def poll():
    url = "https://macbuild.hq.couchbase.com/xcode/api/integrations/filter/latest"
    latest = getJS(url)
    now = datetime.datetime.now()
    ts = now.strftime("%Y%m%d")
    build_no  = "%s-%s" % (MOBILE_VERSION, ts[-5:])
    client = McdClient(HOST, PORT)
    client.sasl_auth_plain("mobile", "")

    buildHist = {}
    for build in latest:
        if 'revisionBlueprint' not in latest[build]:
            continue
        key = latest[build]['revisionBlueprint']['DVTSourceControlWorkspaceBlueprintPrimaryRemoteRepositoryKey']
        rev = latest[build]['revisionBlueprint']['DVTSourceControlWorkspaceBlueprintLocationsKey'][key]['DVTSourceControlLocationRevisionKey']
        name = "iOS-"+latest[build]['bot']['name'].replace(" ","")
        build_id = latest[build]['number']
        results = latest[build]['buildResultSummary']
        totalCount = results['testsCount']
        failCount = results['errorCount']
        result = 'SUCCESS'

        if name in  TOTAL_COUNT_LOG:
            if totalCount == 0:
                # use historical value for total count
                totalCount = TOTAL_COUNT_LOG[name]
            elif totalCount != TOTAL_COUNT_LOG:
                # update total count log
                TOTAL_COUNT_LOG[name] = totalCount
        else:
            TOTAL_COUNT_LOG[name] = totalCount

        if (failCount > 0):
            result = 'UNSTABLE'
        component = None
        for feature in MOBILE_FEATURES:
            tag, _c = feature.split("-")
            docname = name.upper()
            docname = docname.replace("-","_")
            if tag in docname:
               component = _c 
        if component:
            doc = {'build_id': build_id,
                   'priority': 'P0',
                   'name': name,
                   'url': url,
                   'component': component,
                   'failCount':  failCount,
                   'totalCount': totalCount,
                   'result': result,
                   'os': 'iOS',
                   'build': build_no}

            key = "%s-%s" % (doc["name"], doc["build_id"])
            val = json.dumps(doc)
            try:
                #print val
                key = hashlib.md5(key).hexdigest()
                print val
                client.set(key, 0, 0, val, 0)
                buildHist[doc["build"]] = doc["build_id"]
            except Exception as ex:
                print ex
                print "set failed, couchbase down?: %s:%s"  % (HOST,PORT)
开发者ID:subalakr,项目名称:jinja-1,代码行数:66,代码来源:macbuild.py

示例13: storeJob

# 需要导入模块: from mc_bin_client import MemcachedClient [as 别名]
# 或者: from mc_bin_client.MemcachedClient import sasl_auth_plain [as 别名]
def storeJob(jobDoc, bucket, first_pass = True):

    client = McdClient(HOST, PORT)
    client.sasl_auth_plain(bucket, "")

    doc = jobDoc
    url = doc["url"]

    res = getJS(url, {"depth" : 0}).json()

    if res is None:
        return

    buildHist = {}
    if res["lastBuild"]:

        bids = [b["number"] for b in res["builds"]]

        lastTotalCount = -1
        idx=0

        for bid in bids:
            idx = idx + 1
            i = 1
            if idx < len(bids):
                while bids[idx] != bid-i:
                    key = "%s-%s" % (doc["name"], bid-i)
                    key = hashlib.md5(key).hexdigest()
                    try:
                        client.delete(key, vbucket=0)
                    except:
                        pass
                    i = i + 1
            if bid in JOBS[doc["name"]]:
                continue # job already stored
            else:
                if first_pass == False:
                    JOBS[doc["name"]].append(bid)

            doc["build_id"] = bid
            res = getJS(url+str(bid), {"depth" : 0}).json()
            if res is None:
                return

            if "result" not in res:
                continue

            doc["result"] = res["result"]
            doc["duration"] = res["duration"]

            if bucket == "server":
                if res["result"] not in ["SUCCESS", "UNSTABLE", "FAILURE", "ABORTED"]:
                    continue # unknown result state

                actions = res["actions"]
                totalCount = getAction(actions, "totalCount") or 0
                failCount  = getAction(actions, "failCount") or 0
                skipCount  = getAction(actions, "skipCount") or 0
                if totalCount == 0:
                    if lastTotalCount == -1:
                        continue # no tests ever passed for this build
                    else:
                        totalCount = lastTotalCount
                        failCount = totalCount
                else:
                    lastTotalCount = totalCount

                doc["failCount"] = failCount
                doc["totalCount"] = totalCount - skipCount

                params = getAction(actions, "parameters")
                if params is None:
                    doc["priority"] = P1
                    doc["build"] = DEFAULT_BUILD
                else:
                    doc["build"] = getAction(params, "name", "version_number") or getAction(params, "name", "cluster_version") or  DEFAULT_BUILD
                    doc["priority"] = getAction(params, "name", "priority") or P1
                    if doc["priority"].upper() not in [P0, P1, P2]:
                        doc["priority"] = P1
                doc["build"] = doc["build"].replace("-rel","").split(",")[0]
                try:
                    _build= doc["build"].split("-")
                    rel, bno = _build[0], _build[1]
                    # check partial rel #'s
                    rlen = len(rel.split("."))
                    while rlen < 3:
                        rel = rel+".0"
                        rlen+=1

                    # verify rel, build
                    m=re.match("^\d\.\d\.\d{1,5}", rel)
                    if m is None:
                        print "unsupported version_number: "+doc["build"]
                        continue
                    m=re.match("^\d{1,10}", bno)
                    if m is None:
                        print "unsupported version_number: "+doc["build"]
                        continue

                    doc["build"] = "%s-%s" % (rel, bno.zfill(4))
#.........这里部分代码省略.........
开发者ID:subalakr,项目名称:jinja,代码行数:103,代码来源:jinja.py


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