From 15bd189235b660890e12d60627e006ea608fb56e Mon Sep 17 00:00:00 2001 From: "Jay S. Bryant" Date: Wed, 19 Jun 2013 14:52:41 -0500 Subject: [PATCH] Add flag argument to 'cinder-manage config list' Unlike other cinder-manage 'list' commands the 'config list' option doesn't allow users to specify a filter to limit the output. This commit adds the ability to specify the flag the user wishes to display. If no flag is specified the default behavior is still to display all the configured flags. If the flag requested is not found, cinder-manage reports that the flag was not found. (fixes bug 1187137) Change-Id: I698f4c06d7e93217d8f307a880e0ae40711151c2 --- bin/cinder-manage | 18 +++++++++++++++--- doc/source/man/cinder-manage.rst | 4 ++-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/bin/cinder-manage b/bin/cinder-manage index 6c8dd3e39..021c1c8d4 100755 --- a/bin/cinder-manage +++ b/bin/cinder-manage @@ -450,9 +450,21 @@ class ConfigCommands(object): def __init__(self): pass - def list(self): - for key, value in CONF.iteritems(): - if value is not None: + @args('param', nargs='?', default=None, + help='Configuration parameter to display (default: %(default)s)') + def list(self, param=None): + """List parameters configured for cinder. + + Lists all parameters configured for cinder unless an optional argument + is specified. If the parameter is specified we only print the + requested parameter. If the parameter is not found an appropriate + error is produced by .get*(). + """ + param = param and param.strip() + if param: + print '%s = %s' % (param, CONF.get(param)) + else: + for key, value in CONF.iteritems(): print '%s = %s' % (key, value) diff --git a/doc/source/man/cinder-manage.rst b/doc/source/man/cinder-manage.rst index 2776c9756..85e923e49 100644 --- a/doc/source/man/cinder-manage.rst +++ b/doc/source/man/cinder-manage.rst @@ -157,9 +157,9 @@ Cinder Storage Management Cinder Config ~~~~~~~~~~~~~ -``cinder-manage config list`` +``cinder-manage config list []`` - Displays the current configuration parameters (options) for Cinder. + Displays the current configuration parameters (options) for Cinder. The optional flag parameter may be used to display the configuration of one parameter. FILES ===== -- 2.45.2