]> git.proxmox.com Git - ceph.git/blob - ceph/qa/tasks/rgw_cloudtier.py
bump version to 18.2.4-pve3
[ceph.git] / ceph / qa / tasks / rgw_cloudtier.py
1 """
2 rgw_cloudtier configuration routines
3 """
4 import argparse
5 import logging
6
7 from teuthology import misc as teuthology
8 from teuthology.exceptions import ConfigError
9 from tasks.util.rgw import rgwadmin, wait_for_radosgw
10 from teuthology.task import Task
11
12 log = logging.getLogger(__name__)
13
14 class RGWCloudTier(Task):
15 """
16 Configure CloudTier storage class.
17
18 To configure cloudtiering on any client::
19
20 tasks:
21 - ceph:
22 - rgw:
23 - rgw-cloudtier:
24 client.0:
25 cloud_storage_class:
26 cloud_client:
27 cloud_regular_storage_class:
28 cloud_target_storage_class:
29 cloud_retain_head_object:
30 cloud_target_path:
31 cloudtier_user:
32 cloud_secret:
33 cloud_access_key:
34
35 """
36 def __init__(self, ctx, config):
37 super(RGWCloudTier, self).__init__(ctx, config)
38
39 def setup(self):
40 super(RGWCloudTier, self).setup()
41
42 overrides = self.ctx.config.get('overrides', {})
43 teuthology.deep_merge(self.config, overrides.get('rgw-cloudtier', {}))
44
45 if not self.ctx.rgw:
46 raise ConfigError('rgw-cloudtier must run after the rgw task')
47
48 self.ctx.rgw_cloudtier = argparse.Namespace()
49 self.ctx.rgw_cloudtier.config = self.config
50
51 log.info('Configuring rgw cloudtier ...')
52 clients = self.config.keys() # http://tracker.ceph.com/issues/20417
53 for client in clients:
54 client_config = self.config.get(client)
55 if client_config is None:
56 client_config = {}
57
58 if client_config is not None:
59 log.info('client %s - cloudtier config is -----------------%s ', client, client_config)
60 # configuring cloudtier
61
62 cloud_client = client_config.get('cloud_client')
63 cloud_storage_class = client_config.get('cloud_storage_class')
64 cloud_target_path = client_config.get('cloud_target_path')
65 cloud_target_storage_class = client_config.get('cloud_target_storage_class')
66 cloud_retain_head_object = client_config.get('cloud_retain_head_object')
67
68 cloudtier_user = client_config.get('cloudtier_user')
69 cloud_access_key = cloudtier_user.get('cloud_access_key')
70 cloud_secret = cloudtier_user.get('cloud_secret')
71
72 # XXX: the 'default' zone and zonegroup aren't created until we run RGWRados::init_complete().
73 # issue a 'radosgw-admin user list' command to trigger this
74 rgwadmin(self.ctx, client, cmd=['user', 'list'], check_status=True)
75
76 endpoint = self.ctx.rgw.role_endpoints[cloud_client]
77
78 # create cloudtier storage class
79 tier_config_params = "endpoint=" + endpoint.url() + \
80 ",access_key=" + cloud_access_key + \
81 ",secret=" + cloud_secret + \
82 ",retain_head_object=" + cloud_retain_head_object
83
84 if (cloud_target_path != None):
85 tier_config_params += ",target_path=" + cloud_target_path
86 if (cloud_target_storage_class != None):
87 tier_config_params += ",target_storage_class=" + cloud_target_storage_class
88
89 log.info('Configuring cloud-s3 tier storage class type = %s', cloud_storage_class)
90
91 rgwadmin(self.ctx, client,
92 cmd=['zonegroup', 'placement', 'add',
93 '--rgw-zone', 'default',
94 '--placement-id', 'default-placement',
95 '--storage-class', cloud_storage_class,
96 '--tier-type', 'cloud-s3',
97 '--tier-config', tier_config_params],
98 check_status=True)
99
100 ## create cloudtier user with the access keys given on the cloud client
101 cloud_tier_user_id = "cloud-tier-user-" + cloud_client
102 cloud_tier_user_name = "CLOUD TIER USER - " + cloud_client
103 rgwadmin(self.ctx, cloud_client,
104 cmd=['user', 'create', '--uid', cloud_tier_user_id,
105 '--display-name', cloud_tier_user_name,
106 '--access-key', cloud_access_key,
107 '--secret', cloud_secret,
108 '--caps', 'user-policy=*'],
109 check_status=True)
110
111 log.info('Finished Configuring rgw cloudtier ...')
112
113 cluster_name, daemon_type, client_id = teuthology.split_role(client)
114 client_with_id = daemon_type + '.' + client_id
115 self.ctx.daemons.get_daemon('rgw', client_with_id, cluster_name).restart()
116 log.info('restarted rgw daemon ...')
117
118 (remote,) = self.ctx.cluster.only(client).remotes.keys()
119 wait_for_radosgw(endpoint.url(), remote)
120
121
122 task = RGWCloudTier