From a1395ec67241cd3b6c21ae09d7c110c49d80453e Mon Sep 17 00:00:00 2001 From: Mehdi Abaakouk Date: Wed, 23 Jan 2013 09:58:28 +0000 Subject: [PATCH] Allow change the endpoint_type when use swift-dispersion tools Fixes bug 1102319 DocImpact Change-Id: I8fb0417ab9468e97ed01a6cb1e262630905e7f29 --- bin/swift-dispersion-populate | 9 +++++++-- bin/swift-dispersion-report | 8 ++++++-- doc/manpages/swift-dispersion-populate.1 | 1 + doc/manpages/swift-dispersion-report.1 | 1 + doc/source/admin_guide.rst | 1 + etc/dispersion.conf-sample | 1 + 6 files changed, 17 insertions(+), 4 deletions(-) diff --git a/bin/swift-dispersion-populate b/bin/swift-dispersion-populate index 1fe01adc0b..0e3142956f 100755 --- a/bin/swift-dispersion-populate +++ b/bin/swift-dispersion-populate @@ -91,19 +91,24 @@ if __name__ == '__main__': dispersion_coverage = int(conf.get('dispersion_coverage', 1)) retries = int(conf.get('retries', 5)) concurrency = int(conf.get('concurrency', 25)) + endpoint_type = str(conf.get('endpoint_type', 'publicURL')) coropool = GreenPool(size=concurrency) retries_done = 0 + os_options = {'endpoint_type': endpoint_type} + url, token = get_auth(conf['auth_url'], conf['auth_user'], conf['auth_key'], - auth_version=conf.get('auth_version', '1.0')) + auth_version=conf.get('auth_version', '1.0'), + os_options=os_options) account = url.rsplit('/', 1)[1] connpool = Pool(max_size=concurrency) connpool.create = lambda: Connection(conf['auth_url'], conf['auth_user'], conf['auth_key'], retries=retries, - preauthurl=url, preauthtoken=token) + preauthurl=url, preauthtoken=token, + os_options=os_options) container_ring = Ring(swift_dir, ring_name='container') parts_left = dict((x, x) for x in xrange(container_ring.partition_count)) diff --git a/bin/swift-dispersion-report b/bin/swift-dispersion-report index 590dede13c..08af4a7b24 100755 --- a/bin/swift-dispersion-report +++ b/bin/swift-dispersion-report @@ -324,6 +324,7 @@ Usage: %%prog [options] [conf_file] dispersion_coverage = int(conf.get('dispersion_coverage', 1)) retries = int(conf.get('retries', 5)) concurrency = int(conf.get('concurrency', 25)) + endpoint_type = str(conf.get('endpoint_type', 'publicURL')) if options.dump_json or config_true_value(conf.get('dump_json', 'no')): json_output = True container_report = config_true_value(conf.get('container_report', 'yes')) \ @@ -337,14 +338,17 @@ Usage: %%prog [options] [conf_file] coropool = GreenPool(size=concurrency) + os_options = {'endpoint_type': endpoint_type} + url, token = get_auth(conf['auth_url'], conf['auth_user'], conf['auth_key'], - auth_version=conf.get('auth_version', '1.0')) + auth_version=conf.get('auth_version', '1.0'), + os_options=os_options) account = url.rsplit('/', 1)[1] connpool = Pool(max_size=concurrency) connpool.create = lambda: Connection( conf['auth_url'], conf['auth_user'], conf['auth_key'], retries=retries, - preauthurl=url, preauthtoken=token) + preauthurl=url, preauthtoken=token, os_options=os_options) container_ring = Ring(swift_dir, ring_name='container') object_ring = Ring(swift_dir, ring_name='object') diff --git a/doc/manpages/swift-dispersion-populate.1 b/doc/manpages/swift-dispersion-populate.1 index 27188cef1b..e9cb0b2ad0 100644 --- a/doc/manpages/swift-dispersion-populate.1 +++ b/doc/manpages/swift-dispersion-populate.1 @@ -69,6 +69,7 @@ Example \fI/etc/swift/dispersion.conf\fR: .IP "# dispersion_coverage = 1" .IP "# retries = 5" .IP "# concurrency = 25" +.IP "# endpoint_type = publicURL" .RE .PD .SH EXAMPLE diff --git a/doc/manpages/swift-dispersion-report.1 b/doc/manpages/swift-dispersion-report.1 index 2b0ffcd796..d642512715 100644 --- a/doc/manpages/swift-dispersion-report.1 +++ b/doc/manpages/swift-dispersion-report.1 @@ -98,6 +98,7 @@ Example \fI/etc/swift/dispersion.conf\fR: .IP "# retries = 5" .IP "# concurrency = 25" .IP "# dump_json = no" +.IP "# endpoint_type = publicURL" .RE .PD .SH EXAMPLE diff --git a/doc/source/admin_guide.rst b/doc/source/admin_guide.rst index bb080a136e..9f6b04539e 100644 --- a/doc/source/admin_guide.rst +++ b/doc/source/admin_guide.rst @@ -208,6 +208,7 @@ configuration file, /etc/swift/dispersion.conf. Example conf file:: auth_url = http://localhost:8080/auth/v1.0 auth_user = test:tester auth_key = testing + endpoint_type = internalURL There are also options for the conf file for specifying the dispersion coverage (defaults to 1%), retries, concurrency, etc. though usually the defaults are diff --git a/etc/dispersion.conf-sample b/etc/dispersion.conf-sample index d42cf35434..fb62b866ba 100644 --- a/etc/dispersion.conf-sample +++ b/etc/dispersion.conf-sample @@ -6,6 +6,7 @@ auth_key = testing # auth_user = test:tester # auth_key = testing # auth_version = 2.0 +# endpoint_type = publicURL # # swift_dir = /etc/swift # dispersion_coverage = 1