MCPcopy Create free account
hub / github.com/ceph/ceph / create_users

Method create_users

qa/tasks/s3tests_java.py:162–216  ·  view source on GitHub ↗

Create a main and an alternative s3 user. Configuration is read from a skelethon config file s3tests.teuth.config.yaml in the java-s3tests repository and missing information is added from the task. Existing values are NOT overridden unless they are empty!

(self)

Source from the content-addressed store, hash-verified

160 )
161
162 def create_users(self):
163 """
164 Create a main and an alternative s3 user.
165 Configuration is read from a skelethon config file
166 s3tests.teuth.config.yaml in the java-s3tests repository
167 and missing information is added from the task.
168 Existing values are NOT overridden unless they are empty!
169 """
170 log.info("S3 Tests Java: Creating S3 users...")
171 testdir = teuthology.get_testdir(self.ctx)
172 for client in self.all_clients:
173 endpoint = self.ctx.rgw.role_endpoints.get(client)
174 local_user = getpass.getuser()
175 remote_user = teuthology.get_test_user()
176 os.system("scp {remote}@{host}:{tdir}/s3-tests-java/s3tests.teuth.config.yaml /home/{local}/".format(
177 host=endpoint.hostname, tdir=testdir, remote=remote_user, local=local_user))
178 s3tests_conf = teuthology.config_file(
179 '/home/{local}/s3tests.teuth.config.yaml'.format(local=local_user))
180 log.debug("S3 Tests Java: s3tests_conf is {s3cfg}".format(
181 s3cfg=s3tests_conf))
182 for section, user in list(self.users.items()):
183 if section in s3tests_conf:
184 s3_user_id = '{user}.{client}'.format(
185 user=user, client=client)
186 log.debug(
187 'S3 Tests Java: Creating user {s3_user_id}'.format(s3_user_id=s3_user_id))
188 self._config_user(s3tests_conf=s3tests_conf,
189 section=section, user=s3_user_id, client=client)
190 cluster_name, daemon_type, client_id = teuthology.split_role(
191 client)
192 client_with_id = daemon_type + '.' + client_id
193 args = [
194 'adjust-ulimits',
195 'ceph-coverage',
196 '{tdir}/archive/coverage'.format(tdir=testdir),
197 'radosgw-admin',
198 '-n', client_with_id,
199 'user', 'create',
200 '--uid', s3tests_conf[section]['user_id'],
201 '--display-name', s3tests_conf[section]['display_name'],
202 '--access-key', s3tests_conf[section]['access_key'],
203 '--secret', s3tests_conf[section]['access_secret'],
204 '--email', s3tests_conf[section]['email'],
205 '--cluster', cluster_name,
206 ]
207 log.info('{args}'.format(args=args))
208 self.ctx.cluster.only(client).run(
209 args=args,
210 stdout=BytesIO()
211 )
212 else:
213 self.users.pop(section)
214 self._write_cfg_file(s3tests_conf, client)
215 os.system(
216 "rm -rf /home/{local}/s3tests.teuth.config.yaml".format(local=local_user))
217
218 def _config_user(self, s3tests_conf, section, user, client):
219 """

Callers 2

beginMethod · 0.95
create_usersFunction · 0.80

Calls 11

_config_userMethod · 0.95
_write_cfg_fileMethod · 0.95
onlyMethod · 0.80
listFunction · 0.50
infoMethod · 0.45
getMethod · 0.45
formatMethod · 0.45
debugMethod · 0.45
itemsMethod · 0.45
runMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected