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


Python RestConnection.add_zone方法代码示例

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


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

示例1: test_delete_empty_defautl_zone

# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import add_zone [as 别名]
 def test_delete_empty_defautl_zone(self):
     zone_name ="test1"
     default_zone = "Group 1"
     moved_node = []
     serverInfo = self.servers[0]
     moved_node.append(serverInfo.ip)
     rest = RestConnection(serverInfo)
     try:
         self.log.info("create zone {0}".format(zone_name))
         rest.add_zone(zone_name)
         if rest.is_zone_exist(zone_name):
             self.log.info("Move node {0} from zone {1} to zone {2}" \
                           .format(moved_node, default_zone, zone_name))
             status = rest.shuffle_nodes_in_zones(moved_node, default_zone, zone_name)
             if status:
                 rest.delete_zone(default_zone)
             else:
                 self.fail("Failed to move node {0} from zone {1} to zone {2}" \
                           .format(moved_node, default_zone, zone_name))
             if not rest.is_zone_exist(default_zone):
                 self.log.info("successful delete default zone")
             else:
                 raise Exception("Failed to delete default zone")
         rest.rename_zone(zone_name, default_zone)
     except Exception,e :
         print e
开发者ID:DavidAlphaFox,项目名称:couchbase,代码行数:28,代码来源:rackzonetests.py

示例2: cluster_server_groups_write

# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import add_zone [as 别名]
    def cluster_server_groups_write(self,username,password,host,port=8091, servers=None,cluster=None,httpCode=None,user_role=None):
        _cluster_server_groups_write = {
            "create_server_group":"pools/default/serverGroups;POST",
            "delete_server_group":"pools/default/serverGroups/<uuid>;DELETE",
            "edit_server_group":"pools/default/serverGroups;PUT",
            "edit_server_group_id":"pools/default/serverGroups/<uuid>;PUT"
        }

        rest = RestConnection(servers[0])
        try:
            rest.delete_zone('rbacNewGroup')
            rest.delete_zone('rbackGroup')
            rest.delete_zone('rbacNewGroupUpdated')

            create_server_group = {"create_server_group":"pools/default/serverGroups;POST;" + "{'name':'rbacGroup'}"}
            result = self._return_http_code(create_server_group,username,password,host=host,port=port, httpCode=httpCode, user_role=user_role)

            zones = rest.get_zone_names()
            create_server_group = {"delete_server_group":"pools/default/serverGroups/" + zones['rbacGroup'] + ";DELETE"}
            result = self._return_http_code(create_server_group,username,password,host=host,port=port, httpCode=httpCode, user_role=user_role)

            rest.add_zone('rbacNewGroup')
            zones = rest.get_zone_names()
            create_server_group = {"create_server_group":"pools/default/serverGroups/" + zones['rbacNewGroup'] + ";PUT;" + "{'name':'rbacNewGroupUpdated'}"}
            result = self._return_http_code(create_server_group,username,password,host=host,port=port, httpCode=httpCode, user_role=user_role)

        except:
            print "Issues with Server Group add test case"
开发者ID:mihirkamdarcouchbase,项目名称:testrunner,代码行数:30,代码来源:rbacPermissionList.py

示例3: test_create_zone_with_upper_lower_number_and_space_name

# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import add_zone [as 别名]
 def test_create_zone_with_upper_lower_number_and_space_name(self):
     zone_name = " AAAB BBCCC aakkk kmmm3 456 72 "
     serverInfo = self.servers[0]
     rest = RestConnection(serverInfo)
     try:
         self.log.info("create zone {0}".format(zone_name))
         rest.add_zone(zone_name)
     except Exception,e :
         print e
开发者ID:DavidAlphaFox,项目名称:couchbase,代码行数:11,代码来源:rackzonetests.py

示例4: test_create_zone_with_all_number_name

# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import add_zone [as 别名]
 def test_create_zone_with_all_number_name(self):
     zone_name = "3223345557666760"
     serverInfo = self.servers[0]
     rest = RestConnection(serverInfo)
     try:
         self.log.info("create zone {0}".format(zone_name))
         rest.add_zone(zone_name)
     except Exception,e :
         print e
开发者ID:DavidAlphaFox,项目名称:couchbase,代码行数:11,代码来源:rackzonetests.py

