本文整理汇总了Python中membase.api.rest_client.RestConnection.rename_node方法的典型用法代码示例。如果您正苦于以下问题:Python RestConnection.rename_node方法的具体用法?Python RestConnection.rename_node怎么用?Python RestConnection.rename_node使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类membase.api.rest_client.RestConnection
的用法示例。
在下文中一共展示了RestConnection.rename_node方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: convert_to_hostname
# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import rename_node [as 别名]
def convert_to_hostname(self, servers_with_hostnames, username='Administrator', password='password'):
try:
hostname = []
for server in servers_with_hostnames:
shell = RemoteMachineShellConnection(server)
info = shell.extract_remote_info()
domain = ''.join(info.domain[0])
if not domain:
output = shell.execute_command_raw('nslookup %s' % info.hostname[0])
print output
self.fail("Domain is not defined, couchbase cannot be configured correctly. NOT A BUG. CONFIGURATION ISSUE")
hostname.append(info.hostname[0] + "." + domain)
master_rest = RestConnection(server)
current_hostname = master_rest.get_nodes_self().hostname
self.log.info("get_node_self function returned : {0}".format(current_hostname))
if server.ip in current_hostname:
self.log.info("Node {0} is referred via IP. Need to be referred with hostname. Changing the name of the node!!".format(server.ip))
version = RestConnection(server).get_nodes_self().version
if version.startswith("1.8.1") or version.startswith("2.0.0") or version.startswith("2.0.1"):
RemoteUtilHelper.use_hostname_for_server_settings(server)
master_rest.init_cluster()
else:
master_rest.init_cluster()
master_rest.rename_node(username=username, password=password, port='', hostname=hostname[-1])
else:
self.log.info("Node {0} already referred via hostname. No need to convert the name".format(server.ip))
finally:
shell.disconnect()
return hostname
示例2: convert_to_hostname
# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import rename_node [as 别名]
def convert_to_hostname(self, servers_with_hostnames):
try:
hostname = []
for server in servers_with_hostnames:
shell = RemoteMachineShellConnection(server)
info = shell.extract_remote_info()
domain = ''.join(info.domain[0])
hostname.append(info.hostname[0] + "." + domain)
master_rest = RestConnection(server)
var = master_rest.get_nodes_self().hostname
flag = True if server.ip in var else False
self.log.info("get_node_self function returned : {0}".format(var))
if flag:
self.log.info("Node {0} is referred via IP. Need to be referred with hostname. Changing the name of the node!!".format(server.ip))
version = RestConnection(server).get_nodes_self().version
if version.startswith("1.8.1") or version.startswith("2.0.0") or version.startswith("2.0.1"):
RemoteUtilHelper.use_hostname_for_server_settings(server)
obj = RestConnection(server)
obj.init_cluster()
else:
obj = RestConnection(server)
obj.init_cluster()
var = master_rest.rename_node(username='Administrator', password='password', port='', hostname=hostname[-1])
else:
self.log.info("Node {0} already referred via hostname. No need to convert the name".format(server.ip))
finally:
shell.disconnect()
return hostname
示例3: rest_api_renameNode
# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import rename_node [as 别名]
def rest_api_renameNode(self):
try:
self.shell = RemoteMachineShellConnection(self.master)
#com_inst_build = "cat /opt/couchbase/VERSION.txt"
#out = self.shell.execute_command(com_inst_build.format(com_inst_build))
self.install_builds(self.builds, self.servers[0:1])
if self.is_negative_test:
master_rest = RestConnection(self.master)
self.log.info("Renaming node {0} to {1}".format(self.master, self.name))
var = master_rest.rename_node(username=self.master.rest_username, password=self.master.rest_password,
port=self.master.port, hostname=self.name, is_negative_test=True)
out = var.pop()
self.assertEqual(out, self.error, msg="Fail to find correct error. The error should be {0}, but we got : {1}".format(self.error, out))
self.log.info("Got correct error - {0}....Passing the test".format(out))
else:
self.log.info("Node {0} is referred via IP. Changing the name of the node".format(self.servers[0:1]))
hostname = []
info = self.shell.extract_remote_info()
domain = ''.join(info.domain[0])
hostname.append(info.hostname[0] + "." + domain)
self.convert_to_hostname(self, self.servers[0:1])
self.log.info("Calling get_node_self() to check the status of node {0}".format(self.servers[0:1]))
obj = RestConnection(self.master)
var = obj.get_nodes_self().hostname
flag = True if self.master.ip in var else False
self.assertEqual(flag, False, msg="Fail - Node {0} is still referred via IP. Should\
have been referred via hostname. Failing the test!".format(self.master.ip))
self.log.info("Name of node {0} got converted to hostname. Proceeding......!".format(self.master.ip))
self.sleep(10)
self.log.info("Now changing name of node {0} from hostname to IP".format(self.master.ip))
var = obj.rename_node(username='Administrator', password='password', port='', hostname=self.master.ip)
self.log.info("Calling get_node_self() to check the status of the node {0}".format(self.master.ip))
var = obj.get_nodes_self().hostname
flag = True if self.master.ip in var else False
self.assertEqual(flag, True, msg="Fail - Node {0} is still referred via hostname. Should have been referred via IP. Failing the test!".format(self.master.ip))
self.log.info("Node {0} referred via IP. Pass !".format(self.master.ip))
finally:
self.shell.disconnect()
示例4: rename_nodes
# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import rename_node [as 别名]
def rename_nodes(self, servers, names={}):
hostnames={}
for server in servers:
shell = RemoteMachineShellConnection(server)
try:
if not names:
hostname = shell.get_full_hostname()
else:
hostname = names[server]
rest = RestConnection(server)
renamed, content = rest.rename_node(hostname, username=server.rest_username, password=server.rest_password)
self.assertTrue(renamed, "Server %s is not renamed!Hostname %s. Error %s" %(
server, hostname, content))
hostnames[server] = hostname
finally:
shell.disconnect()
return hostnames
示例5: initialize
# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import rename_node [as 别名]
def initialize(self, params):
start_time = time.time()
cluster_initialized = False
server = params["server"]
remote_client = RemoteMachineShellConnection(params["server"])
while time.time() < start_time + 5 * 60:
try:
rest = RestConnection(server)
# Optionally change node name and restart server
if params.get('use_domain_names', 0):
remote_client.set_node_name(server.ip)
rest.rename_node(server.ip)
# Make sure that data_path and index_path are writable by couchbase user
for path in set(filter(None, [server.data_path, server.index_path])):
time.sleep(3)
for cmd in ("rm -rf {0}/*".format(path),
"chown -R couchbase:couchbase {0}".format(path)):
remote_client.execute_command(cmd)
rest.set_data_path(data_path=server.data_path,
index_path=server.index_path)
time.sleep(3)
# Initialize cluster
rest.init_cluster(username=server.rest_username,
password=server.rest_password)
memory_quota = rest.get_nodes_self().mcdMemoryReserved
rest.init_cluster_memoryQuota(memoryQuota=memory_quota)
# TODO: Symlink data-dir to custom path
# remote_client.stop_couchbase()
# remote_client.execute_command('mv /opt/couchbase/var {0}'.format(server.data_path))
# remote_client.execute_command('ln -s {0}/var /opt/couchbase/var'.format(server.data_path))
# remote_client.execute_command("chown -h couchbase:couchbase /opt/couchbase/var")
# remote_client.start_couchbase()
# Optionally disable consistency check
if params.get('disable_consistency', 0):
rest.set_couchdb_option(section='couchdb',
option='consistency_check_ratio',
value='0.0')
# memcached env variable
mem_req_tap_env = params.get('MEMCACHED_REQS_TAP_EVENT', 0)
if mem_req_tap_env:
remote_client.set_environment_variable('MEMCACHED_REQS_TAP_EVENT',
mem_req_tap_env)
remote_client.disconnect()
# TODO: Make it work with windows
if "erlang_threads" in params:
num_threads = params.get('erlang_threads', testconstants.NUM_ERLANG_THREADS)
# Stop couchbase-server
ClusterOperationHelper.stop_cluster([server])
if "sync_threads" in params or ':' in num_threads:
sync_threads = params.get('sync_threads', True)
else:
sync_threads = False
# Change type of threads(sync/async) and num erlang threads
ClusterOperationHelper.change_erlang_threads_values([server], sync_threads, num_threads)
# Start couchbase-server
ClusterOperationHelper.start_cluster([server])
if "erlang_gc_level" in params:
erlang_gc_level = params.get('erlang_gc_level', None)
if erlang_gc_level is None:
# Don't change the value
break
# Stop couchbase-server
ClusterOperationHelper.stop_cluster([server])
# Change num erlang threads
ClusterOperationHelper.change_erlang_gc([server], erlang_gc_level)
# Start couchbase-server
ClusterOperationHelper.start_cluster([server])
cluster_initialized = True
break
except ServerUnavailableException:
log.error("error happened while initializing the cluster @ {0}".format(server.ip))
log.info('sleep for 5 seconds before trying again ...')
time.sleep(5)
if not cluster_initialized:
raise Exception("unable to initialize couchbase node")
示例6: test_settingsCluster
# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import rename_node [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)