~ubuntu-branches/ubuntu/trusty/swift/trusty-updates

« back to all changes in this revision

Viewing changes to bin/swift-dispersion-report

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2013-01-28 09:40:30 UTC
  • mfrom: (1.2.16)
  • Revision ID: package-import@ubuntu.com-20130128094030-aetz57x2qz9ye2d4
Tags: 1.7.6-0ubuntu1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
295
295
    patcher.monkey_patch()
296
296
    hubs.get_hub().debug_exceptions = False
297
297
 
 
298
    conffile = '/etc/swift/dispersion.conf'
 
299
 
298
300
    parser = OptionParser(usage='''
299
 
Usage: %prog [options] [conf_file]
 
301
Usage: %%prog [options] [conf_file]
300
302
 
301
 
[conf_file] defaults to /etc/swift/stats.conf'''.strip())
 
303
[conf_file] defaults to %s'''.strip() % conffile)
302
304
    parser.add_option('-j', '--dump-json', action='store_true', default=False,
303
305
                      help='dump dispersion report in json format')
304
306
    parser.add_option('-d', '--debug', action='store_true', default=False,
305
307
                      help='print 404s to standard error')
306
308
    parser.add_option('-p', '--partitions', action='store_true', default=False,
307
309
                      help='print missing partitions to standard error')
308
 
 
 
310
    parser.add_option('--container-only', action='store_true', default=False,
 
311
                      help='Only run container report')
 
312
    parser.add_option('--object-only', action='store_true', default=False,
 
313
                      help='Only run object report')
309
314
    options, args = parser.parse_args()
310
315
 
311
 
    conffile = '/etc/swift/dispersion.conf'
312
316
    if args:
313
317
        conffile = args.pop(0)
314
318
 
322
326
    concurrency = int(conf.get('concurrency', 25))
323
327
    if options.dump_json or config_true_value(conf.get('dump_json', 'no')):
324
328
        json_output = True
 
329
    container_report = config_true_value(conf.get('container_report', 'yes')) \
 
330
        and not options.object_only
 
331
    object_report = config_true_value(conf.get('object_report', 'yes')) \
 
332
        and not options.container_only
 
333
    if not (object_report or container_report):
 
334
        exit("Neither container or object report is set to run")
325
335
    if options.debug:
326
336
        debug = True
327
337
 
339
349
    container_ring = Ring(swift_dir, ring_name='container')
340
350
    object_ring = Ring(swift_dir, ring_name='object')
341
351
 
342
 
    container_result = container_dispersion_report(
343
 
        coropool, connpool, account, container_ring, retries,
344
 
        options.partitions)
345
 
    object_result = object_dispersion_report(
346
 
        coropool, connpool, account, object_ring, retries, options.partitions)
 
352
    output = {}
 
353
    if container_report:
 
354
        output['container'] = container_dispersion_report(
 
355
            coropool, connpool, account, container_ring, retries,
 
356
            options.partitions)
 
357
    if object_report:
 
358
        output['object'] = object_dispersion_report(
 
359
            coropool, connpool, account, object_ring, retries,
 
360
            options.partitions)
347
361
    if json_output:
348
 
        print json.dumps({"container": container_result,
349
 
                          "object": object_result})
 
362
        print json.dumps(output)