本文整理汇总了Python中membase.api.rest_client.RestConnection._http_request方法的典型用法代码示例。如果您正苦于以下问题:Python RestConnection._http_request方法的具体用法?Python RestConnection._http_request怎么用?Python RestConnection._http_request使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类membase.api.rest_client.RestConnection
的用法示例。
在下文中一共展示了RestConnection._http_request方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_simple_ui_request
# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import _http_request [as 别名]
def test_simple_ui_request(self):
rest = RestConnection(self.master)
passed = True
for api in ["", "versions", "pools", "pools/default", "pools/nodes", "pools/default/overviewStats",
"pools/default/buckets", "pools/default/buckets/@query/stats", "pools/default/nodeServices",
"pools/default/remoteClusters", "pools/default/serverGroups", "pools/default/certificate",
"pools/default/settings/memcached/global", "nodeStatuses", "logs", "settings/web",
"settings/alerts",
"settings/stats", "settings/autoFailover", "settings/maxParallelIndexers",
"settings/viewUpdateDaemon",
"settings/autoCompaction", "settings/replications", "settings/replications",
"settings/saslauthdAuth", "settings/audit", "internalSettings", "nodes/self/xdcrSSLPorts",
"indexStatus",
#"diag/vbuckets", MB-15080
"settings/indexes", "diag",
#"diag/ale", MB-15080
"pools/default/rebalanceProgress", "pools/default/tasks", "index.html", "sasl_logs",
"couchBase", "sampleBuckets"]:
url = rest.baseUrl + api
self.log.info("GET " + url)
try:
status, content, header = rest._http_request(url)
except IncompleteRead, e:
self.log.warn("size of partial responce {0} api is {1} bytes".format(api, sys.getsizeof(e.partial)))
if api != "diag":
#otherwise for /diag API we should increase request time for dynamic data in _http_request
passed = False
continue
self.log.info(header)
if not self.is_linux and api == "settings/saslauthdAuth":
#This http API endpoint is only supported in enterprise edition running on GNU/Linux
continue
if not status:
self.log.info("wrong status for {0} GET request {1}".format(url, header))
passed = False
示例2: _retrieve_user_roles
# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import _http_request [as 别名]
def _retrieve_user_roles(self):
rest = RestConnection(self.master_ip)
url = "/settings/rbac/users"
api = rest.baseUrl + url
status, content, header = rest._http_request(api, 'GET')
log.info(" Retrieve User Roles - Status - {0} -- Content - {1} -- Header - {2}".format(status, content, header))
return status, content, header
示例3: _retrive_all_user_role
# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import _http_request [as 别名]
def _retrive_all_user_role(self, user_list=None ):
server = self.master_ip
rest = RestConnection(server)
url = "/settings/rbac/roles"
api = rest.baseUrl + url
status, content, header = rest._http_request(api, 'GET')
log.info(" Retrieve all User roles - Status - {0} -- Content - {1} -- Header - {2}".format(status, content, header))
return status, content, header
示例4: _delete_user
# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import _http_request [as 别名]
def _delete_user(self,user_name):
rest = RestConnection(self.master_ip)
url = "/settings/rbac/users/" + user_name
api = rest.baseUrl + url
status, content, header = rest._http_request(api, 'DELETE')
print status
print content
print header
return status, content, header
示例5: _retrieve_user_roles
# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import _http_request [as 别名]
def _retrieve_user_roles(self):
rest = RestConnection(self.master_ip)
url = "/settings/rbac/users"
api = rest.baseUrl + url
status, content, header = rest._http_request(api, 'GET')
print status
print content
print header
return status, content, header
示例6: _retrive_all_user_role
# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import _http_request [as 别名]
def _retrive_all_user_role(self, user_list=None ):
server = self.master_ip
rest = RestConnection(server)
url = "/settings/rbac/roles"
api = rest.baseUrl + url
status, content, header = rest._http_request(api, 'GET')
print status
print content
print header
return status, content, header
示例7: _delete_user
# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import _http_request [as 别名]
def _delete_user(self,user_name):
rest = RestConnection(self.master_ip)
if self.auth_type == 'ldap' or self.auth_type == "pam":
url = "/settings/rbac/users/" + user_name
else:
url = "settings/rbac/users/local/" + user_name
api = rest.baseUrl + url
status, content, header = rest._http_request(api, 'DELETE')
log.info (" Deleting User - Status - {0} -- Content - {1} -- Header - {2}".format(status, content, header))
return status, content, header
示例8: _set_user_roles
# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import _http_request [as 别名]
def _set_user_roles(self,user_name,payload):
rest = RestConnection(self.master_ip)
if self.auth_type == "ldap" or self.auth_type == "pam":
url = "settings/rbac/users/" + user_name
elif self.auth_type == 'builtin':
url = "settings/rbac/users/local/" + user_name
api = rest.baseUrl + url
status, content, header = rest._http_request(api, 'PUT', params=payload)
log.info(" Set User Roles - Status - {0} -- Content - {1} -- Header - {2}".format(status, content, header))
return status, content, header
示例9: _check_user_permission
# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import _http_request [as 别名]
def _check_user_permission(self,user_name,password,permission_set):
rest = RestConnection(self.master_ip)
url = "pools/default/checkPermissions/"
param = permission_set
api = rest.baseUrl + url
authorization = base64.encodestring('%s:%s' % (user_name, password))
header = {'Content-Type': 'application/x-www-form-urlencoded',
'Authorization': 'Basic %s' % authorization,
'Accept': '*/*'}
status, content, header = rest._http_request(api, 'POST', params=param,headers=header)
return status, content, header
示例10: _set_user_roles
# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import _http_request [as 别名]
def _set_user_roles(self,user_name,payload):
rest = RestConnection(self.master_ip)
url = "settings/rbac/users/" + user_name
#param = urllib.urlencode(payload)
param = payload
api = rest.baseUrl + url
status, content, header = rest._http_request(api, 'PUT', param)
print status
print content
print header
return status, content, header
示例11: test_simple_ui_request
# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import _http_request [as 别名]
def test_simple_ui_request(self):
rest = RestConnection(self.master)
passed = True
self.log.info("GET " + rest.query_baseUrl)
status, content, header = rest._http_request(rest.query_baseUrl)
self.log.info(header)
if not status:
self.log.info("wrong status for {0} GET request {1}".format(rest.query_baseUrl, header))
passed = False
self.assertTrue(passed, msg="some GET requests failed. See logs above")
_, content, _ = rest._http_request(rest.query_baseUrl)
occurrences = [m.start() for m in re.finditer('web request failed', content)]
for occurrence in occurrences:
subcontent = content[occurrence - 1000: occurrence + 1000]
if 'path,"/diag"' in subcontent:
break
else:
passed = False
self.log.info(subcontent)
self.assertTrue(passed, "some web request failed in the server logs. See logs above")
示例12: _rest_client_wrapper
# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import _http_request [as 别名]
def _rest_client_wrapper(self,username,password, url,method,params,restClient,port=None):
if restClient == None:
restClient = self.master_ip
if port != None:
restClient.port=port
rest = RestConnection(restClient)
rest.username = username
rest.password = password
api = rest.baseUrl + url
status, content, header = rest._http_request(api, method=method, params=params)
print content
print status
return header['status']
示例13: FailoverTests
# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import _http_request [as 别名]
#.........这里部分代码省略.........
self.log.info('picking server : {0} as the master'.format(self.referenceNode))
def run_failover_operations(self, chosen, failover_reason):
""" Method to run fail over operations used in the test scenario based on failover reason """
# Perform Operations relalted to failover
for node in chosen:
if failover_reason == 'stop_server':
self.stop_server(node)
self.log.info("10 seconds delay to wait for membase-server to shutdown")
# wait for 5 minutes until node is down
self.assertTrue(RestHelper(self.rest).wait_for_node_status(node, "unhealthy", 300),
msg="node status is not unhealthy even after waiting for 5 minutes")
elif failover_reason == "firewall":
server = [srv for srv in self.servers if node.ip == srv.ip][0]
RemoteUtilHelper.enable_firewall(server, bidirectional=self.bidirectional)
status = RestHelper(self.rest).wait_for_node_status(node, "unhealthy", 300)
if status:
self.log.info("node {0}:{1} is 'unhealthy' as expected".format(node.ip, node.port))
else:
# verify iptables on the node if something wrong
for server in self.servers:
if server.ip == node.ip:
shell = RemoteMachineShellConnection(server)
info = shell.extract_remote_info()
if info.type.lower() == "windows":
o, r = shell.execute_command("netsh advfirewall show allprofiles")
shell.log_command_output(o, r)
else:
o, r = shell.execute_command("/sbin/iptables --list")
shell.log_command_output(o, r)
shell.disconnect()
self.rest.print_UI_logs()
api = self.rest.baseUrl + 'nodeStatuses'
status, content, header = self.rest._http_request(api)
json_parsed = json.loads(content)
self.log.info("nodeStatuses: {0}".format(json_parsed))
self.fail("node status is not unhealthy even after waiting for 5 minutes")
# define precondition check for failover
failed_over = self.rest.fail_over(node.id, graceful=self.graceful)
# Check for negative cases
if self.graceful and (failover_reason in ['stop_server', 'firewall']):
if failed_over:
# MB-10479
self.rest.print_UI_logs()
self.assertFalse(failed_over, "Graceful Falover was started for unhealthy node!!! ")
return
elif self.gracefulFailoverFail and failed_over:
""" Check if the fail_over fails as expected """
self.assertTrue(not failed_over,""" Graceful failover should fail due to not enough replicas """)
return
# Check if failover happened as expected or re-try one more time
if not failed_over:
self.log.info("unable to failover the node the first time. try again in 60 seconds..")
# try again in 75 seconds
self.sleep(75)
failed_over = self.rest.fail_over(node.id, graceful=self.graceful)
if self.graceful and (failover_reason not in ['stop_server', 'firewall']):
reached = RestHelper(self.rest).rebalance_reached()
self.assertTrue(reached, "rebalance failed for Graceful Failover, stuck or did not completed")
def run_operation_tasks(self):
""" Method to run operations Update/Delete/Create """
# Load All Buckets if num_items > 0
示例14: build_info
# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import _http_request [as 别名]
def build_info(node):
rest = RestConnection(node)
api = rest.baseUrl + 'nodes/self'
status, content = rest._http_request(api)
json_parsed = json.loads(content)
return json_parsed
示例15: FailoverTests
# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import _http_request [as 别名]
#.........这里部分代码省略.........
failed_over = True
for node in chosen:
unreachable = False
if failover_reason == 'stop_server':
unreachable=True
self.stop_server(node)
self.log.info("10 seconds delay to wait for membase-server to shutdown")
# wait for 5 minutes until node is down
self.assertTrue(RestHelper(self.rest).wait_for_node_status(node, "unhealthy", self.wait_timeout * 10),
msg="node status is not unhealthy even after waiting for 5 minutes")
elif failover_reason == "firewall":
unreachable=True
self.filter_list.append (node.ip)
server = [srv for srv in self.servers if node.ip == srv.ip][0]
RemoteUtilHelper.enable_firewall(server, bidirectional=self.bidirectional)
status = RestHelper(self.rest).wait_for_node_status(node, "unhealthy", self.wait_timeout * 10)
if status:
self.log.info("node {0}:{1} is 'unhealthy' as expected".format(node.ip, node.port))
else:
# verify iptables on the node if something wrong
for server in self.servers:
if server.ip == node.ip:
shell = RemoteMachineShellConnection(server)
info = shell.extract_remote_info()
if info.type.lower() == "windows":
o, r = shell.execute_command("netsh advfirewall show allprofiles")
shell.log_command_output(o, r)
else:
o, r = shell.execute_command("/sbin/iptables --list")
shell.log_command_output(o, r)
shell.disconnect()
self.rest.print_UI_logs()
api = self.rest.baseUrl + 'nodeStatuses'
status, content, header = self.rest._http_request(api)
json_parsed = json.loads(content)
self.log.info("nodeStatuses: {0}".format(json_parsed))
self.fail("node status is not unhealthy even after waiting for 5 minutes")
# verify the failover type
if self.check_verify_failover_type:
graceful_count, graceful_failover = self.verify_failover_type(node, graceful_count, self.num_replicas, unreachable)
# define precondition check for failover
success_failed_over = self.rest.fail_over(node.id, graceful=(self.graceful and graceful_failover))
if self.graceful and graceful_failover:
if self.stopGracefulFailover or self.killNodes or self.stopNodes or self.firewallOnNodes:
self.victim_node_operations(node)
# Start Graceful Again
self.log.info(" Start Graceful Failover Again !")
success_failed_over = self.rest.fail_over(node.id, graceful=(self.graceful and graceful_failover))
msg = "graceful failover failed for nodes {0}".format(node.id)
self.assertTrue(self.rest.monitorRebalance(stop_if_loop=True), msg=msg)
else:
msg = "rebalance failed while removing failover nodes {0}".format(node.id)
self.assertTrue(self.rest.monitorRebalance(stop_if_loop=True), msg=msg)
failed_over = failed_over and success_failed_over
# Check for negative cases
if self.graceful and (failover_reason in ['stop_server', 'firewall']):
if failed_over:
# MB-10479
self.rest.print_UI_logs()
self.assertFalse(failed_over, "Graceful Falover was started for unhealthy node!!! ")
return
elif self.gracefulFailoverFail and not failed_over:
""" Check if the fail_over fails as expected """
self.assertFalse(failed_over,""" Graceful failover should fail due to not enough replicas """)
return