]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
rgw.py: refactor configure
authorJoe Buck <jbbuck@gmail.com>
Thu, 1 Aug 2013 06:19:57 +0000 (23:19 -0700)
committerJoe Buck <jbbuck@gmail.com>
Tue, 13 Aug 2013 06:25:16 +0000 (23:25 -0700)
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 <jbbuck@gmail.com>
teuthology/task/rgw.py

index 63d05657625a6c155d6bcd52e97cf4aa0033c837..ff41f4244ac3fb6188fe141c7903d8e819c9af67 100644 (file)
@@ -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