# once the client is chosen, pull the host name and assigned port out of
# the role_endpoints that were assigned by the rgw task
- (remote_host, remote_port) = ctx.rgw.role_endpoints[client]
+ endpoint = ctx.rgw.role_endpoints[client]
##
user1='foo'
aws_access_key_id=access_key,
aws_secret_access_key=secret_key,
is_secure=False,
- port=remote_port,
- host=remote_host,
+ port=endpoint.port,
+ host=endpoint.hostname,
calling_format=boto.s3.connection.OrdinaryCallingFormat(),
)
connection2 = boto.s3.connection.S3Connection(
aws_access_key_id=access_key2,
aws_secret_access_key=secret_key2,
is_secure=False,
- port=remote_port,
- host=remote_host,
+ port=endpoint.port,
+ host=endpoint.hostname,
calling_format=boto.s3.connection.OrdinaryCallingFormat(),
)
client.1:
extra_args: ['--exclude', 'test_100_continue']
"""
+ assert hasattr(ctx, 'rgw'), 'ragweed must run after the rgw task'
assert config is None or isinstance(config, list) \
or isinstance(config, dict), \
"task ragweed only supports a list or dictionary for configuration"
ragweed_conf = {}
for client in clients:
+ endpoint = ctx.rgw.role_endpoints.get(client)
+ assert endpoint, 'ragweed: no rgw endpoint for {}'.format(client)
+
ragweed_conf[client] = ConfigObj(
indent_type='',
infile={
'rgw':
{
- 'port' : 7280,
+ 'port' : endpoint.port,
'is_secure' : 'no',
},
'fixtures' : {},
from teuthology import misc as teuthology
from teuthology import contextutil
from teuthology.orchestra.run import CommandFailedError
+from util import get_remote_for_role
from util.rgw import rgwadmin, wait_for_radosgw
from util.rados import (rados, create_ec_pool,
create_replicated_pool,
log = logging.getLogger(__name__)
+class RGWEndpoint:
+ def __init__(self, hostname=None, port=None):
+ self.hostname = hostname
+ self.port = port
+
+ def url(self):
+ return 'http://{hostname}:{port}/'.format(hostname=self.hostname, port=self.port)
+
@contextlib.contextmanager
def start_rgw(ctx, config, clients):
"""
log.info("Using %s as radosgw frontend", ctx.rgw.frontend)
- host, port = ctx.rgw.role_endpoints[client]
+ endpoint = ctx.rgw.role_endpoints[client]
frontends = \
'{frontend} port={port}'.format(frontend=ctx.rgw.frontend,
- port=port)
+ port=endpoint.port)
frontend_prefix = client_config.get('frontend_prefix', None)
if frontend_prefix:
frontends += ' prefix={pfx}'.format(pfx=frontend_prefix)
if keystone_role is not None:
if not ctx.keystone:
raise ConfigError('rgw must run after the keystone task')
- url = 'http://{host}:{port}/v1/KEY_$(tenant_id)s'.format(host=host,
- port=port)
+ url = 'http://{host}:{port}/v1/KEY_$(tenant_id)s'.format(host=endpoint.hostname,
+ port=endpoint.port)
ctx.keystone.create_endpoint(ctx, keystone_role, 'swift', url)
keystone_host, keystone_port = \
# XXX: add_daemon() doesn't let us wait until radosgw finishes startup
for client in config.keys():
- host, port = ctx.rgw.role_endpoints[client]
- endpoint = 'http://{host}:{port}/'.format(host=host, port=port)
- log.info('Polling {client} until it starts accepting connections on {endpoint}'.format(client=client, endpoint=endpoint))
- wait_for_radosgw(endpoint)
+ endpoint = ctx.rgw.role_endpoints[client]
+ url = endpoint.url()
+ log.info('Polling {client} until it starts accepting connections on {url}'.format(client=client, url=url))
+ wait_for_radosgw(url)
try:
yield
],
)
-def assign_ports(ctx, config):
+def assign_endpoints(ctx, config):
"""
- Assign port numberst starting with port 7280.
+ Assign port numbers starting with port 7280.
"""
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
+
+ for role, client_config in config.iteritems():
+ client_config = client_config or {}
+ remote = get_remote_for_role(ctx, role)
+ role_endpoints[role] = RGWEndpoint(remote.hostname, port)
+ port += 1
return role_endpoints
overrides = ctx.config.get('overrides', {})
teuthology.deep_merge(config, overrides.get('rgw', {}))
- role_endpoints = assign_ports(ctx, config)
ctx.rgw = argparse.Namespace()
- ctx.rgw.role_endpoints = role_endpoints
ctx.rgw.ec_data_pool = bool(config.pop('ec-data-pool', False))
ctx.rgw.erasure_code_profile = config.pop('erasure_code_profile', {})
log.debug("config is {}".format(config))
log.debug("client list is {}".format(clients))
+
+ ctx.rgw.role_endpoints = assign_endpoints(ctx, config)
+
subtasks = [
lambda: create_pools(ctx=ctx, clients=clients),
]
""" create cluster and gateway instances for all of the radosgw roles """
clusters = {}
gateways = {}
- for role, (host, port) in role_endpoints.iteritems():
+ for role, endpoint in role_endpoints.iteritems():
cluster_name, daemon_type, client_id = misc.split_role(role)
# find or create the cluster by name
cluster = clusters.get(cluster_name)
raise ConfigError('no daemon for role=%s cluster=%s type=rgw id=%s' % \
(role, cluster_name, client_id))
(remote,) = ctx.cluster.only(role).remotes.keys()
- gateways[role] = Gateway(role, remote, daemon, host, port, cluster)
+ gateways[role] = Gateway(role, remote, daemon, endpoint.hostname,
+ endpoint.port, cluster)
return clusters, gateways
def create_realm(cluster, config):
client.1:
extra_args: ['--exclude', 'test_100_continue']
"""
+ assert hasattr(ctx, 'rgw'), 's3tests must run after the rgw task'
assert config is None or isinstance(config, list) \
or isinstance(config, dict), \
"task s3tests only supports a list or dictionary for configuration"
s3tests_conf = {}
for client in clients:
+ endpoint = ctx.rgw.role_endpoints.get(client)
+ assert endpoint, 's3tests: no rgw endpoint for {}'.format(client)
+
s3tests_conf[client] = ConfigObj(
indent_type='',
infile={
'DEFAULT':
{
- 'port' : 7280,
+ 'port' : endpoint.port,
'is_secure' : 'no',
},
'fixtures' : {},
client.1:
extra_args: ['--exclude', 'TestFile']
"""
+ assert hasattr(ctx, 'rgw'), 'swift must run after the rgw task'
assert config is None or isinstance(config, list) \
or isinstance(config, dict), \
"task testswift only supports a list or dictionary for configuration"
testswift_conf = {}
for client in clients:
+ endpoint = ctx.rgw.role_endpoints.get(client)
+ assert endpoint, 'swift: no rgw endpoint for {}'.format(client)
+
testswift_conf[client] = ConfigObj(
indent_type='',
infile={
'func_test':
{
- 'auth_port' : 7280,
+ 'auth_port' : endpoint.port,
'auth_ssl' : 'no',
'auth_prefix' : '/auth/',
},