2 rgw_cloudtier configuration routines
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
12 log
= logging
.getLogger(__name__
)
14 class RGWCloudTier(Task
):
16 Configure CloudTier storage class.
18 To configure cloudtiering on any client::
27 cloud_regular_storage_class:
28 cloud_target_storage_class:
29 cloud_retain_head_object:
36 def __init__(self
, ctx
, config
):
37 super(RGWCloudTier
, self
).__init
__(ctx
, config
)
40 super(RGWCloudTier
, self
).setup()
42 overrides
= self
.ctx
.config
.get('overrides', {})
43 teuthology
.deep_merge(self
.config
, overrides
.get('rgw-cloudtier', {}))
46 raise ConfigError('rgw-cloudtier must run after the rgw task')
48 self
.ctx
.rgw_cloudtier
= argparse
.Namespace()
49 self
.ctx
.rgw_cloudtier
.config
= self
.config
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:
58 if client_config
is not None:
59 log
.info('client %s - cloudtier config is -----------------%s ', client
, client_config
)
60 # configuring cloudtier
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')
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')
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)
76 endpoint
= self
.ctx
.rgw
.role_endpoints
[cloud_client
]
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
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
89 log
.info('Configuring cloud-s3 tier storage class type = %s', cloud_storage_class
)
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
],
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=*'],
111 log
.info('Finished Configuring rgw cloudtier ...')
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 ...')
118 (remote
,) = self
.ctx
.cluster
.only(client
).remotes
.keys()
119 wait_for_radosgw(endpoint
.url(), remote
)