Skip to content

Commit

Permalink
MB-6212: Check if bucket ram quota
Browse files Browse the repository at this point in the history
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
bcui6611 committed Aug 15, 2012
1 parent 11d89e5 commit 10913bb
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions cbdocloader
Expand Up @@ -51,6 +51,21 @@ class DocLoader:
'password': self.options.password} 'password': self.options.password}


self.rest = RestConnection(server_info) 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): if not RestHelper(self.rest).bucket_exists(self.options.bucket):
self.rest.create_bucket(bucket=self.options.bucket, self.rest.create_bucket(bucket=self.options.bucket,
Expand Down

0 comments on commit 10913bb

Please sign in to comment.