示例5: test_create_zone_with_lower_case_name

# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import add_zone [as 别名]
 def test_create_zone_with_lower_case_name(self):
     zone_name = "allwithlowercaseeeeeee"
     serverInfo = self.servers[0]
     rest = RestConnection(serverInfo)
     try:
         self.log.info("create zone {0}".format(zone_name))
         rest.add_zone(zone_name)
     except Exception,e :
         print e
开发者ID:DavidAlphaFox,项目名称:couchbase,代码行数:11,代码来源:rackzonetests.py

示例6: test_create_zone_with_upper_case_name

# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import add_zone [as 别名]
 def test_create_zone_with_upper_case_name(self):
     zone_name = "ALLWITHUPTERCASE"
     serverInfo = self.servers[0]
     rest = RestConnection(serverInfo)
     try:
         self.log.info("create zone {0}".format(zone_name))
         rest.add_zone(zone_name)
     except Exception,e :
         print e
开发者ID:DavidAlphaFox,项目名称:couchbase,代码行数:11,代码来源:rackzonetests.py

示例7: test_create_second_default_zone

# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import add_zone [as 别名]
 def test_create_second_default_zone(self):
     zone_name = "Group 1"
     serverInfo = self.servers[0]
     rest = RestConnection(serverInfo)
     try:
         self.log.info("create additional default zone")
         rest.add_zone(zone_name)
     except Exception,e :
         print e
开发者ID:DavidAlphaFox,项目名称:couchbase,代码行数:11,代码来源:rackzonetests.py

示例8: test_create_zone_with_none_ascii_name

# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import add_zone [as 别名]
 def test_create_zone_with_none_ascii_name(self):
     # zone name is limited to 64 bytes
     zone_name = "abcdGHIJKLMNOPQRSTUVWXYZ0123456789efghijklmnopqrstuvwyABCDEF_-.%"
     serverInfo = self.servers[0]
     rest = RestConnection(serverInfo)
     try:
         self.log.info("create zone {0}".format(zone_name))
         rest.add_zone(zone_name)
     except Exception,e :
         print e
开发者ID:DavidAlphaFox,项目名称:couchbase,代码行数:12,代码来源:rackzonetests.py

示例9: test_zone_enable_after_upgrade_from_ce_to_ee

# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import add_zone [as 别名]
    def test_zone_enable_after_upgrade_from_ce_to_ee(self):
        params = {}
        params['product'] = self.product
        params['version'] = self.version
        params['vbuckets'] = [self.vbuckets]
        params['type'] = self.type
        """ install couchbasse server community edition to run the test """
        InstallerJob().parallel_install(self.servers[:3], params)

        params["type"] = "enterprise"
        zone_name = "AAABBBCCCaakkkkmmm345672"
        serverInfo = self.servers[0]
        ini_servers = self.servers[:self.nodes_init]
        rest = RestConnection(serverInfo)
        self.user = serverInfo.rest_username
        self.password = serverInfo.rest_password
        if len(ini_servers) > 1:
            self.cluster.rebalance([ini_servers[0]], ini_servers[1:], [])
        rest = RestConnection(self.master)
        self._bucket_creation()

        """ verify all nodes in cluster in CE """
        if rest.is_enterprise_edition():
            raise Exception("This test needs couchbase server community edition to run")

        self._load_all_buckets(self.servers[0], self.gen_load, "create", 0)
        try:
            self.log.info("create zone {0}".format(zone_name))
            result = rest.add_zone(zone_name)
            if result:
                raise Exception("Zone feature should not be available in CE version")
        except Exception,e :
            if "Failed" in e:
                pass
开发者ID:DavidAlphaFox,项目名称:couchbase,代码行数:36,代码来源:rackzonetests.py

示例10: shuffle_nodes_between_zones_and_rebalance

# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import add_zone [as 别名]
 def shuffle_nodes_between_zones_and_rebalance(self, to_remove=None):
     """
     Shuffle the nodes present in the cluster if zone > 1. Rebalance the nodes in the end.
     Nodes are divided into groups iteratively i.e. 1st node in Group 1, 2nd in Group 2, 3rd in Group 1 and so on, when
     zone=2.
     :param to_remove: List of nodes to be removed.
     """
     if not to_remove:
         to_remove = []
     serverinfo = self.servers[0]
     rest = RestConnection(serverinfo)
     zones = ["Group 1"]
     nodes_in_zone = {"Group 1": [serverinfo.ip]}
     # Create zones, if not existing, based on params zone in test.
     # Shuffle the nodes between zones.
     if int(self.zone) > 1:
         for i in range(1, int(self.zone)):
             a = "Group "
             zones.append(a + str(i + 1))
             if not rest.is_zone_exist(zones[i]):
                 rest.add_zone(zones[i])
             nodes_in_zone[zones[i]] = []
         # Divide the nodes between zones.
         nodes_in_cluster = [node.ip for node in self.get_nodes_in_cluster()]
         nodes_to_remove = [node.ip for node in to_remove]
         for i in range(1, len(self.servers)):
             if self.servers[i].ip in nodes_in_cluster and self.servers[i].ip not in nodes_to_remove:
                 server_group = i % int(self.zone)
                 nodes_in_zone[zones[server_group]].append(self.servers[i].ip)
         # Shuffle the nodesS
         for i in range(1, self.zone):
             node_in_zone = list(set(nodes_in_zone[zones[i]]) -
                                 set([node for node in rest.get_nodes_in_zone(zones[i])]))
             rest.shuffle_nodes_in_zones(node_in_zone, zones[0], zones[i])
     otpnodes = [node.id for node in rest.node_statuses()]
     nodes_to_remove = [node.id for node in rest.node_statuses() if node.ip in [t.ip for t in to_remove]]
     # Start rebalance and monitor it.
     started = rest.rebalance(otpNodes=otpnodes, ejectedNodes=nodes_to_remove)
     if started:
         result = rest.monitorRebalance()
         msg = "successfully rebalanced cluster {0}"
         self.log.info(msg.format(result))
     # Verify replicas of one node should not be in the same zone as active vbuckets of the node.
     if self.zone > 1:
         self._verify_replica_distribution_in_zones(nodes_in_zone)
开发者ID:arod1987,项目名称:testrunner,代码行数:47,代码来源:volume.py

示例11: test_replica_distribution_in_zone

# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import add_zone [as 别名]
    def test_replica_distribution_in_zone(self):
        if len(self.servers) < int(self.num_node):
            msg = "This test needs minimum {1} servers to run.\n  Currently in ini file \
                   has only {0} servers".format(len(self.servers), self.num_node)
            self.log.error("{0}".format(msg))
            raise Exception(msg)
        if self.shutdown_zone >= self.zone:
            msg = "shutdown zone should smaller than zone"
            raise Exception(msg)
        serverInfo = self.servers[0]
        rest = RestConnection(serverInfo)
        zones = []
        zones.append("Group 1")
        nodes_in_zone = {}
        nodes_in_zone["Group 1"] = [serverInfo.ip]
        """ Create zone base on params zone in test"""
        if int(self.zone) > 1:
            for i in range(1,int(self.zone)):
                a = "Group "
                zones.append(a + str(i + 1))
                rest.add_zone(a + str(i + 1))
        servers_rebalanced = []
        self.user = serverInfo.rest_username
        self.password = serverInfo.rest_password
        if len(self.servers)%int(self.zone) != 0:
            msg = "unbalance zone.  Recaculate to make balance ratio node/zone"
            raise Exception(msg)
        """ Add node to each zone """
        k = 1
        for i in range(0, self.zone):
            if "Group 1" in zones[i]:
                total_node_per_zone = int(len(self.servers))/int(self.zone) - 1
            else:
                nodes_in_zone[zones[i]] = []
                total_node_per_zone = int(len(self.servers))/int(self.zone)
            for n in range(0,total_node_per_zone):
                nodes_in_zone[zones[i]].append(self.servers[k].ip)
                rest.add_node(user=self.user, password=self.password, \
                    remoteIp=self.servers[k].ip, port='8091', zone_name=zones[i])
                k += 1
        otpNodes = [node.id for node in rest.node_statuses()]
        """ Start rebalance and monitor it. """
        started = rest.rebalance(otpNodes, [])

        if started:
            try:
                result = rest.monitorRebalance()
            except RebalanceFailedException as e:
                self.log.error("rebalance failed: {0}".format(e))
                return False, servers_rebalanced
            msg = "successfully rebalanced cluster {0}"
            self.log.info(msg.format(result))
        """ Verify replica of one node should not in same zone of active. """
        self._verify_replica_distribution_in_zones(nodes_in_zone, "tap")

        """ Simulate entire nodes down in zone(s) by killing erlang process"""
        if self.shutdown_zone >= 1 and self.zone >=2:
            self.log.info("Start to shutdown nodes in zone to failover")
            for down_zone in range(1, self.shutdown_zone + 1):
                down_zone = "Group " + str(down_zone + 1)
                for sv in nodes_in_zone[down_zone]:
                    for si in self.servers:
                        if si.ip == sv:
                            server = si

                    shell = RemoteMachineShellConnection(server)
                    os_info = shell.extract_remote_info()
                    shell.kill_erlang(os_info)
                    """ Failover down node(s)"""
                    failed_over = rest.fail_over("[email protected]" + server.ip)
                    if not failed_over:
                        self.log.info("unable to failover the node the first time. \
                                       try again in 75 seconds..")
                        time.sleep(75)
                        failed_over = rest.fail_over("[email protected]" + server.ip)
                    self.assertTrue(failed_over, "unable to failover node after erlang killed")
        otpNodes = [node.id for node in rest.node_statuses()]
        self.log.info("start rebalance after failover.")
        """ Start rebalance and monitor it. """
        started = rest.rebalance(otpNodes, [])
        if started:
            try:
                result = rest.monitorRebalance()
            except RebalanceFailedException as e:
                self.log.error("rebalance failed: {0}".format(e))
                return False, servers_rebalanced
            msg = "successfully rebalanced in selected nodes from the cluster ? {0}"
            self.log.info(msg.format(result))
        """ Compare current keys in bucekt with initial loaded keys count. """
        self._verify_total_keys(self.servers[0], self.num_items)
