Merge "Call swift-recon with more than one server type"

This commit is contained in:
Jenkins
2016-07-07 14:27:55 +00:00
committed by Gerrit Code Review

View File

@@ -941,7 +941,8 @@ class SwiftRecon(object):
""" """
print("=" * 79) print("=" * 79)
usage = ''' usage = '''
usage: %prog <server_type> [-v] [--suppress] [-a] [-r] [-u] [-d] usage: %prog <server_type> [<server_type> [<server_type>]]
[-v] [--suppress] [-a] [-r] [-u] [-d]
[-l] [-T] [--md5] [--auditor] [--updater] [--expirer] [--sockstat] [-l] [-T] [--md5] [--auditor] [--updater] [--expirer] [--sockstat]
[--human-readable] [--human-readable]
@@ -1009,37 +1010,38 @@ class SwiftRecon(object):
'storage policy (specified as name or index).') 'storage policy (specified as name or index).')
options, arguments = args.parse_args() options, arguments = args.parse_args()
if len(sys.argv) <= 1 or len(arguments) > 1: if len(sys.argv) <= 1 or len(arguments) > len(self.check_types):
args.print_help() args.print_help()
sys.exit(0) sys.exit(0)
if arguments: if arguments:
if arguments[0] in self.check_types: arguments = set(arguments)
self.server_type = arguments[0] if arguments.issubset(self.check_types):
server_types = arguments
else: else:
print("Invalid Server Type") print("Invalid Server Type")
args.print_help() args.print_help()
sys.exit(1) sys.exit(1)
else: else: # default
self.server_type = 'object' server_types = ['object']
swift_dir = options.swiftdir swift_dir = options.swiftdir
self.verbose = options.verbose self.verbose = options.verbose
self.suppress_errors = options.suppress self.suppress_errors = options.suppress
self.timeout = options.timeout self.timeout = options.timeout
for server_type in server_types:
self.server_type = server_type
ring_names = self._get_ring_names(options.policy) ring_names = self._get_ring_names(options.policy)
if not ring_names: if not ring_names:
print('Invalid Storage Policy') print('Invalid Storage Policy: %s' % options.policy)
args.print_help() args.print_help()
sys.exit(0) sys.exit(0)
hosts = self.get_hosts(options.region, options.zone, hosts = self.get_hosts(options.region, options.zone,
swift_dir, ring_names) swift_dir, ring_names)
print("--> Starting reconnaissance on %s hosts (%s)" %
print("--> Starting reconnaissance on %s hosts" % len(hosts)) (len(hosts), self.server_type))
print("=" * 79) print("=" * 79)
if options.all: if options.all:
if self.server_type == 'object': if self.server_type == 'object':
self.async_check(hosts) self.async_check(hosts)
@@ -1068,7 +1070,9 @@ class SwiftRecon(object):
if self.server_type == 'object': if self.server_type == 'object':
self.async_check(hosts) self.async_check(hosts)
else: else:
print("Error: Can't check asyncs on non object servers.") print("Error: Can't check asyncs on non object "
"servers.")
print("=" * 79)
if options.unmounted: if options.unmounted:
self.umount_check(hosts) self.umount_check(hosts)
if options.replication: if options.replication:
@@ -1080,14 +1084,18 @@ class SwiftRecon(object):
self.auditor_check(hosts) self.auditor_check(hosts)
if options.updater: if options.updater:
if self.server_type == 'account': if self.server_type == 'account':
print("Error: Can't check updaters on account servers.") print("Error: Can't check updaters on account "
"servers.")
print("=" * 79)
else: else:
self.updater_check(hosts) self.updater_check(hosts)
if options.expirer: if options.expirer:
if self.server_type == 'object': if self.server_type == 'object':
self.expirer_check(hosts) self.expirer_check(hosts)
else: else:
print("Error: Can't check expired on non object servers.") print("Error: Can't check expired on non object "
"servers.")
print("=" * 79)
if options.validate_servers: if options.validate_servers:
self.server_type_check(hosts) self.server_type_check(hosts)
if options.loadstats: if options.loadstats: