]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw multisite: use get_config_master_client for radosgw_admin task 12535/head
authorAli Maredia <amaredia@redhat.com>
Tue, 20 Dec 2016 18:09:12 +0000 (13:09 -0500)
committerAli Maredia <amaredia@redhat.com>
Thu, 13 Apr 2017 16:15:50 +0000 (12:15 -0400)
Signed-off-by: Ali Maredia <amaredia@redhat.com>
qa/suites/rgw/singleton/all/radosgw-admin-data-sync.yaml
qa/suites/rgw/singleton/all/radosgw-admin-multi-region.yaml
qa/suites/rgw/singleton/all/radosgw-admin.yaml
qa/tasks/radosgw_admin.py
qa/tasks/rgw.py
qa/tasks/util/rgw.py

index ffd59f608bad21c424634956634c88d7c63bbf07..03d7c612c4a37c77157ed4e281eeaf332576093f 100644 (file)
@@ -63,4 +63,3 @@ tasks:
 - sleep:
     duration: 30
 - radosgw-admin:
-    master_client: client.0
index 9000e0929bd5c7835db26194a91c99fbc5cae2d6..d28dec9e7a12c9542aadc8c4ee8b331037ab126b 100644 (file)
@@ -65,4 +65,3 @@ tasks:
       dest: client.1
       metadata-only: true
 - radosgw-admin:
-    master_client: client.0
index 83b35a9af43cddfb8d7baa4201044616291eaf33..aada29b5b33466bd6fedcc1f376c032694274199 100644 (file)
@@ -18,4 +18,3 @@ tasks:
 - rgw:
     client.0:
 - radosgw-admin:
-    master_client: client.0
index 609dfe1c06d10f11b8b77f1f58baa862e5480ccf..a08a5ddd44dcb4b9d81a4a57a6790231f9837258 100644 (file)
@@ -68,18 +68,25 @@ def task(ctx, config):
     """
     global log
 
-    assert isinstance(config, dict), \
-        "task radosgw-admin only supports a dictionary with a master_client for configuration"
-
-    # regions found just like in the rgw task
+    # regions and config found from rgw task
+    assert ctx.rgw.regions
+        "tasks radosgw_admin needs region(s) declared from the rgw task"
     regions = ctx.rgw.regions
-
     log.debug('regions are: %r', regions)
+
+    assert ctx.rgw.config
+        "tasks radosgw_admin needs a config passed from the rgw task"
+    config = ctx.rgw.config
     log.debug('config is: %r', config)
 
-    client = config["master_client"]
+    clients_from_config = config.keys()
+
+    # choose first client as default
+    client = clients_from_config[0]
 
     multi_region_run = rgw_utils.multi_region_enabled(ctx)
+    if multi_region_run:
+        client = rgw_utils.get_config_master_client(ctx, config, regions)
 
     log.debug('multi_region_run is: %r', multi_region_run)
     log.debug('master_client is: %r', client)
index 80b25248666431d713daf0e61eed7f55813f2b28..6e73a182b9617ed8de409c2234fe24aceb89e02c 100644 (file)
@@ -18,36 +18,13 @@ from teuthology.orchestra import run
 from teuthology import misc as teuthology
 from teuthology import contextutil
 from teuthology.orchestra.run import CommandFailedError
-from util.rgw import rgwadmin
+from util.rgw import rgwadmin, get_config_master_client, extract_zone_info, extract_region_info
 from util.rados import (rados, create_ec_pool,
                                         create_replicated_pool,
                                         create_cache_pool)
 
 log = logging.getLogger(__name__)
 
-def get_config_master_client(ctx, config, regions):
-
-    role_zones = dict([(client, extract_zone_info(ctx, client, c_config))
-                       for client, c_config in config.iteritems()])
-    log.debug('roles_zones = %r', role_zones)
-    region_info = dict([
-        (region_name, extract_region_info(region_name, r_config))
-        for region_name, r_config in regions.iteritems()])
-
-     # read master zonegroup and master_zone
-    for zonegroup, zg_info in region_info.iteritems():
-        if zg_info['is_master']:
-            master_zonegroup = zonegroup
-            master_zone = zg_info['master_zone']
-            break
-
-    for client in config.iterkeys():
-        (zonegroup, zone, zone_info) = role_zones[client]
-        if zonegroup == master_zonegroup and zone == master_zone:
-            return client
-
-    return None
-
 @contextlib.contextmanager
 def create_apache_dirs(ctx, config, on_client = None, except_client = None):
     """
@@ -471,97 +448,6 @@ def extract_user_info(client_config):
     return user_info
 
 
-def extract_zone_info(ctx, client, client_config):
-    """
-    Get zone information.
-    :param client: dictionary of client information
-    :param client_config: dictionary of client configuration information
-    :returns: zone extracted from client and client_config information
-    """
-    cluster_name, daemon_type, client_id = teuthology.split_role(client)
-    client_with_id = daemon_type + '.' + client_id
-    ceph_config = ctx.ceph[cluster_name].conf.get('global', {})
-    ceph_config.update(ctx.ceph[cluster_name].conf.get('client', {}))
-    ceph_config.update(ctx.ceph[cluster_name].conf.get(client_with_id, {}))
-    for key in ['rgw zone', 'rgw region', 'rgw zone root pool']:
-        assert key in ceph_config, \
-            'ceph conf must contain {key} for {client}'.format(key=key,
-                                                               client=client)
-    region = ceph_config['rgw region']
-    zone = ceph_config['rgw zone']
-    zone_info = dict()
-    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',
-                'rgw domain root']:
-        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
-
-    index_pool = '.' + region + '.' + zone + '.' + 'index_pool'
-    data_pool = '.' + region + '.' + zone + '.' + 'data_pool'
-    data_extra_pool = '.' + region + '.' + zone + '.' + 'data_extra_pool'
-    compression_type = ceph_config.get('rgw compression type', '')
-
-    zone_info['placement_pools'] = [{'key': 'default_placement',
-                                     'val': {'index_pool': index_pool,
-                                             'data_pool': data_pool,
-                                             'data_extra_pool': data_extra_pool,
-                                             'compression': compression_type}
-                                     }]
-
-    # 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
-    # in the fill_in_endpoints() method
-    for key in ['rgw log meta', 'rgw log data']:
-        if key in ceph_config:
-            zone_info[key] = ceph_config[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
-    # in the fill_in_endpoints() method
-    for key in ['rgw log meta', 'rgw log data']:
-        if key in ceph_config:
-            zone_info[key] = ceph_config[key]
-
-    return region, zone, zone_info
-
-
-def extract_region_info(region, region_info):
-    """
-    Extract region information from the region_info parameter, using get
-    to set default values.
-
-    :param region: name of the region
-    :param region_info: region information (in dictionary form).
-    :returns: dictionary of region information set from region_info, using
-            default values for missing fields.
-    """
-    assert isinstance(region_info['zones'], list) and region_info['zones'], \
-        'zones must be a non-empty list'
-    return dict(
-        name=region,
-        api_name=region_info.get('api name', region),
-        is_master=region_info.get('is master', False),
-        log_meta=region_info.get('log meta', False),
-        log_data=region_info.get('log data', False),
-        master_zone=region_info.get('master zone', region_info['zones'][0]),
-        placement_targets=region_info.get('placement targets',
-                                          [{'name': 'default_placement',
-                                            'tags': []}]),
-        default_placement=region_info.get('default placement',
-                                          'default_placement'),
-        )
-
-
 def assign_ports(ctx, config):
     """
     Assign port numberst starting with port 7280.
index 02215b0ed48b256730bbdbd6303516025ea5d6e3..0cdb769b0aa2cda8e74862a511720c5cf180f9e6 100644 (file)
@@ -189,3 +189,116 @@ def get_sync_agent(ctx, source):
             if conf['src'] == source:
                 return host_for_role(ctx, source), conf.get('port', 8000)
     return None, None
+
+def extract_zone_info(ctx, client, client_config):
+    """
+    Get zone information.
+    :param client: dictionary of client information
+    :param client_config: dictionary of client configuration information
+    :returns: zone extracted from client and client_config information
+    """
+    cluster_name, daemon_type, client_id = teuthology.split_role(client)
+    client_with_id = daemon_type + '.' + client_id
+    ceph_config = ctx.ceph[cluster_name].conf.get('global', {})
+    ceph_config.update(ctx.ceph[cluster_name].conf.get('client', {}))
+    ceph_config.update(ctx.ceph[cluster_name].conf.get(client_with_id, {}))
+    for key in ['rgw zone', 'rgw region', 'rgw zone root pool']:
+        assert key in ceph_config, \
+            'ceph conf must contain {key} for {client}'.format(key=key,
+                                                               client=client)
+    region = ceph_config['rgw region']
+    zone = ceph_config['rgw zone']
+    zone_info = dict()
+    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',
+                'rgw domain root']:
+        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
+
+    index_pool = '.' + region + '.' + zone + '.' + 'index_pool'
+    data_pool = '.' + region + '.' + zone + '.' + 'data_pool'
+    data_extra_pool = '.' + region + '.' + zone + '.' + 'data_extra_pool'
+    compression_type = ceph_config.get('rgw compression type', '')
+
+    zone_info['placement_pools'] = [{'key': 'default_placement',
+                                     'val': {'index_pool': index_pool,
+                                             'data_pool': data_pool,
+                                             'data_extra_pool': data_extra_pool,
+                                             'compression': compression_type}
+                                     }]
+
+    # 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
+    # in the fill_in_endpoints() method
+    for key in ['rgw log meta', 'rgw log data']:
+        if key in ceph_config:
+            zone_info[key] = ceph_config[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
+    # in the fill_in_endpoints() method
+    for key in ['rgw log meta', 'rgw log data']:
+        if key in ceph_config:
+            zone_info[key] = ceph_config[key]
+
+    return region, zone, zone_info
+
+def extract_region_info(region, region_info):
+    """
+    Extract region information from the region_info parameter, using get
+    to set default values.
+
+    :param region: name of the region
+    :param region_info: region information (in dictionary form).
+    :returns: dictionary of region information set from region_info, using
+            default values for missing fields.
+    """
+    assert isinstance(region_info['zones'], list) and region_info['zones'], \
+        'zones must be a non-empty list'
+    return dict(
+        name=region,
+        api_name=region_info.get('api name', region),
+        is_master=region_info.get('is master', False),
+        log_meta=region_info.get('log meta', False),
+        log_data=region_info.get('log data', False),
+        master_zone=region_info.get('master zone', region_info['zones'][0]),
+        placement_targets=region_info.get('placement targets',
+                                          [{'name': 'default_placement',
+                                            'tags': []}]),
+        default_placement=region_info.get('default placement',
+                                          'default_placement'),
+        )
+
+def get_config_master_client(ctx, config, regions):
+
+    role_zones = dict([(client, extract_zone_info(ctx, client, c_config))
+                       for client, c_config in config.iteritems()])
+    log.debug('roles_zones = %r', role_zones)
+    region_info = dict([
+        (region_name, extract_region_info(region_name, r_config))
+        for region_name, r_config in regions.iteritems()])
+
+     # read master zonegroup and master_zone
+    for zonegroup, zg_info in region_info.iteritems():
+        if zg_info['is_master']:
+            master_zonegroup = zonegroup
+            master_zone = zg_info['master_zone']
+            break
+
+    for client in config.iterkeys():
+        (zonegroup, zone, zone_info) = role_zones[client]
+        if zonegroup == master_zonegroup and zone == master_zone:
+            return client
+
+    return None
+