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


Python RestConnection.eject_node方法代码示例

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


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

示例1: cleanup_cluster

# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import eject_node [as 别名]
    def cleanup_cluster(servers, wait_for_rebalance=True, master = None):
        log = logger.Logger.get_logger()
        if master == None:
            master = servers[0]
        rest = RestConnection(master)
        helper = RestHelper(rest)
        helper.is_ns_server_running(timeout_in_seconds=testconstants.NS_SERVER_TIMEOUT)
        nodes = rest.node_statuses()
        master_id = rest.get_nodes_self().id
        for node in nodes:
            if int(node.port) in xrange(9091, 9991):
                rest.eject_node(node)
                nodes.remove(node)

        if len(nodes) > 1:
            log.info("rebalancing all nodes in order to remove nodes")
            rest.log_client_error("Starting rebalance from test, ejected nodes %s" % \
                                                             [node.id for node in nodes if node.id != master_id])
            removed = helper.remove_nodes(knownNodes=[node.id for node in nodes],
                                          ejectedNodes=[node.id for node in nodes if node.id != master_id],
                                          wait_for_rebalance=wait_for_rebalance)
            success_cleaned = []
            for removed in [node for node in nodes if (node.id != master_id)]:
                removed.rest_password = servers[0].rest_password
                removed.rest_username = servers[0].rest_username
                try:
                    rest = RestConnection(removed)
                except Exception as ex:
                    log.error("can't create rest connection after rebalance out for ejected nodes,\
                        will retry after 10 seconds according to MB-8430: {0} ".format(ex))
                    time.sleep(10)
                    rest = RestConnection(removed)
                start = time.time()
                while time.time() - start < 30:
                    if len(rest.get_pools_info()["pools"]) == 0:
                        success_cleaned.append(removed)
                        break
                    else:
                        time.sleep(0.1)
                if time.time() - start > 10:
                    log.error("'pools' on node {0}:{1} - {2}".format(
                           removed.ip, removed.port, rest.get_pools_info()["pools"]))
            for node in set([node for node in nodes if (node.id != master_id)]) - set(success_cleaned):
                log.error("node {0}:{1} was not cleaned after removing from cluster".format(
                           removed.ip, removed.port))
                try:
                    rest = RestConnection(node)
                    rest.force_eject_node()
                except Exception as ex:
                    log.error("force_eject_node {0}:{1} failed: {2}".format(removed.ip, removed.port, ex))
            if len(set([node for node in nodes if (node.id != master_id)])\
                    - set(success_cleaned)) != 0:
                raise Exception("not all ejected nodes were cleaned successfully")

            log.info("removed all the nodes from cluster associated with {0} ? {1}".format(servers[0], \
                    [(node.id, node.port) for node in nodes if (node.id != master_id)]))
开发者ID:EricACooper,项目名称:testrunner,代码行数:58,代码来源:cluster_helper.py

示例2: _add_all_node_body

# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import eject_node [as 别名]
 def _add_all_node_body(self):
     self.common_setUp(False)
     master = self.servers[0]
     master_rest = RestConnection(master)
     added_otps = []
     for i in range(1, len(self.servers)):
         ip = self.servers[i].ip
         port = self.servers[i].port
         self.log.info("adding node : {0} to the cluster".format(ip))
         otpNode = master_rest.add_node(
             user=self.membase.rest_username, password=self.membase.rest_password, remoteIp=ip, port=port
         )
         if otpNode:
             added_otps.append(otpNode)
             self.log.info("added node : {0} to the cluster".format(otpNode.id))
         else:
             self.fail(msg="unable to add node : {0} to the cluster".format(ip))
         time.sleep(5)
     for otpNode in added_otps:
         # now lets eject it
         self.log.info("ejecting the node {0}".format(otpNode.id))
         ejected = master_rest.eject_node(
             user=self.membase.rest_username, password=self.membase.rest_password, otpNode=otpNode.id
         )
         self.assertTrue(ejected, msg="unable to eject the node {0}".format(otpNode.id))
