2013-08-17 17:14:37 +00:00
|
|
|
import argparse
|
2011-06-22 23:36:58 +00:00
|
|
|
import contextlib
|
2013-07-11 00:45:35 +00:00
|
|
|
import json
|
2011-06-22 23:36:58 +00:00
|
|
|
import logging
|
|
|
|
import os
|
|
|
|
|
2013-07-11 00:45:35 +00:00
|
|
|
from cStringIO import StringIO
|
|
|
|
|
2013-07-22 21:21:51 +00:00
|
|
|
from ..orchestra import run
|
2011-06-22 23:36:58 +00:00
|
|
|
from teuthology import misc as teuthology
|
|
|
|
from teuthology import contextutil
|
2013-07-19 22:16:16 +00:00
|
|
|
from teuthology.task_util.rgw import rgwadmin
|
2013-07-22 21:21:51 +00:00
|
|
|
from teuthology.task_util.rados import rados
|
2011-06-22 23:36:58 +00:00
|
|
|
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
@contextlib.contextmanager
|
|
|
|
def create_dirs(ctx, config):
|
|
|
|
log.info('Creating apache directories...')
|
2013-01-23 20:37:39 +00:00
|
|
|
testdir = teuthology.get_testdir(ctx)
|
2012-02-21 23:47:32 +00:00
|
|
|
for client in config.iterkeys():
|
2011-06-22 23:36:58 +00:00
|
|
|
ctx.cluster.only(client).run(
|
|
|
|
args=[
|
|
|
|
'mkdir',
|
|
|
|
'-p',
|
2013-07-22 17:38:28 +00:00
|
|
|
'{tdir}/apache/htdocs.{client}'.format(tdir=testdir,
|
|
|
|
client=client),
|
2013-07-31 19:47:48 +00:00
|
|
|
'{tdir}/apache/tmp.{client}/fastcgi_sock'.format(tdir=testdir,
|
|
|
|
client=client),
|
2011-06-22 23:36:58 +00:00
|
|
|
run.Raw('&&'),
|
|
|
|
'mkdir',
|
2013-07-22 17:38:28 +00:00
|
|
|
'{tdir}/archive/apache.{client}'.format(tdir=testdir,
|
|
|
|
client=client),
|
2011-06-22 23:36:58 +00:00
|
|
|
],
|
|
|
|
)
|
|
|
|
try:
|
|
|
|
yield
|
|
|
|
finally:
|
|
|
|
log.info('Cleaning up apache directories...')
|
2012-02-21 23:47:32 +00:00
|
|
|
for client in config.iterkeys():
|
2011-06-22 23:36:58 +00:00
|
|
|
ctx.cluster.only(client).run(
|
|
|
|
args=[
|
|
|
|
'rm',
|
|
|
|
'-rf',
|
2013-07-22 17:38:28 +00:00
|
|
|
'{tdir}/apache/tmp.{client}'.format(tdir=testdir,
|
|
|
|
client=client),
|
2011-06-22 23:36:58 +00:00
|
|
|
run.Raw('&&'),
|
|
|
|
'rmdir',
|
2013-07-22 17:38:28 +00:00
|
|
|
'{tdir}/apache/htdocs.{client}'.format(tdir=testdir,
|
|
|
|
client=client),
|
2011-06-22 23:36:58 +00:00
|
|
|
],
|
|
|
|
)
|
2013-07-24 19:24:33 +00:00
|
|
|
|
|
|
|
for client in config.iterkeys():
|
|
|
|
ctx.cluster.only(client).run(
|
|
|
|
args=[
|
|
|
|
'rmdir',
|
|
|
|
'{tdir}/apache'.format(tdir=testdir),
|
|
|
|
],
|
2013-08-02 00:08:01 +00:00
|
|
|
check_status=False, # only need to remove once per host
|
2013-07-24 19:24:33 +00:00
|
|
|
)
|
2011-06-22 23:36:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
@contextlib.contextmanager
|
2013-07-22 17:38:28 +00:00
|
|
|
def ship_config(ctx, config, role_endpoints):
|
2012-02-21 23:47:32 +00:00
|
|
|
assert isinstance(config, dict)
|
2013-07-22 17:38:28 +00:00
|
|
|
assert isinstance(role_endpoints, dict)
|
2013-01-23 20:37:39 +00:00
|
|
|
testdir = teuthology.get_testdir(ctx)
|
2011-06-22 23:36:58 +00:00
|
|
|
log.info('Shipping apache config and rgw.fcgi...')
|
2013-07-10 01:52:26 +00:00
|
|
|
src = os.path.join(os.path.dirname(__file__), 'apache.conf.template')
|
2012-02-21 23:47:32 +00:00
|
|
|
for client in config.iterkeys():
|
2011-06-22 23:36:58 +00:00
|
|
|
(remote,) = ctx.cluster.only(client).remotes.keys()
|
2013-07-10 01:52:26 +00:00
|
|
|
system_type = teuthology.get_system_type(remote)
|
|
|
|
if system_type == 'deb':
|
|
|
|
mod_path = '/usr/lib/apache2/modules'
|
2013-07-19 21:42:38 +00:00
|
|
|
print_continue = 'on'
|
2013-07-10 01:52:26 +00:00
|
|
|
else:
|
|
|
|
mod_path = '/usr/lib64/httpd/modules'
|
2013-07-19 21:42:38 +00:00
|
|
|
print_continue = 'off'
|
2013-07-22 17:38:28 +00:00
|
|
|
host, port = role_endpoints[client]
|
2011-06-22 23:36:58 +00:00
|
|
|
with file(src, 'rb') as f:
|
2013-07-10 01:52:26 +00:00
|
|
|
conf = f.read().format(
|
|
|
|
testdir=testdir,
|
|
|
|
mod_path=mod_path,
|
2013-07-19 21:42:38 +00:00
|
|
|
print_continue=print_continue,
|
2013-07-22 17:38:28 +00:00
|
|
|
host=host,
|
|
|
|
port=port,
|
|
|
|
client=client,
|
2013-07-10 01:52:26 +00:00
|
|
|
)
|
2011-06-22 23:36:58 +00:00
|
|
|
teuthology.write_file(
|
|
|
|
remote=remote,
|
2013-07-22 17:38:28 +00:00
|
|
|
path='{tdir}/apache/apache.{client}.conf'.format(tdir=testdir,
|
|
|
|
client=client),
|
2013-02-07 06:02:10 +00:00
|
|
|
data=conf,
|
2011-06-22 23:36:58 +00:00
|
|
|
)
|
|
|
|
teuthology.write_file(
|
|
|
|
remote=remote,
|
2013-07-22 17:38:28 +00:00
|
|
|
path='{tdir}/apache/htdocs.{client}/rgw.fcgi'.format(tdir=testdir,
|
|
|
|
client=client),
|
2011-06-22 23:36:58 +00:00
|
|
|
data="""#!/bin/sh
|
|
|
|
ulimit -c unlimited
|
2013-07-31 19:47:48 +00:00
|
|
|
exec radosgw -f -n {client} -k /etc/ceph/ceph.{client}.keyring --rgw-socket-path {tdir}/apache/tmp.{client}/fastcgi_sock/rgw_sock
|
2013-07-26 21:11:01 +00:00
|
|
|
|
2013-07-22 17:38:28 +00:00
|
|
|
""".format(tdir=testdir, client=client)
|
2011-06-22 23:36:58 +00:00
|
|
|
)
|
|
|
|
remote.run(
|
|
|
|
args=[
|
|
|
|
'chmod',
|
|
|
|
'a=rx',
|
2013-07-22 17:38:28 +00:00
|
|
|
'{tdir}/apache/htdocs.{client}/rgw.fcgi'.format(tdir=testdir,
|
|
|
|
client=client),
|
2011-06-22 23:36:58 +00:00
|
|
|
],
|
|
|
|
)
|
|
|
|
try:
|
|
|
|
yield
|
|
|
|
finally:
|
|
|
|
log.info('Removing apache config...')
|
2012-02-21 23:47:32 +00:00
|
|
|
for client in config.iterkeys():
|
2011-06-22 23:36:58 +00:00
|
|
|
ctx.cluster.only(client).run(
|
|
|
|
args=[
|
|
|
|
'rm',
|
|
|
|
'-f',
|
2013-07-22 17:38:28 +00:00
|
|
|
'{tdir}/apache/apache.{client}.conf'.format(tdir=testdir,
|
|
|
|
client=client),
|
2011-06-22 23:36:58 +00:00
|
|
|
run.Raw('&&'),
|
|
|
|
'rm',
|
|
|
|
'-f',
|
2013-07-22 17:38:28 +00:00
|
|
|
'{tdir}/apache/htdocs.{client}/rgw.fcgi'.format(tdir=testdir,
|
|
|
|
client=client),
|
2011-06-22 23:36:58 +00:00
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2011-09-03 00:58:19 +00:00
|
|
|
@contextlib.contextmanager
|
|
|
|
def start_rgw(ctx, config):
|
|
|
|
log.info('Starting rgw...')
|
2013-01-23 20:37:39 +00:00
|
|
|
testdir = teuthology.get_testdir(ctx)
|
2012-02-21 23:47:32 +00:00
|
|
|
for client in config.iterkeys():
|
2011-09-03 00:58:19 +00:00
|
|
|
(remote,) = ctx.cluster.only(client).remotes.iterkeys()
|
2012-02-22 00:08:21 +00:00
|
|
|
|
|
|
|
client_config = config.get(client)
|
|
|
|
if client_config is None:
|
|
|
|
client_config = {}
|
2012-02-24 20:04:58 +00:00
|
|
|
log.info("rgw %s config is %s", client, client_config)
|
2013-07-13 18:28:57 +00:00
|
|
|
id_ = client.split('.', 1)[1]
|
|
|
|
log.info('client {client} is id {id}'.format(client=client, id=id_))
|
2012-02-22 00:08:21 +00:00
|
|
|
run_cmd=[
|
2013-02-18 20:14:14 +00:00
|
|
|
'sudo',
|
2013-07-22 17:38:28 +00:00
|
|
|
'{tdir}/adjust-ulimits'.format(tdir=testdir),
|
|
|
|
'ceph-coverage',
|
|
|
|
'{tdir}/archive/coverage'.format(tdir=testdir),
|
|
|
|
'{tdir}/daemon-helper'.format(tdir=testdir),
|
|
|
|
'term',
|
2012-02-22 00:08:21 +00:00
|
|
|
]
|
|
|
|
run_cmd_tail=[
|
2013-07-22 17:38:28 +00:00
|
|
|
'radosgw',
|
|
|
|
'-n', client,
|
|
|
|
'-k', '/etc/ceph/ceph.{client}.keyring'.format(client=client),
|
2013-07-26 21:18:24 +00:00
|
|
|
'--rgw-socket-path',
|
2013-07-26 21:15:28 +00:00
|
|
|
'{tdir}/apache/tmp.{client}/fastcgi_sock/rgw_sock'.format(
|
|
|
|
tdir=testdir,
|
|
|
|
client=client,
|
|
|
|
),
|
2013-07-22 17:38:28 +00:00
|
|
|
'--log-file',
|
|
|
|
'/var/log/ceph/rgw.{client}.log'.format(client=client),
|
|
|
|
'--rgw_ops_log_socket_path',
|
|
|
|
'{tdir}/rgw.opslog.{client}.sock'.format(tdir=testdir,
|
|
|
|
client=client),
|
|
|
|
'{tdir}/apache/apache.{client}.conf'.format(tdir=testdir,
|
|
|
|
client=client),
|
|
|
|
'--foreground',
|
|
|
|
run.Raw('|'),
|
|
|
|
'sudo',
|
|
|
|
'tee',
|
|
|
|
'/var/log/ceph/rgw.{client}.stdout'.format(tdir=testdir,
|
|
|
|
client=client),
|
|
|
|
run.Raw('2>&1'),
|
2012-02-22 00:08:21 +00:00
|
|
|
]
|
2012-02-22 17:18:17 +00:00
|
|
|
|
2012-02-24 22:55:23 +00:00
|
|
|
run_cmd.extend(
|
|
|
|
teuthology.get_valgrind_args(
|
2013-02-04 04:08:40 +00:00
|
|
|
testdir,
|
2012-02-24 22:55:23 +00:00
|
|
|
client,
|
|
|
|
client_config.get('valgrind')
|
|
|
|
)
|
|
|
|
)
|
2012-02-22 00:08:21 +00:00
|
|
|
|
|
|
|
run_cmd.extend(run_cmd_tail)
|
|
|
|
|
2013-04-30 23:37:48 +00:00
|
|
|
ctx.daemons.add_daemon(
|
|
|
|
remote, 'rgw', client,
|
2012-02-22 00:08:21 +00:00
|
|
|
args=run_cmd,
|
2011-09-03 00:58:19 +00:00
|
|
|
logger=log.getChild(client),
|
|
|
|
stdin=run.PIPE,
|
|
|
|
wait=False,
|
|
|
|
)
|
|
|
|
|
|
|
|
try:
|
|
|
|
yield
|
|
|
|
finally:
|
2013-04-30 23:37:48 +00:00
|
|
|
teuthology.stop_daemons_of_type(ctx, 'rgw')
|
|
|
|
for client in config.iterkeys():
|
2012-11-20 00:19:06 +00:00
|
|
|
ctx.cluster.only(client).run(
|
|
|
|
args=[
|
|
|
|
'rm',
|
2013-04-30 23:37:48 +00:00
|
|
|
'-f',
|
2013-07-22 17:38:28 +00:00
|
|
|
'{tdir}/rgw.opslog.{client}.sock'.format(tdir=testdir,
|
|
|
|
client=client),
|
2013-04-30 23:37:48 +00:00
|
|
|
],
|
|
|
|
)
|
2011-09-03 00:58:19 +00:00
|
|
|
|
|
|
|
|
2011-06-22 23:36:58 +00:00
|
|
|
@contextlib.contextmanager
|
|
|
|
def start_apache(ctx, config):
|
|
|
|
log.info('Starting apache...')
|
2013-01-23 20:37:39 +00:00
|
|
|
testdir = teuthology.get_testdir(ctx)
|
2011-06-22 23:36:58 +00:00
|
|
|
apaches = {}
|
2012-02-21 23:47:32 +00:00
|
|
|
for client in config.iterkeys():
|
2011-06-22 23:36:58 +00:00
|
|
|
(remote,) = ctx.cluster.only(client).remotes.keys()
|
2013-07-10 01:52:26 +00:00
|
|
|
system_type = teuthology.get_system_type(remote)
|
|
|
|
if system_type == 'deb':
|
|
|
|
apache_name = 'apache2'
|
|
|
|
else:
|
|
|
|
apache_name = '/usr/sbin/httpd'
|
2011-06-22 23:36:58 +00:00
|
|
|
proc = remote.run(
|
|
|
|
args=[
|
2013-06-23 16:15:28 +00:00
|
|
|
'{tdir}/adjust-ulimits'.format(tdir=testdir),
|
2013-01-23 20:37:39 +00:00
|
|
|
'{tdir}/daemon-helper'.format(tdir=testdir),
|
2013-07-10 01:52:26 +00:00
|
|
|
'kill',
|
|
|
|
apache_name,
|
|
|
|
'-X',
|
|
|
|
'-f',
|
2013-07-22 17:38:28 +00:00
|
|
|
'{tdir}/apache/apache.{client}.conf'.format(tdir=testdir,
|
|
|
|
client=client),
|
2011-06-22 23:36:58 +00:00
|
|
|
],
|
|
|
|
logger=log.getChild(client),
|
|
|
|
stdin=run.PIPE,
|
|
|
|
wait=False,
|
|
|
|
)
|
|
|
|
apaches[client] = proc
|
|
|
|
|
|
|
|
try:
|
|
|
|
yield
|
|
|
|
finally:
|
|
|
|
log.info('Stopping apache...')
|
|
|
|
for client, proc in apaches.iteritems():
|
|
|
|
proc.stdin.close()
|
|
|
|
|
|
|
|
run.wait(apaches.itervalues())
|
|
|
|
|
2013-07-31 22:14:48 +00:00
|
|
|
def extract_user_info(client_config):
|
2013-08-02 03:54:38 +00:00
|
|
|
# test if there isn't a system user or if there isn't a name for that user, return None
|
|
|
|
if 'system user' not in client_config or 'name' not in client_config['system user']:
|
|
|
|
return None
|
|
|
|
|
2013-07-31 22:14:48 +00:00
|
|
|
user_info = dict()
|
|
|
|
user_info['system_key'] = dict(
|
|
|
|
user=client_config['system user']['name'],
|
|
|
|
access_key=client_config['system user']['access key'],
|
|
|
|
secret_key=client_config['system user']['secret key'],
|
|
|
|
)
|
|
|
|
return user_info
|
|
|
|
|
2013-07-22 17:38:28 +00:00
|
|
|
def extract_zone_info(ctx, client, client_config):
|
|
|
|
|
|
|
|
ceph_config = ctx.ceph.conf.get('global', {})
|
|
|
|
ceph_config.update(ctx.ceph.conf.get('client', {}))
|
|
|
|
ceph_config.update(ctx.ceph.conf.get(client, {}))
|
|
|
|
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']
|
2013-08-17 00:32:45 +00:00
|
|
|
zone_info = dict()
|
2013-08-01 06:19:57 +00:00
|
|
|
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',
|
2013-08-17 00:32:45 +00:00
|
|
|
'rgw user swift pool', 'rgw user uid pool', 'rgw domain root']:
|
2013-08-01 06:19:57 +00:00
|
|
|
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
|
2013-07-22 17:38:28 +00:00
|
|
|
|
2013-08-01 21:03:59 +00:00
|
|
|
# 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]
|
|
|
|
|
2013-08-01 21:03:59 +00:00
|
|
|
# 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]
|
|
|
|
|
2013-07-22 17:38:28 +00:00
|
|
|
return region, zone, zone_info
|
|
|
|
|
|
|
|
def extract_region_info(region, region_info):
|
|
|
|
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),
|
2013-08-01 21:03:59 +00:00
|
|
|
log_meta=region_info.get('log meta', False),
|
|
|
|
log_data=region_info.get('log data', False),
|
2013-07-22 17:38:28 +00:00
|
|
|
master_zone=region_info.get('master zone', region_info['zones'][0]),
|
|
|
|
placement_targets=region_info.get('placement targets', []),
|
|
|
|
default_placement=region_info.get('default placement', ''),
|
|
|
|
)
|
|
|
|
|
|
|
|
def assign_ports(ctx, config):
|
|
|
|
port = 7280
|
|
|
|
role_endpoints = {}
|
|
|
|
for remote, roles_for_host in ctx.cluster.remotes.iteritems():
|
|
|
|
for role in roles_for_host:
|
|
|
|
if role in config:
|
|
|
|
role_endpoints[role] = (remote.name.split('@')[1], port)
|
|
|
|
port += 1
|
|
|
|
|
|
|
|
return role_endpoints
|
|
|
|
|
|
|
|
def fill_in_endpoints(region_info, role_zones, role_endpoints):
|
|
|
|
for role, (host, port) in role_endpoints.iteritems():
|
2013-08-01 21:03:59 +00:00
|
|
|
region, zone, zone_info, _ = role_zones[role]
|
2013-07-22 17:38:28 +00:00
|
|
|
host, port = role_endpoints[role]
|
|
|
|
endpoint = 'http://{host}:{port}/'.format(host=host, port=port)
|
2013-08-09 04:03:27 +00:00
|
|
|
# check if the region specified under client actually exists
|
|
|
|
# in region_info (it should, if properly configured).
|
|
|
|
# If not, throw a reasonable error
|
|
|
|
if region not in region_info:
|
|
|
|
raise Exception('Region: {region} was specified but no corresponding' \
|
|
|
|
' entry was round under \'regions\''.format(region=region))
|
|
|
|
|
2013-07-22 17:38:28 +00:00
|
|
|
region_conf = region_info[region]
|
|
|
|
region_conf.setdefault('endpoints', [])
|
|
|
|
region_conf['endpoints'].append(endpoint)
|
2013-08-01 21:03:59 +00:00
|
|
|
|
|
|
|
# this is the payload for the 'zones' field in the region field
|
|
|
|
zone_payload = dict()
|
|
|
|
zone_payload['endpoints'] = [endpoint]
|
|
|
|
zone_payload['name'] = zone
|
|
|
|
|
|
|
|
# Pull the log meta and log data settings out of zone_info, if they exist, then pop them
|
|
|
|
# as they don't actually belong in the zone info
|
|
|
|
for key in ['rgw log meta', 'rgw log data']:
|
|
|
|
new_key = key.split(' ',1)[1]
|
|
|
|
new_key = new_key.replace(' ', '_')
|
|
|
|
|
|
|
|
if key in zone_info:
|
|
|
|
value = zone_info.pop(key)
|
|
|
|
else:
|
|
|
|
value = 'false'
|
|
|
|
|
|
|
|
zone_payload[new_key] = value
|
|
|
|
|
2013-07-22 17:38:28 +00:00
|
|
|
region_conf.setdefault('zones', [])
|
2013-08-01 21:03:59 +00:00
|
|
|
region_conf['zones'].append(zone_payload)
|
2013-07-13 18:28:57 +00:00
|
|
|
|
2013-07-31 22:14:48 +00:00
|
|
|
@contextlib.contextmanager
|
|
|
|
def configure_users(ctx, config):
|
|
|
|
log.info('Configuring users...')
|
|
|
|
|
|
|
|
# extract the user info and append it to the payload tuple for the given client
|
|
|
|
for client, c_config in config.iteritems():
|
2013-08-01 17:07:56 +00:00
|
|
|
if not c_config:
|
|
|
|
continue
|
2013-07-31 22:14:48 +00:00
|
|
|
user_info = extract_user_info(c_config)
|
2013-08-04 00:16:52 +00:00
|
|
|
|
|
|
|
# if user_info was successfully parsed, use it to create a user
|
|
|
|
if user_info is not None:
|
|
|
|
log.debug('Creating user {user} on {client}'.format(
|
|
|
|
user=user_info['system_key']['user'],client=client))
|
|
|
|
rgwadmin(ctx, client,
|
|
|
|
cmd=[
|
|
|
|
'-n', client,
|
|
|
|
'user', 'create',
|
|
|
|
'--uid', user_info['system_key']['user'],
|
|
|
|
'--access-key', user_info['system_key']['access_key'],
|
|
|
|
'--secret', user_info['system_key']['secret_key'],
|
|
|
|
'--display-name', user_info['system_key']['user'],
|
|
|
|
'--system',
|
|
|
|
],
|
|
|
|
check_status=True,
|
|
|
|
)
|
2013-07-31 22:14:48 +00:00
|
|
|
|
|
|
|
yield
|
|
|
|
|
2013-07-11 00:45:35 +00:00
|
|
|
@contextlib.contextmanager
|
2013-07-22 17:38:28 +00:00
|
|
|
def configure_regions_and_zones(ctx, config, regions, role_endpoints):
|
|
|
|
if not regions:
|
2013-08-01 06:19:57 +00:00
|
|
|
log.debug('In rgw.configure_regions_and_zones() and regions is None. Bailing')
|
2013-07-22 17:38:28 +00:00
|
|
|
yield
|
|
|
|
return
|
|
|
|
|
2013-07-11 00:45:35 +00:00
|
|
|
log.info('Configuring regions and zones...')
|
|
|
|
|
2013-07-22 17:38:28 +00:00
|
|
|
log.debug('config is %r', config)
|
|
|
|
log.debug('regions are %r', regions)
|
|
|
|
log.debug('role_endpoints = %r', role_endpoints)
|
2013-07-31 22:14:48 +00:00
|
|
|
# extract the zone info
|
2013-07-22 17:38:28 +00:00
|
|
|
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)
|
2013-07-31 22:14:48 +00:00
|
|
|
|
|
|
|
# extract the user info and append it to the payload tuple for the given client
|
|
|
|
for client, c_config in config.iteritems():
|
2013-08-02 03:54:38 +00:00
|
|
|
if not c_config:
|
|
|
|
user_info = None
|
|
|
|
else:
|
|
|
|
user_info = extract_user_info(c_config)
|
|
|
|
|
2013-07-31 22:14:48 +00:00
|
|
|
(region, zone, zone_info) = role_zones[client]
|
|
|
|
role_zones[client] = (region, zone, zone_info, user_info)
|
|
|
|
|
2013-07-22 17:38:28 +00:00
|
|
|
region_info = dict([(region, extract_region_info(region, r_config))
|
|
|
|
for region, r_config in regions.iteritems()])
|
2013-07-13 18:28:57 +00:00
|
|
|
|
2013-07-22 17:38:28 +00:00
|
|
|
fill_in_endpoints(region_info, role_zones, role_endpoints)
|
|
|
|
|
2013-08-01 06:19:57 +00:00
|
|
|
# clear out the old defaults
|
2013-07-22 17:38:28 +00:00
|
|
|
first_mon = teuthology.get_first_mon(ctx, config)
|
|
|
|
(mon,) = ctx.cluster.only(first_mon).remotes.iterkeys()
|
|
|
|
# removing these objects from .rgw.root and the per-zone root pools
|
|
|
|
# may or may not matter
|
|
|
|
rados(ctx, mon,
|
|
|
|
cmd=['-p', '.rgw.root', 'rm', 'region_info.default'])
|
|
|
|
rados(ctx, mon,
|
|
|
|
cmd=['-p', '.rgw.root', 'rm', 'zone_info.default'])
|
2013-07-11 00:45:35 +00:00
|
|
|
|
2013-07-22 17:38:28 +00:00
|
|
|
for client in config.iterkeys():
|
2013-07-31 22:14:48 +00:00
|
|
|
for role, (_, zone, zone_info, user_info) in role_zones.iteritems():
|
2013-07-22 17:38:28 +00:00
|
|
|
rados(ctx, mon,
|
|
|
|
cmd=['-p', zone_info['domain_root'],
|
|
|
|
'rm', 'region_info.default'])
|
|
|
|
rados(ctx, mon,
|
|
|
|
cmd=['-p', zone_info['domain_root'],
|
|
|
|
'rm', 'zone_info.default'])
|
2013-08-01 06:19:57 +00:00
|
|
|
rgwadmin(ctx, client,
|
|
|
|
cmd=['-n', client, 'zone', 'set', '--rgw-zone', zone],
|
|
|
|
stdin=StringIO(json.dumps(dict(zone_info.items() + user_info.items()))),
|
|
|
|
check_status=True)
|
|
|
|
|
|
|
|
for region, info in region_info.iteritems():
|
|
|
|
region_json = json.dumps(info)
|
|
|
|
log.debug('region info is: %s', region_json)
|
|
|
|
rgwadmin(ctx, client,
|
|
|
|
cmd=['-n', client, 'region', 'set'],
|
|
|
|
stdin=StringIO(region_json),
|
|
|
|
check_status=True)
|
|
|
|
if info['is_master']:
|
|
|
|
rgwadmin(ctx, client,
|
|
|
|
cmd=['-n', client,
|
|
|
|
'region', 'default',
|
|
|
|
'--rgw-region', region],
|
|
|
|
check_status=True)
|
|
|
|
|
|
|
|
rgwadmin(ctx, client, cmd=['-n', client, 'regionmap', 'update'])
|
2013-07-22 17:38:28 +00:00
|
|
|
yield
|
2011-06-22 23:36:58 +00:00
|
|
|
|
|
|
|
@contextlib.contextmanager
|
|
|
|
def task(ctx, config):
|
|
|
|
"""
|
|
|
|
Spin up apache configured to run a rados gateway.
|
|
|
|
Only one should be run per machine, since it uses a hard-coded port for now.
|
|
|
|
|
|
|
|
For example, to run rgw on all clients::
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
- ceph:
|
|
|
|
- rgw:
|
|
|
|
|
|
|
|
To only run on certain clients::
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
- ceph:
|
|
|
|
- rgw: [client.0, client.3]
|
2012-02-22 00:08:21 +00:00
|
|
|
|
|
|
|
or
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
- ceph:
|
|
|
|
- rgw:
|
|
|
|
client.0:
|
|
|
|
client.3:
|
|
|
|
|
|
|
|
To run radosgw through valgrind:
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
- ceph:
|
|
|
|
- rgw:
|
|
|
|
client.0:
|
|
|
|
valgrind: [--tool=memcheck]
|
|
|
|
client.3:
|
|
|
|
valgrind: [--tool=memcheck]
|
2012-02-24 20:04:58 +00:00
|
|
|
|
2013-07-19 21:42:38 +00:00
|
|
|
Note that without a modified fastcgi module e.g. with the default
|
|
|
|
one on CentOS, you must have rgw print continue = false in ceph.conf::
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
- ceph:
|
|
|
|
conf:
|
|
|
|
global:
|
|
|
|
rgw print continue: false
|
|
|
|
- rgw: [client.0]
|
2013-07-22 17:38:28 +00:00
|
|
|
|
|
|
|
To run rgws for multiple regions or zones, describe the regions
|
|
|
|
and their zones in a regions section. The endpoints will be
|
|
|
|
generated by this task. Each client must have a region, zone,
|
|
|
|
and pools assigned in ceph.conf::
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
- install:
|
|
|
|
- ceph:
|
|
|
|
conf:
|
|
|
|
client.0:
|
|
|
|
rgw region: foo
|
|
|
|
rgw zone: foo-1
|
2013-08-09 04:04:42 +00:00
|
|
|
rgw region root pool: .rgw.rroot.foo
|
|
|
|
rgw zone root pool: .rgw.zroot.foo
|
2013-08-02 02:11:28 +00:00
|
|
|
rgw log meta: true
|
|
|
|
rgw log data: true
|
2013-07-22 17:38:28 +00:00
|
|
|
client.1:
|
|
|
|
rgw region: bar
|
|
|
|
rgw zone: bar-master
|
2013-08-09 04:04:42 +00:00
|
|
|
rgw region root pool: .rgw.rroot.bar
|
|
|
|
rgw zone root pool: .rgw.zroot.bar
|
2013-08-02 02:11:28 +00:00
|
|
|
rgw log meta: true
|
|
|
|
rgw log data: true
|
2013-07-22 17:38:28 +00:00
|
|
|
client.2:
|
|
|
|
rgw region: bar
|
|
|
|
rgw zone: bar-secondary
|
2013-08-09 04:04:42 +00:00
|
|
|
rgw region root pool: .rgw.rroot.bar
|
|
|
|
rgw zone root pool: .rgw.zroot.bar-secondary
|
2013-07-22 17:38:28 +00:00
|
|
|
- rgw:
|
|
|
|
regions:
|
|
|
|
foo:
|
|
|
|
api name: api_name # default: region name
|
|
|
|
is master: true # default: false
|
|
|
|
master zone: foo-1 # default: first zone
|
|
|
|
zones: [foo-1]
|
2013-08-02 02:11:28 +00:00
|
|
|
log meta: true
|
|
|
|
log data: true
|
2013-07-22 17:38:28 +00:00
|
|
|
placement targets: [target1, target2] # default: []
|
|
|
|
default placement: target2 # default: ''
|
|
|
|
bar:
|
|
|
|
api name: bar-api
|
|
|
|
zones: [bar-master, bar-secondary]
|
|
|
|
client.0:
|
|
|
|
system user:
|
|
|
|
name: foo-system
|
|
|
|
access key: X2IYPSTY1072DDY1SJMC
|
|
|
|
secret key: YIMHICpPvT+MhLTbSsiBJ1jQF15IFvJA8tgwJEcm
|
|
|
|
client.1:
|
|
|
|
system user:
|
|
|
|
name: bar1
|
|
|
|
access key: Y2IYPSTY1072DDY1SJMC
|
|
|
|
secret key: XIMHICpPvT+MhLTbSsiBJ1jQF15IFvJA8tgwJEcm
|
|
|
|
client.2:
|
|
|
|
system user:
|
|
|
|
name: bar2
|
|
|
|
access key: Z2IYPSTY1072DDY1SJMC
|
|
|
|
secret key: ZIMHICpPvT+MhLTbSsiBJ1jQF15IFvJA8tgwJEcm
|
2011-06-22 23:36:58 +00:00
|
|
|
"""
|
|
|
|
if config is None:
|
2012-02-21 23:47:32 +00:00
|
|
|
config = dict(('client.{id}'.format(id=id_), None)
|
|
|
|
for id_ in teuthology.all_roles_of_type(ctx.cluster, 'client'))
|
|
|
|
elif isinstance(config, list):
|
|
|
|
config = dict((name, None) for name in config)
|
2011-06-22 23:36:58 +00:00
|
|
|
|
2013-07-22 17:38:28 +00:00
|
|
|
regions = {}
|
|
|
|
if 'regions' in config:
|
|
|
|
# separate region info so only clients are keys in config
|
|
|
|
regions = config['regions']
|
|
|
|
del config['regions']
|
2013-07-11 00:45:35 +00:00
|
|
|
|
2013-07-22 17:38:28 +00:00
|
|
|
role_endpoints = assign_ports(ctx, config)
|
2013-08-17 17:14:37 +00:00
|
|
|
ctx.rgw = argparse.Namespace()
|
|
|
|
ctx.rgw.role_endpoints = role_endpoints
|
2011-06-22 23:36:58 +00:00
|
|
|
|
|
|
|
with contextutil.nested(
|
|
|
|
lambda: create_dirs(ctx=ctx, config=config),
|
2013-07-22 17:38:28 +00:00
|
|
|
lambda: configure_regions_and_zones(
|
|
|
|
ctx=ctx,
|
|
|
|
config=config,
|
|
|
|
regions=regions,
|
|
|
|
role_endpoints=role_endpoints,
|
|
|
|
),
|
2013-07-31 22:14:48 +00:00
|
|
|
lambda: configure_users(
|
|
|
|
ctx=ctx,
|
|
|
|
config=config,
|
|
|
|
),
|
2013-07-22 17:38:28 +00:00
|
|
|
lambda: ship_config(ctx=ctx, config=config,
|
|
|
|
role_endpoints=role_endpoints),
|
2011-09-03 00:58:19 +00:00
|
|
|
lambda: start_rgw(ctx=ctx, config=config),
|
2011-06-22 23:36:58 +00:00
|
|
|
lambda: start_apache(ctx=ctx, config=config),
|
|
|
|
):
|
|
|
|
yield
|