summaryrefslogtreecommitdiffstats
path: root/qa/tasks/rgw_cloudtier.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:54:28 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:54:28 +0000
commite6918187568dbd01842d8d1d2c808ce16a894239 (patch)
tree64f88b554b444a49f656b6c656111a145cbbaa28 /qa/tasks/rgw_cloudtier.py
parentInitial commit. (diff)
downloadceph-e6918187568dbd01842d8d1d2c808ce16a894239.tar.xz
ceph-e6918187568dbd01842d8d1d2c808ce16a894239.zip
Adding upstream version 18.2.2.upstream/18.2.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'qa/tasks/rgw_cloudtier.py')
-rw-r--r--qa/tasks/rgw_cloudtier.py122
1 files changed, 122 insertions, 0 deletions
diff --git a/qa/tasks/rgw_cloudtier.py b/qa/tasks/rgw_cloudtier.py
new file mode 100644
index 000000000..88f7d0dc2
--- /dev/null
+++ b/qa/tasks/rgw_cloudtier.py
@@ -0,0 +1,122 @@
+"""
+rgw_cloudtier configuration routines
+"""
+import argparse
+import logging
+
+from teuthology import misc as teuthology
+from teuthology.exceptions import ConfigError
+from tasks.util.rgw import rgwadmin, wait_for_radosgw
+from teuthology.task import Task
+
+log = logging.getLogger(__name__)
+
+class RGWCloudTier(Task):
+ """
+ Configure CloudTier storage class.
+
+ To configure cloudtiering on any client::
+
+ tasks:
+ - ceph:
+ - rgw:
+ - rgw-cloudtier:
+ client.0:
+ cloud_storage_class:
+ cloud_client:
+ cloud_regular_storage_class:
+ cloud_target_storage_class:
+ cloud_retain_head_object:
+ cloud_target_path:
+ cloudtier_user:
+ cloud_secret:
+ cloud_access_key:
+
+ """
+ def __init__(self, ctx, config):
+ super(RGWCloudTier, self).__init__(ctx, config)
+
+ def setup(self):
+ super(RGWCloudTier, self).setup()
+
+ overrides = self.ctx.config.get('overrides', {})
+ teuthology.deep_merge(self.config, overrides.get('rgw-cloudtier', {}))
+
+ if not self.ctx.rgw:
+ raise ConfigError('rgw-cloudtier must run after the rgw task')
+
+ self.ctx.rgw_cloudtier = argparse.Namespace()
+ self.ctx.rgw_cloudtier.config = self.config
+
+ log.info('Configuring rgw cloudtier ...')
+ clients = self.config.keys() # http://tracker.ceph.com/issues/20417
+ for client in clients:
+ client_config = self.config.get(client)
+ if client_config is None:
+ client_config = {}
+
+ if client_config is not None:
+ log.info('client %s - cloudtier config is -----------------%s ', client, client_config)
+ # configuring cloudtier
+
+ cloud_client = client_config.get('cloud_client')
+ cloud_storage_class = client_config.get('cloud_storage_class')
+ cloud_target_path = client_config.get('cloud_target_path')
+ cloud_target_storage_class = client_config.get('cloud_target_storage_class')
+ cloud_retain_head_object = client_config.get('cloud_retain_head_object')
+
+ cloudtier_user = client_config.get('cloudtier_user')
+ cloud_access_key = cloudtier_user.get('cloud_access_key')
+ cloud_secret = cloudtier_user.get('cloud_secret')
+
+ # XXX: the 'default' zone and zonegroup aren't created until we run RGWRados::init_complete().
+ # issue a 'radosgw-admin user list' command to trigger this
+ rgwadmin(self.ctx, client, cmd=['user', 'list'], check_status=True)
+
+ endpoint = self.ctx.rgw.role_endpoints[cloud_client]
+
+ # create cloudtier storage class
+ tier_config_params = "endpoint=" + endpoint.url() + \
+ ",access_key=" + cloud_access_key + \
+ ",secret=" + cloud_secret + \
+ ",retain_head_object=" + cloud_retain_head_object
+
+ if (cloud_target_path != None):
+ tier_config_params += ",target_path=" + cloud_target_path
+ if (cloud_target_storage_class != None):
+ tier_config_params += ",target_storage_class=" + cloud_target_storage_class
+
+ log.info('Configuring cloud-s3 tier storage class type = %s', cloud_storage_class)
+
+ rgwadmin(self.ctx, client,
+ cmd=['zonegroup', 'placement', 'add',
+ '--rgw-zone', 'default',
+ '--placement-id', 'default-placement',
+ '--storage-class', cloud_storage_class,
+ '--tier-type', 'cloud-s3',
+ '--tier-config', tier_config_params],
+ check_status=True)
+
+ ## create cloudtier user with the access keys given on the cloud client
+ cloud_tier_user_id = "cloud-tier-user-" + cloud_client
+ cloud_tier_user_name = "CLOUD TIER USER - " + cloud_client
+ rgwadmin(self.ctx, cloud_client,
+ cmd=['user', 'create', '--uid', cloud_tier_user_id,
+ '--display-name', cloud_tier_user_name,
+ '--access-key', cloud_access_key,
+ '--secret', cloud_secret,
+ '--caps', 'user-policy=*'],
+ check_status=True)
+
+ log.info('Finished Configuring rgw cloudtier ...')
+
+ cluster_name, daemon_type, client_id = teuthology.split_role(client)
+ client_with_id = daemon_type + '.' + client_id
+ self.ctx.daemons.get_daemon('rgw', client_with_id, cluster_name).restart()
+ log.info('restarted rgw daemon ...')
+
+ (remote,) = self.ctx.cluster.only(client).remotes.keys()
+ wait_for_radosgw(endpoint.url(), remote)
+
+
+task = RGWCloudTier