From e3b9add3fb1a17426143e1ff8758a44952bf9196 Mon Sep 17 00:00:00 2001 From: Joe Buck Date: Wed, 31 Jul 2013 23:19:57 -0700 Subject: [PATCH] rgw.py: refactor configure Extend the rados pool configuration options to specify all pools (if desired). Also, reordered zone and region configuration so that they're configure (per client) in this order: zone, region, set default region Signed-off-by: Joe Buck --- teuthology/task/rgw.py | 69 ++++++++++++++++++++++-------------------- 1 file changed, 37 insertions(+), 32 deletions(-) diff --git a/teuthology/task/rgw.py b/teuthology/task/rgw.py index 63d05657625a6..ff41f4244ac3f 100644 --- a/teuthology/task/rgw.py +++ b/teuthology/task/rgw.py @@ -271,11 +271,21 @@ def extract_zone_info(ctx, client, client_config): client=client) region = ceph_config['rgw region'] zone = ceph_config['rgw zone'] - zone_info = {} - for key in ['control_pool', 'gc_pool', 'log_pool', 'intent_log_pool', - 'usage_log_pool', 'user_keys_pool', 'user_email_pool', - 'user_swift_pool', 'user_uid_pool', 'domain_root']: - zone_info[key] = '.' + region + '.' + zone + '.' + key + zone_info = dict( + domain_root=ceph_config['rgw zone root pool'], + ) + for key in ['rgw control pool', 'rgw gc pool', 'rgw log pool', 'rgw intent log pool', + 'rgw usage log pool', 'rgw user keys pool', 'rgw user email pool', + 'rgw user swift pool', 'rgw user uid pool']: + new_key = key.split(' ',1)[1] + new_key = new_key.replace(' ', '_') + + if key in ceph_config: + value = ceph_config[key] + log.debug('{key} specified in ceph_config ({val})'.format(key=key, val=value)) + zone_info[new_key] = value + else: + zone_info[new_key] = '.' + region + '.' + zone + '.' + new_key # these keys are meant for the zones argument in the region info. # We insert them into zone_info with a different format and then remove them @@ -380,6 +390,7 @@ def configure_users(ctx, config): @contextlib.contextmanager def configure_regions_and_zones(ctx, config, regions, role_endpoints): if not regions: + log.debug('In rgw.configure_regions_and_zones() and regions is None. Bailing') yield return @@ -407,33 +418,8 @@ def configure_regions_and_zones(ctx, config, regions, role_endpoints): for region, r_config in regions.iteritems()]) fill_in_endpoints(region_info, role_zones, role_endpoints) - for client in config.iterkeys(): - for region, info in region_info.iteritems(): - region_json = json.dumps(info) - log.debug('region info is: %s', region_json) - rgwadmin(ctx, client, - cmd=['-n', client, 'region', 'set'], - stdin=StringIO(region_json), - check_status=True) - if info['is_master']: - rgwadmin(ctx, client, - cmd=['-n', client, - 'region', 'default', - '--rgw-region', region], - check_status=True) - for role, (_, zone, zone_info, user_info) in role_zones.iteritems(): - - # add the user_info (if it exists) to the zone_info - if user_info: - new_dict = dict(zone_info.items() + user_info.items()) - else: - new_dict = zone_info - - rgwadmin(ctx, client, - cmd=['-n', client, 'zone', 'set', '--rgw-zone', zone], - stdin=StringIO(json.dumps(new_dict)), - check_status=True) + # clear out the old defaults first_mon = teuthology.get_first_mon(ctx, config) (mon,) = ctx.cluster.only(first_mon).remotes.iterkeys() # removing these objects from .rgw.root and the per-zone root pools @@ -444,7 +430,6 @@ def configure_regions_and_zones(ctx, config, regions, role_endpoints): cmd=['-p', '.rgw.root', 'rm', 'zone_info.default']) for client in config.iterkeys(): - rgwadmin(ctx, client, cmd=['-n', client, 'regionmap', 'update']) for role, (_, zone, zone_info, user_info) in role_zones.iteritems(): rados(ctx, mon, cmd=['-p', zone_info['domain_root'], @@ -452,6 +437,26 @@ def configure_regions_and_zones(ctx, config, regions, role_endpoints): rados(ctx, mon, cmd=['-p', zone_info['domain_root'], 'rm', 'zone_info.default']) + rgwadmin(ctx, client, + cmd=['-n', client, 'zone', 'set', '--rgw-zone', zone], + stdin=StringIO(json.dumps(dict(zone_info.items() + user_info.items()))), + check_status=True) + + for region, info in region_info.iteritems(): + region_json = json.dumps(info) + log.debug('region info is: %s', region_json) + rgwadmin(ctx, client, + cmd=['-n', client, 'region', 'set'], + stdin=StringIO(region_json), + check_status=True) + if info['is_master']: + rgwadmin(ctx, client, + cmd=['-n', client, + 'region', 'default', + '--rgw-region', region], + check_status=True) + + rgwadmin(ctx, client, cmd=['-n', client, 'regionmap', 'update']) yield @contextlib.contextmanager -- 2.39.5