Change usage help and Attention messages to warnings

Change-Id: I1396aaffe36e739606f15f7fef37b11bd83f1fc1
This commit is contained in:
Mark Seger 2015-06-03 08:16:06 -04:00
parent 2242b0ae8a
commit af734b3fb6
4 changed files with 10 additions and 8 deletions

View File

@ -26,7 +26,7 @@ if __name__ == '__main__':
usage = ''' usage = '''
Shows the nodes responsible for the item specified. Shows the nodes responsible for the item specified.
Usage: %prog [-a] <ring.gz> <account> [<container>] [<object>] Usage: %prog [-a] <ring.gz> <account> [<container> [<object>]]
Or: %prog [-a] <ring.gz> -p partition Or: %prog [-a] <ring.gz> -p partition
Or: %prog [-a] -P policy_name <account> <container> <object> Or: %prog [-a] -P policy_name <account> <container> <object>
Note: account, container, object can also be a single arg separated by / Note: account, container, object can also be a single arg separated by /

View File

@ -25,7 +25,7 @@
.SH SYNOPSIS .SH SYNOPSIS
.LP .LP
.B swift-get-nodes .B swift-get-nodes
\ <ring.gz> <account> [<container>] [<object>] \ <ring.gz> <account> [<container> [<object>]]
.SH DESCRIPTION .SH DESCRIPTION
.PP .PP

View File

@ -382,7 +382,7 @@ def print_obj(datafile, check_etag=True, swift_dir='/etc/swift',
if (policy_index is not None and if (policy_index is not None and
policy_index_for_name is not None and policy_index_for_name is not None and
policy_index != policy_index_for_name): policy_index != policy_index_for_name):
print 'Attention: Ring does not match policy!' print 'Warning: Ring does not match policy!'
print 'Double check your policy name!' print 'Double check your policy name!'
if not ring and policy_index_for_name: if not ring and policy_index_for_name:
ring = POLICIES.get_object_ring(policy_index_for_name, ring = POLICIES.get_object_ring(policy_index_for_name,
@ -472,9 +472,9 @@ def print_item_locations(ring, ring_name=None, account=None, container=None,
policy = POLICIES.get_by_name(policy_name) policy = POLICIES.get_by_name(policy_name)
if policy: if policy:
if ring_name != policy.ring_name: if ring_name != policy.ring_name:
print 'Attention! mismatch between ring and policy detected!' print 'Warning: mismatch between ring and policy name!'
else: else:
print 'Attention! Policy %s is not valid' % policy_name print 'Warning: Policy %s is not valid' % policy_name
policy_index = None policy_index = None
if ring is None and (obj or part): if ring is None and (obj or part):
@ -518,14 +518,16 @@ def print_item_locations(ring, ring_name=None, account=None, container=None,
ring = Ring(swift_dir, ring_name='container') ring = Ring(swift_dir, ring_name='container')
else: else:
if ring_name != 'container': if ring_name != 'container':
print 'Attention! mismatch between ring and item detected!' print 'Warning: account/container specified ' + \
'but ring not named "container"'
if account and not container and not obj: if account and not container and not obj:
loc = 'accounts' loc = 'accounts'
if not any([ring, ring_name]): if not any([ring, ring_name]):
ring = Ring(swift_dir, ring_name='account') ring = Ring(swift_dir, ring_name='account')
else: else:
if ring_name != 'account': if ring_name != 'account':
print 'Attention! mismatch between ring and item detected!' print 'Warning: account specified ' + \
'but ring not named "account"'
print '\nAccount \t%s' % account print '\nAccount \t%s' % account
print 'Container\t%s' % container print 'Container\t%s' % container

View File

@ -411,7 +411,7 @@ class TestPrintObjFullMeta(TestCliInfoBase):
out = StringIO() out = StringIO()
with mock.patch('sys.stdout', out): with mock.patch('sys.stdout', out):
print_obj(self.datafile, policy_name='two', swift_dir=self.testdir) print_obj(self.datafile, policy_name='two', swift_dir=self.testdir)
ring_alert_msg = 'Attention: Ring does not match policy' ring_alert_msg = 'Warning: Ring does not match policy!'
self.assertTrue(ring_alert_msg in out.getvalue()) self.assertTrue(ring_alert_msg in out.getvalue())
def test_valid_etag(self): def test_valid_etag(self):