Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MB-6233: Retrieve couch_api_base from server

For unconfigured setup, the couch_api_base value cannot be retrieved
correctly by url: http://ip:port/pools/default. But it is avaible
by using url: http://ip:port/pools/default/buckets/bucket_name
Before saving any design docs, it is better to reset the couch_api_base
value in couchbase client object.

Change-Id: I432064afddf18c0bf10a2218fe595b86b4180288
Reviewed-on: http://review.couchbase.org/20137
Tested-by: Bin Cui <bin.cui@gmail.com>
Reviewed-by: Pavel Paulau <pavel.paulau@gmail.com>
  • Loading branch information...
commit 2284fc530a3db98a2f60184c046b08206e509661 1 parent c22674b
@bcui6611 bcui6611 authored
Showing with 21 additions and 0 deletions.
  1. +21 −0 cbdocloader
View
21 cbdocloader
@@ -134,6 +134,10 @@ class DocLoader:
self.options.password)
self.bucket = cb[self.options.bucket]
+
+ #Retrieve and reset couchbase_api_base from server
+ self.bucket.server.couch_api_base = self.retrive_couch_api_base(cb)
+
self.views = list()
if self.args[0].endswith('.zip'):
@@ -141,6 +145,23 @@ class DocLoader:
else:
self.enumerate_and_save()
+ def retrive_couch_api_base(self, cb):
+ if (':' in self.options.node):
+ ip, port = self.options.node.split(':')
+ else:
+ ip, port = self.options.node, 8091
+
+ server_config_uri = "http://%s:%s/pools/default/buckets/%s" % (ip, port, self.options.bucket)
+ config = client.ServerHelper.parse_server_config(server_config_uri,
+ self.options.username,
+ self.options.password)
+ couch_api_base = config["nodes"][0].get("couchApiBase")
+
+ #Remove bucket suffix because it is added when saving design docs
+ couch_api_base = "/".join(couch_api_base.split("/")[:-1]) + "/"
+
+ return couch_api_base
+
def verify_queries(self):
for view in self.views:
print "View:", view
Please sign in to comment.
Something went wrong with that request. Please try again.