开发者ID:DavidAlphaFox,项目名称:couchbase,代码行数:92,代码来源:rackzonetests.py

示例12: Exception

# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import add_zone [as 别名]
                    try:
                        self.log.info("try to create zone {0} when cluster is not completely EE".format(zone_name))
                        result = rest.add_zone(zone_name)
                        if result:
                            raise Exception("Zone feature should not be available in CE version")
                    except Exception,e :
                        if "Failed" in e:
                            pass
        serverInfo = self.servers[1]
        rest = RestConnection(serverInfo)
        self.user = serverInfo.rest_username
        self.password = serverInfo.rest_password
        if not rest.is_enterprise_edition():
            raise Exception("Test failed to upgrade cluster from CE to EE")
        self.log.info("try to create zone {0} when cluster {1} is completely EE".format(zone_name, serverInfo.ip))
        result = rest.add_zone(zone_name)
        self.log.info("sleep  5 seconds")
        time.sleep(5)
        if result:
            self.log.info("Zone feature is available in this cluster")
        else:
            raise Exception("Could not create zone with name: %s in cluster.  It's a bug" % zone_name)
        if rest.is_zone_exist(zone_name.strip()):
            self.log.info("verified! zone '{0}' is existed".format(zone_name.strip()))
        else:
            raise Exception("There is not zone with name: %s in cluster.  It's a bug" % zone_name)

        """ re-install enterprise edition for next test if there is any """
        InstallerJob().parallel_install([self.servers[0]], params)

        """ reset master node to new node to teardown cluster """
开发者ID:DavidAlphaFox,项目名称:couchbase,代码行数:33,代码来源:rackzonetests.py

示例13: test_settingsCluster

# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import add_zone [as 别名]

