本文整理汇总了Python中membase.api.rest_client.RestConnection.get_ddoc方法的典型用法代码示例。如果您正苦于以下问题:Python RestConnection.get_ddoc方法的具体用法?Python RestConnection.get_ddoc怎么用?Python RestConnection.get_ddoc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类membase.api.rest_client.RestConnection
的用法示例。
在下文中一共展示了RestConnection.get_ddoc方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _verify_ddoc_ops_all_buckets
# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import get_ddoc [as 别名]
def _verify_ddoc_ops_all_buckets(self):
self.log.info("DDoc Validation Started")
rest = RestConnection(self.master)
# Iterate over all the DDocs/Views stored in the internal dictionary
for bucket, self.ddoc_view_map in self.bucket_ddoc_map.items():
for ddoc_name, view_list in self.ddoc_view_map.items():
try:
# fetch the DDoc information from the database
ddoc_json, header = rest.get_ddoc(bucket, ddoc_name)
self.log.info("Database Document {0} details : {1}".format(ddoc_name, json.dumps(ddoc_json)))
ddoc = DesignDocument._init_from_json(ddoc_name, ddoc_json)
for view in view_list:
if view.name not in [v.name for v in ddoc.views]:
self.fail(
"Validation Error: View - {0} in Design Doc - {1} and Bucket - {2} is missing from database".format(
view.name, ddoc_name, bucket
)
)
except ReadDocumentException:
self.fail(
"Validation Error: Design Document - {0} is missing from Bucket - {1}".format(ddoc_name, bucket)
)
self.log.info("DDoc Validation Successful")
示例2: execute
# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import get_ddoc [as 别名]
def execute(self, task_manager):
rest = RestConnection(self.server)
try:
# remove view from existing design doc
content = rest.get_ddoc(self.bucket, self.design_doc_name)
ddoc = DesignDocument._init_from_json(self.design_doc_name, content)
status = ddoc.delete_view(self.view)
if not status:
self.state = FINISHED
self.set_exception(Exception('View does not exist! %s' % (self.view.name)))
# update design doc
rest.create_design_document(self.bucket, ddoc)
self.state = CHECKING
task_manager.schedule(self, 2)
except (ValueError, ReadDocumentException, DesignDocCreationException) as e:
self.state = FINISHED
self.set_exception(e)
#catch and set all unexpected exceptions
except Exception as e:
self.state = FINISHED
self.log.info("Unexpected Exception Caught")
self.set_exception(e)
示例3: create_primary_index_for_3_0_and_greater
# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import get_ddoc [as 别名]
def create_primary_index_for_3_0_and_greater(self):
self.log.info("CHECK FOR PRIMARY INDEXES")
rest = RestConnection(self.master)
versions = rest.get_nodes_versions()
ddoc_name = 'ddl_#primary'
if versions[0].startswith("3"):
try:
rest.get_ddoc(self.buckets[0], ddoc_name)
except ReadDocumentException:
for bucket in self.buckets:
self.log.info("Creating primary index for %s ..." % bucket.name)
self.query = "CREATE PRIMARY INDEX ON %s " % (bucket.name)
try:
self.run_cbq_query()
except Exception, ex:
self.log.error('ERROR during index creation %s' % str(ex))
示例4: verify_ddoc
# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import get_ddoc [as 别名]
def verify_ddoc(self, file):
rest = RestConnection(self.master)
ddoc_names = self.get_ddoc_names(file)
for bucket in self.buckets:
for ddoc_name in ddoc_names:
ddoc_json, header = rest.get_ddoc(bucket, ddoc_name)
if ddoc_json is not None:
self.log.info('Database Document {0} details : {1}'.format(ddoc_name, json.dumps(ddoc_json)))
else:
raise Exception("ddoc %s is not imported" % ddoc_name)
示例5: _check_ddoc_revision
# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import get_ddoc [as 别名]
def _check_ddoc_revision(self):
valid = False
rest = RestConnection(self.server)
try:
content = rest.get_ddoc(self.bucket, self.design_doc_name)
new_rev_id = self._parse_revision(content['_rev'])
if new_rev_id != self.ddoc_rev_no:
self.ddoc_rev_no = new_rev_id
valid = True
except ReadDocumentException:
pass
return valid
示例6: _verify_ddoc_ops_all_buckets
# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import get_ddoc [as 别名]
def _verify_ddoc_ops_all_buckets(self):
rest = RestConnection(self.servers[0])
for bucket, self.ddoc_view_map in self.bucket_ddoc_map.items():
for ddoc_name, self.view_name_list in self.ddoc_view_map.items():
try:
ddoc_json = rest.get_ddoc(bucket, ddoc_name)
self.log.info('Document {0} details : {1}'.format(ddoc_name,json.dumps(ddoc_json)))
ddoc = DesignDocument._init_from_json(ddoc_name, ddoc_json)
for view_name in self.view_name_list:
if view_name not in [view.name for view in ddoc.views]:
self.fail("Validation Error: View - {0} in Design Doc - {1} and Bucket - {2} is missing".format(view_name,ddoc_name, bucket))
except ReadDocumentException:
self.fail("Validation Error: Design Document - {0} is missing".format(ddoc_name))
示例7: _check_ddoc_revision
# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import get_ddoc [as 别名]
def _check_ddoc_revision(self):
valid = False
rest = RestConnection(self.server)
try:
content = rest.get_ddoc(self.bucket, self.design_doc_name)
new_rev_id = self._parse_revision(content['_rev'])
if new_rev_id != self.ddoc_rev_no:
self.ddoc_rev_no = new_rev_id
valid = True
except ReadDocumentException:
pass
#catch and set all unexpected exceptions
except Exception as e:
self.state = FINISHED
self.log.info("Unexpected Exception Caught")
self.set_exception(e)
return valid