Skip to content

Commit

Permalink
Update cosbench.py to add cosbench user/subuser if use_existing is False
Browse files Browse the repository at this point in the history
  • Loading branch information
wadeholler authored and Mark Nelson committed Jan 25, 2016
1 parent 56cf505 commit ebfed44
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions benchmark/cosbench.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ def __init__(self, cluster, config):
self.objects = config["objects_max"]
self.mode = config["mode"]
self.user = settings.cluster.get('user')
self.rgw = settings.cluster.get('rgws')[0]
self.use_existing = settings.cluster.get('use_existing')

self.run_dir = '%s/osd_ra-%08d/op_size-%s/concurrent_procs-%03d/containers-%05d/objects-%05d/%s' % (self.run_dir, int(self.osd_ra), self.op_size, int(self.total_procs), int(self.containers),int(self.objects), self.mode)
self.out_dir = '%s/osd_ra-%08d/op_size-%s/concurrent_procs-%03d/containers-%05d/objects-%05d/%s' % (self.archive_dir, int(self.osd_ra), self.op_size, int(self.total_procs), int(self.containers),int(self.objects), self.mode)
Expand All @@ -46,7 +48,17 @@ def prerun_check(self):
pass
logger.debug("%s", cosconf)
if "username" in cosconf and "password" in cosconf and "url" in cosconf:

if not self.use_existing:
user, subuser = cosconf["username"].split(':')
stdout, stderr = common.pdsh("%s@%s" % (self.user, self.rgw),"radosgw-admin user create --uid='%s' --display-name='%s'" % (user, user)).communicate()
stdout, stderr = common.pdsh("%s@%s" % (self.user, self.rgw),"radosgw-admin subuser create --uid=%s --subuser=%s --access=full" % (user, cosconf["username"])).communicate()
stdout, stderr = common.pdsh("%s@%s" % (self.user, self.rgw),"radosgw-admin key create --uid=%s --subuser=%s --key-type=swift" % (user, cosconf["username"])).communicate()
stdout, stderr = common.pdsh("%s@%s" % (self.user, self.rgw),"radosgw-admin user modify --uid=%s --max-buckets=100000" % (user)).communicate()
stdout, stderr = common.pdsh("%s@%s" % (self.user, self.rgw),"radosgw-admin subuser modify --uid=%s --subuser=%s --secret=%s --key-type=swift" % (user, cosconf["username"], cosconf["password"])).communicate()

stdout, stderr = common.pdsh("%s@%s" % (self.user, self.config["controller"]),"curl -D - -H 'X-Auth-User: %s' -H 'X-Auth-Key: %s' %s" % (cosconf["username"], cosconf["password"], cosconf["url"])).communicate()

else:
logger.error("Auth Configuration in Yaml file is not in correct format")
sys.exit()
Expand Down

0 comments on commit ebfed44

Please sign in to comment.