add a -v command line switch to increase output verbosity

This commit is contained in:
Doug Hellmann 2012-03-07 17:44:25 -05:00
parent 78a59e7850
commit e5791eaa34
2 changed files with 13 additions and 2 deletions

View File

@ -43,6 +43,12 @@ def parse():
action="append",
dest="component",
help="openstack component: %s" % (_format_list(settings.COMPONENT_NAMES)))
parser.add_option("-v", "--verbose",
action="append_const",
const=1,
dest="verbosity",
default=[1],
help="increase the verbose level")
base_group = OptionGroup(parser, "Install & uninstall & start & stop specific options")
base_group.add_option("-a", "--action",
@ -104,7 +110,6 @@ def parse():
output['ignore_deps'] = not options.ensure_deps
output['keep_old'] = options.keep_old
output['extras'] = args
LOG.debug("Extracted options %s" % (output))
output['verbosity'] = len(options.verbosity)
return output

6
stack
View File

@ -16,6 +16,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import logging
import logging.config
import os
import sys
@ -114,6 +115,11 @@ def main():
args = opts.parse()
prog_name = sys.argv[0]
# Adjust logging verbose level based on the command line switch.
if args['verbosity'] >= 2:
lg.getLogger().setLevel(logging.DEBUG)
LOG.debug("Command line options %s" % (args))
#will need root to setup openstack
if not sh.got_root():
rest_args = sys.argv[1:]