# HG changeset patch # User john.levon@xxxxxxx # Date 1215470381 25200 # Node ID 6042ba3dce6a57dbe7ee547ae65be93dbef1b0a2 # Parent fa3aae2098440bb154e4b699c1a352fe6a4f110b Improve virt-convert output Print some details before long operations such as disk convert, and add a --quiet flag to allow skipping them. Signed-off-by: John Levon <john.levon@xxxxxxx> diff --git a/man/en/virt-convert.1 b/man/en/virt-convert.1 --- a/man/en/virt-convert.1 +++ b/man/en/virt-convert.1 @@ -178,6 +178,9 @@ Output format. Currently, \f(CW\*(C`virt .IP "\-d, \-\-debug" 4 .IX Item "-d, --debug" Print debugging information +.IP "\-q, \-\-quiet" 4 +.IX Item "-q, --quiet" +Avoid verbose output. .SH "EXAMPLES" .IX Header "EXAMPLES" Convert a paravirt guest from \f(CW\*(C`image.vmx\*(C'\fR: diff --git a/man/en/virt-convert.pod b/man/en/virt-convert.pod --- a/man/en/virt-convert.pod +++ b/man/en/virt-convert.pod @@ -62,6 +62,10 @@ Output format. Currently, C<virt-image> Print debugging information +=item -q, --quiet + +Avoid verbose output. + =back =head1 EXAMPLES diff --git a/virt-convert b/virt-convert --- a/virt-convert +++ b/virt-convert @@ -36,6 +36,8 @@ def parse_args(): opts = OptionParser() opts.set_usage("%prog [options] inputdir|input.vmx " "[outputdir|output.xml]") + opts.add_option("-q", "--quiet", action="store_true", dest="quiet", + help=("Don't be verbose")) opts.add_option("-a", "--arch", type="string", dest="arch", default=util.get_default_arch(), help=("Machine Architecture Type (i686/x86_64/ppc)")) @@ -44,10 +46,10 @@ def parse_args(): opts.add_option("-d", "--debug", action="store_true", dest="debug", help=("Print debugging information")) opts.add_option("-i", "--input-format", action="store", - dest="inputformat", default="vmx", + dest="input_format", default="vmx", help=("Input format, e.g. 'vmx'")) opts.add_option("-o", "--output-format", action="store", - dest="outputformat", default="virt-image", + dest="output_format", default="virt-image", help=("Output format, e.g. 'virt-image'")) opts.add_option("-v", "--hvm", action="store_true", dest="fullvirt", help=("This guest should be a fully virtualized guest")) @@ -61,11 +63,11 @@ def parse_args(): opts.error(("Too many arguments provided")) # hard-code for now - if options.inputformat != "vmx": - opts.error(("Unsupported input format \"%s\"" % options.inputformat)) - if options.outputformat != "virt-image": + if options.input_format != "vmx": + opts.error(("Unsupported input format \"%s\"" % options.input_format)) + if options.output_format != "virt-image": opts.error(("Unsupported output format \"%s\"" - % options.outputformat)) + % options.output_format)) if os.path.isdir(args[0]): vmx_files = [x for x in os.listdir(args[0]) if x.endswith(".vmx") ] if (len(vmx_files)) == 0: @@ -92,6 +94,11 @@ def parse_args(): return options +def verbose(options, msg): + """Output a message if --quiet is not set.""" + if not options.quiet: + print msg + def rmrf(path): """Remove a directory and all its contents.""" @@ -127,17 +134,17 @@ def main(): cli.setupLogging("virt-convert", options.debug) try: - inp = virtconv.vmconfig.find_parser_by_name(options.inputformat) + inp = virtconv.vmconfig.find_parser_by_name(options.input_format) except: logging.error("No parser of format \"%s\" was found." % - options.inputformat) + options.input_format) sys.exit(1) try: - outp = virtconv.vmconfig.find_parser_by_name(options.outputformat) + outp = virtconv.vmconfig.find_parser_by_name(options.output_format) except: logging.error("No parser of format \"%s\" was found." % - options.outputformat) + options.output_format) sys.exit(1) vmdef = None @@ -184,8 +191,13 @@ def main(): logging.debug("output_file: %s" % options.output_file) logging.debug("output_dir: %s" % options.input_dir) + verbose(options, "Generating output in \"%s\" format to %s/" % + (options.output_format, options.output_dir)) + try: for d in vmdef.disks: + verbose(options, "Converting disk \"%s\" to type %s..." % + (d.path, vmconfig.qemu_formats[vmconfig.DISK_TYPE_RAW])) d.convert(options.input_dir, options.output_dir, vmconfig.DISK_TYPE_RAW) except OSError, e: @@ -199,7 +211,7 @@ def main(): cleanup("Couldn't export to file \"%s\": %s" % (options.output_file, e.message), options, created_dir) - print "\n\nConversion completed and placed in: %s" % options.output_dir + verbose(options, "Done.") if __name__ == "__main__": try: _______________________________________________ et-mgmt-tools mailing list et-mgmt-tools@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/et-mgmt-tools