#.........这里部分代码省略.........
                               "view_fragmentation_threshold:percentage":50,
                               "view_fragmentation_threshold:size":10,
                               "purge_interval":3,
                               "source":"ns_server",
                               "user":"Administrator",
                               'source':source,
                               "user":user,
                               'ip':self.ipAddress,
                               'port':1234}
            rest.set_auto_compaction(dbFragmentThresholdPercentage=50,
                                     viewFragmntThresholdPercentage=50,
                                     dbFragmentThreshold=10,
                                     viewFragmntThreshold=10)

        elif (ops == 'modifyCompactionSettingsTime'):
            expectedResults = {"parallel_db_and_view_compaction":False,
                               "database_fragmentation_threshold:percentage":50,
                               "database_fragmentation_threshold:size":10,
                               "view_fragmentation_threshold:percentage":50,
                               "view_fragmentation_threshold:size":10,
                               "allowed_time_period:abort_outside":True,
                               "allowed_time_period:to_minute":15,
                               "allowed_time_period:from_minute":12,
                               "allowed_time_period:to_hour":1,
                               "allowed_time_period:from_hour":1,
                               "purge_interval":3,
                               "source":"ns_server",
                               "user":"Administrator",
                               'source':source,
                               "user":user,
                               'ip':self.ipAddress,
                               'port':1234,
                               }
            rest.set_auto_compaction(dbFragmentThresholdPercentage=50,
                                     viewFragmntThresholdPercentage=50,
                                     dbFragmentThreshold=10,
                                     viewFragmntThreshold=10,
                                     allowedTimePeriodFromHour=1,
                                     allowedTimePeriodFromMin=12,
                                     allowedTimePeriodToHour=1,
                                     allowedTimePeriodToMin=15,
                                     allowedTimePeriodAbort='true')

        elif (ops == "AddGroup"):
            expectedResults = {'group_name':'add group', 'source':source, 'user':user, 'ip':self.ipAddress, 'port':1234}
            rest.add_zone(expectedResults['group_name'])
            tempStr = rest.get_zone_uri()[expectedResults['group_name']]
            tempStr = (tempStr.split("/"))[4]
            expectedResults['uuid'] = tempStr

        elif (ops == "UpdateGroup"):
            expectedResults = {'group_name':'upGroup', 'source':source, 'user':user, 'ip':self.ipAddress, 'port':1234, 'nodes':[]}
            rest.add_zone(expectedResults['group_name'])
            rest.rename_zone(expectedResults['group_name'], 'update group')
            expectedResults['group_name'] = 'update group'
            tempStr = rest.get_zone_uri()[expectedResults['group_name']]
            tempStr = (tempStr.split("/"))[4]
            expectedResults['uuid'] = tempStr

        elif (ops == "UpdateGroupAddNodes"):
            sourceGroup = "Group 1"
            destGroup = 'destGroup'
            expectedResults = {'group_name':destGroup, 'source':source, 'user':user, 'ip':self.ipAddress, 'port':1234, 'nodes':['[email protected]' + self.master.ip], 'port':1234}
            #rest.add_zone(sourceGroup)
            rest.add_zone(destGroup)
            self.sleep(30)
            rest.shuffle_nodes_in_zones([self.master.ip], sourceGroup, destGroup)
            tempStr = rest.get_zone_uri()[expectedResults['group_name']]
            tempStr = (tempStr.split("/"))[4]
            expectedResults['uuid'] = tempStr

        elif (ops == "DeleteGroup"):
            expectedResults = {'group_name':'delete group', 'source':source, 'user':user, 'ip':self.ipAddress, 'port':1234}
            rest.add_zone(expectedResults['group_name'])
            tempStr = rest.get_zone_uri()[expectedResults['group_name']]
            tempStr = (tempStr.split("/"))[4]
            expectedResults['uuid'] = tempStr
            rest.delete_zone(expectedResults['group_name'])

        elif (ops == "regenCer"):
            expectedResults = {'source':source, 'user':user, 'ip':self.ipAddress, 'port':1234}
            rest.regenerate_cluster_certificate()

        elif (ops == 'renameNode'):
            rest.rename_node(self.master.ip, user, password)
            expectedResults = {"hostname":self.master.ip, "node":"[email protected]" + self.master.ip, "source":source, "user":user, "ip":self.ipAddress, "port":56845}

        try:
            self.checkConfig(self.eventID, self.master, expectedResults)
        finally:
            if (ops == "UpdateGroupAddNodes"):
                sourceGroup = "Group 1"
                destGroup = 'destGroup'
                rest.shuffle_nodes_in_zones([self.master.ip], destGroup, sourceGroup)

            rest = RestConnection(self.master)
            zones = rest.get_zone_names()
            for zone in zones:
                if zone != "Group 1":
                    rest.delete_zone(zone)
开发者ID:pkdevboxy,项目名称:testrunner,代码行数:104,代码来源:audittest.py


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