Permalink
Browse files

MB-6212: Check if bucket ram quota

If specified ram quota exeeds available quota in the cluster,
give out error message and exit

Change-Id: I8cb43e5083fe03a835a12672f951f9bccc3877db
Reviewed-on: http://review.couchbase.org/19661
Tested-by: Bin Cui <bin.cui@gmail.com>
Reviewed-by: Steve Yen <steve.yen@gmail.com>
  • Loading branch information...
1 parent 11d89e5 commit 10913bb528df394ccce587f1d8e0d99c05886fb0 @bcui6611 bcui6611 committed Aug 15, 2012
Showing with 15 additions and 0 deletions.
  1. +15 −0 cbdocloader
View
@@ -51,6 +51,21 @@ class DocLoader:
'password': self.options.password}
self.rest = RestConnection(server_info)
+ uri = "http://%s:%s/nodes/self" % (server_info["ip"], server_info["port"])
+ status, content = self.rest._http_request(uri)
+ quotaUnused = -1
+ if status:
+ try:
+ json_parsed = json.loads(content)
+ quotaTotal = json_parsed["storageTotals"]["ram"]["quotaTotal"]
+ quotaUnused = quotaTotal - json_parsed["storageTotals"]["ram"]["quotaUsed"]
+ except:
+ pass
+ quotaUnused = quotaUnused / 1024.0
+ if quotaUnused > 0 and quotaUnused < self.options.ram_quota:
+ print "RAM quota specified is too large to be provisioned into this cluster"
+ print "Available RAM quota: %d, requested: %d" % (quotaUnused, self.options.ram_quota)
+ sys.exit()
if not RestHelper(self.rest).bucket_exists(self.options.bucket):
self.rest.create_bucket(bucket=self.options.bucket,

0 comments on commit 10913bb

Please sign in to comment.