开发者ID:ronniedada,项目名称:testrunner,代码行数:27,代码来源:addnodestests.py

示例3: _add_node_already_added_body

# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import eject_node [as 别名]
    def _add_node_already_added_body(self):
        self.common_setUp(False)
        master = self.servers[0]
        master_rest = RestConnection(master)
        for i in range(1,len(self.servers)):
            ip = self.servers[i].ip
            self.log.info('adding node : {0} to the cluster'.format(ip))
            otpNode = master_rest.add_node(user=self.membase.rest_username,
                                           password=self.membase.rest_password,
                                           remoteIp=ip, port=self.servers[i].port)
            if otpNode:
                self.log.info('added node : {0} to the cluster'.format(otpNode.id))
                #try to add again
                try:
                    readd_otpNode = master_rest.add_node(user=self.membase.rest_username,
                                           password=self.membase.rest_password,
                                           remoteIp=ip,port=self.servers[i].port)
                    if readd_otpNode:
                        self.fail("server did not raise any exception when calling add_node on an already added node")
                except ServerAlreadyJoinedException:
                    self.log.info("server raised ServerAlreadyJoinedException as expected")

                #now lets eject it
                self.log.info("ejecting the node {0}".format(otpNode.id))
                ejected = master_rest.eject_node(user=self.membase.rest_username,
                                                 password=self.membase.rest_password,
                                                 otpNode=otpNode.id)
                self.assertTrue(ejected,
                                msg="unable to eject the node {0}".format(otpNode.id))
            else:
                self.fail(msg="unable to add node : {0} to the cluster".format(ip))
开发者ID:jchris,项目名称:testrunner,代码行数:33,代码来源:addnodestests.py

示例4: _add_1_node_body

# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import eject_node [as 别名]
 def _add_1_node_body(self):
     master = self.servers[0]
     master_rest = RestConnection(master)
     for i in range(1,len(self.servers)):
         ip = self.servers[i].ip
         port = self.servers[i].port
         self.log.info('adding node : {0}:{1} to the cluster'.format(ip,port))
         otpNode = master_rest.add_node(user=self.membase.rest_username,
                                        password=self.membase.rest_password,
                                        remoteIp=ip, port=port)
         if otpNode:
             self.log.info('added node : {0} to the cluster'.format(otpNode.id))
             #now lets eject it
             self.log.info("ejecting the node {0}".format(otpNode.id))
             ejected = master_rest.eject_node(user=self.membase.rest_username,
                                              password=self.membase.rest_password,
                                              otpNode=otpNode.id)
             self.assertTrue(ejected,
                             msg="unable to eject the node {0}".format(otpNode.id))
         else:
             self.fail(msg="unable to add node : {0} to the cluster".format(ip))
         time.sleep(5)
开发者ID:jchris,项目名称:testrunner,代码行数:24,代码来源:addnodestests.py

示例5: cluster_nodes_write

# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import eject_node [as 别名]
    def cluster_nodes_write(self,username,password,host,port=8091, servers=None,cluster=None,httpCode=None,user_role=None):
        try:
            _cluster_nodes_write = {
                "ejectNode":"/controller/ejectNode;POST",
                #"addNode":"/controller/addNode;POST",
                #"addNodeV2":"/controller/addNodeV2;POST",
                #"uuidAddNode":"pools/default/serverGroups/<uuid>/addNode;POST",
                #"uiidAddNodev1":"/pools/default/serverGroups/<uuid>/addNodeV2;POST",
                #"failover":"/controller/failOver;POST",
                #"graceFullFailover":"/controller/startGracefulFailover;POST",
                #"rebalance":"/controller/rebalance;POST",
                #"reAddNode":"/controller/reAddNode;POST",
                #"reFailover":"/controller/reFailOver;POST",
                #"stopRebalance":"/controller/stopRebalance;POST",
                #"setRecoveryType":"/controller/setRecoveryType;POST"
            }

            rest = RestConnection(servers[0])
            known_nodes = []


            #Add Node
            params = {'hostname': servers[1].ip,'user': 'Administrator','password': 'password'}
            add_node = {"addNode":"controller/addNode;POST;" + str(params)}
            result = self._return_http_code(add_node,username,password,host=host,port=port, httpCode=httpCode, user_role=user_role)

            #cluster.rebalance(servers,servers[1],[])
            rest.eject_node("Administrator","password",'[email protected]'+servers[1].ip)

            #cluster.rebalance(servers,[],servers[1:])

            #time.sleep(30)
            #params = {'hostname': servers[1].ip,'user': 'Administrator','password': 'password'}
            #add_node = {"addNode":"controller/addNodeV2;POST;" + str(params)}
            #result = self._return_http_code(add_node,username,password,host=host,port=port, httpCode=httpCode, user_role=user_role)

            #cluster.rebalance(servers,[],servers[1:])

            time.sleep(30)
            cluster.rebalance(servers,servers[1:],[])
            params = {'otpNode': "[email protected]"+servers[1].ip}
            failover_node = {"failover":"controller/failOver;POST;"+str(params)}
            result = self._return_http_code(failover_node,username,password,host=host,port=port, httpCode=httpCode, user_role=user_role)
            time.sleep(30)
            cluster.rebalance(servers,[],servers[1:])

            time.sleep(15)
            cluster.rebalance(servers,servers[1:],[])
            time.sleep(15)
            params = {'otpNode': "[email protected]"+servers[1].ip}
            grace_failover = {"grace_failover":"controller/startGracefulFailover;POST;"+str(params)}
            result = self._return_http_code(grace_failover,username,password,host=host,port=port, httpCode=httpCode, user_role=user_role)
            time.sleep(60)
            rest.set_recovery_type("[email protected]"+servers[1].ip,'delta')
            time.sleep(30)

            rest.add_back_node("[email protected]"+servers[1].ip)

            time.sleep(30)
            serv_out = '[email protected]' + servers[2].ip
            rest.fail_over(serv_out,graceful=False)
            time.sleep(15)
            params = {'otpNode': "[email protected]"+servers[2].ip}
            radd_node = {"reAddNode":"controller/reAddNode;POST;"+ str(params)}
            result = self._return_http_code(radd_node,username,password,host=host,port=port, httpCode=httpCode, user_role=user_role)


            time.sleep(30)

            #serv_out = '[email protected]' + servers[3].ip
            #rest.fail_over(serv_out,graceful=False)
            #params = {'otpNode': "[email protected]"+servers[3].ip}
            #radd_node = {"reFailOver":"controller/reFailOver;POST;"+ str(params)}
            #result = self._return_http_code(radd_node,username,password,host=host,port=port, httpCode=httpCode, user_role=user_role)

            cluster.rebalance(servers,[],servers[1:])

            time.sleep(30)
            cluster.rebalance(servers,servers[1:],[])
            time.sleep(30)
            serv_out = '[email protected]' + servers[1].ip
            rest.fail_over(serv_out,graceful=True)
            time.sleep(60)
            params = {'otpNode': '[email protected]'+servers[1].ip,'recoveryType': 'delta'}
            recovery_type = {"setRecoveryType":"controller/setRecoveryType;POST;"+ str(params)}
            result = self._return_http_code(recovery_type,username,password,host=host,port=port, httpCode=httpCode, user_role=user_role)
            cluster.rebalance(servers)
        except:
            log.info ("Issue with rebalance, going to next test case")
            cluster.rebalance(servers,[],servers[1:])
            for server in servers:
                rest = RestConnection(server)
                rest.init_cluster(username='Administrator', password='password')
                rest.init_cluster_memoryQuota(memoryQuota=rest.get_nodes_self().mcdMemoryReserved)
开发者ID:mihirkamdarcouchbase,项目名称:testrunner,代码行数:96,代码来源:rbacPermissionList.py


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