cli: Drop dest= from most arguments, it was redundant

This commit is contained in:
Cole Robinson 2014-01-20 18:04:23 -05:00
parent 41a84bae9f
commit d1edce1ca5
5 changed files with 100 additions and 110 deletions

View File

@ -138,16 +138,14 @@ def parse_args():
geng.add_argument("-o", "--original", dest="original_guest",
help=_("Name of the original guest; "
"The status must be shut off or paused."))
geng.add_argument("--original-xml", dest="original_xml",
geng.add_argument("--original-xml",
help=_("XML file to use as the original guest."))
geng.add_argument("--auto-clone", dest="auto_clone", action="store_true",
geng.add_argument("--auto-clone", action="store_true",
help=_("Auto generate clone name and storage paths from"
" the original guest configuration."))
geng.add_argument("-n", "--name", dest="new_name",
help=_("Name for the new guest"))
geng.add_argument("-u", "--uuid", dest="new_uuid",
help=_("New UUID for the clone guest; Default is a "
"randomly generated UUID"))
geng.add_argument("-u", "--uuid", dest="new_uuid", help=argparse.SUPPRESS)
stog = parser.add_argument_group(_("Storage Configuration"))
stog.add_argument("-f", "--file", dest="new_diskfile", action="append",
@ -174,8 +172,7 @@ def parse_args():
# Just used for clone tests
misc.add_argument("--clone-running", action="store_true",
dest="clone_running", default=False,
help=argparse.SUPPRESS)
default=False, help=argparse.SUPPRESS)
cli.add_misc_options(misc, prompt=True, replace=True, printxml=True)

View File

@ -56,12 +56,12 @@ def parse_args():
add_output_arg(parser)
cong = parser.add_argument_group("Conversion Options")
cong.add_argument("-i", "--input-format", dest="input_format",
cong.add_argument("-i", "--input-format",
help=_("Input format, e.g. 'vmx'"))
cong.add_argument("-o", "--output-format", dest="output_format",
cong.add_argument("-o", "--output-format",
default="virt-image",
help=_("Output format, e.g. 'virt-image'"))
cong.add_argument("-D", "--disk-format", dest="disk_format",
cong.add_argument("-D", "--disk-format",
help=_("Output disk format"))
virg = parser.add_argument_group("Virtualization Type Options")
@ -71,7 +71,7 @@ def parse_args():
help=_("This guest should be a paravirtualized guest"))
cfgg = parser.add_argument_group("Guest Configuration Options")
cfgg.add_argument("-a", "--arch", dest="arch",
cfgg.add_argument("-a", "--arch",
default=get_default_arch(),
help=_("Machine Architecture Type (i686/x86_64/ppc)"))
cli.add_distro_options(cfgg)

View File

@ -20,6 +20,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301 USA.
import argparse
import sys
import urlgrabber.progress as progress
@ -41,13 +42,11 @@ def parse_args():
help=_("virt-image(5) image descriptor"))
geng = parser.add_argument_group(_("General Options"))
geng.add_argument("-n", "--name", dest="name",
help=_("Name of the guest instance"))
geng.add_argument("-n", "--name", help=_("Name of the guest instance"))
geng.add_argument("-r", "--ram", type=int, dest="memory",
help=_("Memory to allocate for guest instance in "
"megabytes"))
geng.add_argument("-u", "--uuid", dest="uuid",
help=_("UUID for the guest."))
geng.add_argument("-u", "--uuid", help=argparse.SUPPRESS)
cli.vcpu_cli_options(geng)
cli.add_distro_options(geng)
cli.add_old_feature_options(geng)
@ -56,10 +55,9 @@ def parse_args():
cli.graphics_option_group(parser)
misc = parser.add_argument_group(_("Miscellaneous Options"))
misc.add_argument("--boot", type=int, dest="boot",
misc.add_argument("--boot", type=int,
help=_("The zero-based index of the boot record to use"))
misc.add_argument("--skip-checksum", action="store_true",
dest="skipchecksum",
help=_("Skip disk checksum verification process"))
cli.add_misc_options(misc, prompt=True, replace=True, printxml=True,
@ -132,7 +130,7 @@ def main(conn=None):
meter = progress.TextMeter(fo=sys.stdout)
if not options.skipchecksum:
if not options.skip_checksum:
for disk in image.storage.values():
disk.check_disk_signature(meter=meter)

View File

@ -46,7 +46,7 @@ def install_specified(location, cdpath, pxe, import_install):
return bool(pxe or cdpath or location or import_install)
def cdrom_specified(guest, diskopts=None):
def cdrom_specified(guest, disk=None):
disks = guest.get_devices("disk")
for disk in disks:
@ -54,8 +54,8 @@ def cdrom_specified(guest, diskopts=None):
return True
# Probably haven't set up disks yet
if not disks and diskopts:
for opts in diskopts:
if not disks and disk:
for opts in disk:
if opts.count("device=cdrom"):
return True
@ -114,11 +114,11 @@ def check_cdrom_option_error(options):
##############################
def convert_old_sound(options):
if options.sound:
if options.soundhw:
return
if not options.old_sound_bool:
return
options.sound = "default"
options.soundhw = "default"
def get_disks(guest, disks, nodisks, need_storage):
@ -128,9 +128,9 @@ def get_disks(guest, disks, nodisks, need_storage):
if not disks and need_storage and cli.is_prompt():
disks = [None]
for diskopts in disks:
for disk in disks:
try:
if diskopts is None:
if disk is None:
dev = None
sparse = True
size = None
@ -139,7 +139,7 @@ def get_disks(guest, disks, nodisks, need_storage):
# We skip validation here, since we may have converted
# --file-size to --disk size=8 which doesn't validate on
# its own.
dev = cli.parse_disk(guest, diskopts,
dev = cli.parse_disk(guest, disk,
virtinst.VirtualDisk(guest.conn))
size = dev.cli_size
path = dev.path
@ -154,7 +154,7 @@ def get_disks(guest, disks, nodisks, need_storage):
def convert_old_disks(options):
if options.diskopts or options.nodisks:
if options.disk or options.nodisks:
return
paths = virtinst.util.listify(options.file_paths)
@ -184,7 +184,7 @@ def convert_old_disks(options):
logging.debug("Converted to new style: --disk %s", optstr)
opts.append(optstr)
options.diskopts = opts
options.disk = opts
options.file_paths = []
options.disksize = None
options.sparse = True
@ -378,16 +378,16 @@ def validate_required_options(options, guest):
msg += "\n" + cli.ram_missing
if (not guest.os.is_container() and
not storage_specified(options.diskopts,
not storage_specified(options.disk,
options.nodisks,
options.filesystems)):
options.filesystem)):
msg += "\n" + disk_missing
need_storage = True
if (not guest.os.is_container() and
(not install_specified(options.location, options.cdrom,
options.pxe, options.import_install)) and
(not cdrom_specified(guest, options.diskopts))):
(not cdrom_specified(guest, options.disk))):
msg += "\n" + install_missing
need_install = True
@ -400,12 +400,12 @@ def validate_required_options(options, guest):
def check_option_collisions(options, guest):
# Disk collisions
if options.nodisks and (options.file_paths or
options.diskopts or
options.disk or
options.disksize):
fail(_("Cannot specify storage and use --nodisks"))
if ((options.file_paths or options.disksize or not options.sparse) and
options.diskopts):
options.disk):
fail(_("Cannot mix --file, --nonsparse, or --file-size with --disk "
"options. Use --disk PATH[,size=SIZE][,sparse=yes|no]"))
@ -443,9 +443,9 @@ def check_option_collisions(options, guest):
guest.conn.support_remote_url_install()):
fail(_("Libvirt version does not support remote --location installs"))
if not options.location and options.extra:
if not options.location and options.extra_args:
fail(_("--extra-args only work if specified with --location."))
if not options.location and options.initrd_injections:
if not options.location and options.initrd_inject:
fail(_("--initrd-inject only works if specified with --location."))
@ -464,7 +464,7 @@ def build_installer(options, conn, virt_type):
instclass = virtinst.PXEInstaller
elif options.cdrom or options.location:
instclass = virtinst.DistroInstaller
elif options.import_install or options.bootopts:
elif options.import_install or options.boot:
if options.import_install and options.nodisks:
fail(_("A disk device must be specified with --import."))
options.import_install = True
@ -496,8 +496,8 @@ def build_guest_instance(conn, options):
cli.convert_old_features(options)
# Install options
guest.installer.extraargs = options.extra
guest.installer.initrd_injections = options.initrd_injections
guest.installer.extraargs = options.extra_args or ""
guest.installer.initrd_injections = options.initrd_inject
cli.set_os_variant(guest, options.distro_type, options.distro_variant)
guest.os.init = options.init
@ -507,7 +507,7 @@ def build_guest_instance(conn, options):
cli.parse_numatune(guest, options.numatune)
cli.parse_cpu(guest, options.cpu)
cli.parse_security(guest, options.security)
cli.parse_boot(guest, options.bootopts)
cli.parse_boot(guest, options.boot)
cli.parse_features(guest, options.features)
cli.parse_clock(guest, options.clock)
@ -522,13 +522,13 @@ def build_guest_instance(conn, options):
cli.get_graphics(guest, options.graphics)
cli.get_videos(guest, options.video)
cli.get_watchdogs(guest, options.watchdog)
cli.get_filesystems(guest, options.filesystems)
cli.get_sounds(guest, options.sound)
cli.get_serials(guest, options.serials)
cli.get_parallels(guest, options.parallels)
cli.get_channels(guest, options.channels)
cli.get_consoles(guest, options.consoles)
cli.get_hostdevs(guest, options.hostdevs)
cli.get_filesystems(guest, options.filesystem)
cli.get_sounds(guest, options.soundhw)
cli.get_serials(guest, options.serial)
cli.get_parallels(guest, options.parallel)
cli.get_channels(guest, options.channel)
cli.get_consoles(guest, options.console)
cli.get_hostdevs(guest, options.host_device)
cli.get_smartcards(guest, options.smartcard)
cli.get_tpms(guest, options.tpm)
cli.get_rngs(guest, options.rng)
@ -550,7 +550,7 @@ def build_guest_instance(conn, options):
# Needs to come after setting memory
cli.get_cpuset(guest, options.cpuset)
get_disks(guest, options.diskopts, options.nodisks, need_storage)
get_disks(guest, options.disk, options.nodisks, need_storage)
get_install_media(guest, options.location, options.cdrom, need_install)
# Various little validations about option collisions. Need to do
@ -890,58 +890,55 @@ def parse_args():
cli.add_connect_option(parser)
geng = parser.add_argument_group(_("General Options"))
geng.add_argument("-n", "--name", dest="name",
geng.add_argument("-n", "--name",
help=_("Name of the guest instance"))
geng.add_argument("-r", "--ram", type=int, dest="memory",
help=_("Memory to allocate for guest instance in "
"megabytes"))
cli.vcpu_cli_options(geng)
geng.add_argument("--description", dest="description",
geng.add_argument("--description",
help=_("Human readable description of the VM to store in "
"the generated XML."))
geng.add_argument("--security", dest="security",
geng.add_argument("--security",
help=_("Set domain security driver configuration."))
geng.add_argument("--numatune", dest="numatune",
geng.add_argument("--numatune",
help=_("Tune NUMA policy for the domain process."))
geng.add_argument("--features", dest="features",
geng.add_argument("--features",
help=_("Set domain <features> XML. Ex:\n"
"--features acpi=off\n"
"--features apic=on,eoi=on"))
geng.add_argument("--clock", dest="clock",
geng.add_argument("--clock",
help=_("Set domain <clock> XML. Ex:\n"
"--clock offset=localtime,rtc_tickpolicy=catchup"))
insg = parser.add_argument_group(_("Installation Method Options"))
insg.add_argument("-c", dest="cdrom_short", help=argparse.SUPPRESS)
insg.add_argument("--cdrom", dest="cdrom",
help=_("CD-ROM installation media"))
insg.add_argument("-l", "--location", dest="location",
insg.add_argument("--cdrom", help=_("CD-ROM installation media"))
insg.add_argument("-l", "--location",
help=_("Installation source (eg, nfs:host:/path, "
"http://host/path, ftp://host/path)"))
insg.add_argument("--pxe", action="store_true", dest="pxe",
insg.add_argument("--pxe", action="store_true",
help=_("Boot from the network using the PXE protocol"))
insg.add_argument("--import", action="store_true", dest="import_install",
help=_("Build guest around an existing disk image"))
insg.add_argument("--init", dest="init",
insg.add_argument("--init",
help=_("Path to init binary for container guest. Ex:\n"
"--init /path/to/app (to contain an application)\n"
"--init /sbin/init (for a full OS container)"))
insg.add_argument("--livecd", action="store_true", dest="livecd",
insg.add_argument("--livecd", action="store_true",
help=_("Treat the CD-ROM media as a Live CD"))
insg.add_argument("-x", "--extra-args", dest="extra",
default="",
insg.add_argument("-x", "--extra-args",
help=_("Additional arguments to pass to the install kernel "
"booted from --location"))
insg.add_argument("--initrd-inject", dest="initrd_injections",
action="append",
insg.add_argument("--initrd-inject", action="append",
help=_("Add given file to root of initrd from --location"))
cli.add_distro_options(insg)
insg.add_argument("--boot", dest="bootopts", default="",
insg.add_argument("--boot", default="",
help=_("Optionally configure post-install boot order, "
"menu, permanent kernel boot, etc."))
stog = parser.add_argument_group(_("Storage Configuration"))
stog.add_argument("--disk", dest="diskopts", action="append",
stog.add_argument("--disk", action="append",
help=_("Specify storage with various options. Ex.\n"
"--disk path=/my/existing/disk\n"
"--disk path=/my/new/disk,size=5 (in gigabytes)\n"
@ -981,22 +978,20 @@ def parse_args():
virg = parser.add_argument_group(_("Virtualization Platform Options"))
virg.add_argument("-v", "--hvm", action="store_true", dest="fullvirt",
help=_("This guest should be a fully virtualized guest"))
virg.add_argument("-p", "--paravirt", action="store_true", dest="paravirt",
virg.add_argument("-p", "--paravirt", action="store_true",
help=_("This guest should be a paravirtualized guest"))
virg.add_argument("--container", action="store_true", default=False,
dest="container",
help=_("This guest should be a container guest"))
virg.add_argument("--virt-type", dest="hv_type",
default="",
help=_("Hypervisor name to use (kvm, qemu, xen, ...)"))
virg.add_argument("--accelerate", action="store_true", default=False,
dest="accelerate", help=argparse.SUPPRESS)
virg.add_argument("--arch", dest="arch",
help=argparse.SUPPRESS)
virg.add_argument("--arch",
help=_("The CPU architecture to simulate"))
virg.add_argument("--machine", dest="machine",
virg.add_argument("--machine",
help=_("The machine type to emulate"))
virg.add_argument("-u", "--uuid", dest="uuid",
help=_("UUID for the guest."))
virg.add_argument("-u", "--uuid", help=argparse.SUPPRESS)
cli.add_old_feature_options(virg)
misc = parser.add_argument_group(_("Miscellaneous Options"))

View File

@ -755,7 +755,7 @@ def set_os_variant(obj, distro_type, distro_variant):
#############################
def add_connect_option(parser):
parser.add_argument("--connect", metavar="URI", dest="connect",
parser.add_argument("--connect", metavar="URI",
help=_("Connect to hypervisor with libvirt URI"))
@ -763,17 +763,17 @@ def add_misc_options(grp, prompt=False, replace=False,
printxml=False, printstep=False,
noreboot=False, dryrun=False):
if prompt:
grp.add_argument("--prompt", action="store_true", dest="prompt",
grp.add_argument("--prompt", action="store_true",
default=False, help=argparse.SUPPRESS)
grp.add_argument("--force", action="store_true", dest="force",
grp.add_argument("--force", action="store_true",
default=False, help=argparse.SUPPRESS)
if noreboot:
grp.add_argument("--noreboot", action="store_true", dest="noreboot",
grp.add_argument("--noreboot", action="store_true",
help=_("Don't boot guest after completing install."))
if replace:
grp.add_argument("--replace", action="store_true", dest="replace",
grp.add_argument("--replace", action="store_true",
help=_("Don't check name collision, overwrite any guest "
"with the same name."))
@ -791,26 +791,26 @@ def add_misc_options(grp, prompt=False, replace=False,
help=_("Run through install process, but do not "
"create devices or define the guest."))
grp.add_argument("-q", "--quiet", action="store_true", dest="quiet",
grp.add_argument("-q", "--quiet", action="store_true",
help=_("Suppress non-error output"))
grp.add_argument("-d", "--debug", action="store_true", dest="debug",
grp.add_argument("-d", "--debug", action="store_true",
help=_("Print debugging information"))
def vcpu_cli_options(grp, backcompat=True):
grp.add_argument("--vcpus", dest="vcpus",
grp.add_argument("--vcpus",
help=_("Number of vcpus to configure for your guest. Ex:\n"
"--vcpus 5\n"
"--vcpus 5,maxcpus=10\n"
"--vcpus sockets=2,cores=4,threads=2"))
grp.add_argument("--cpuset", dest="cpuset",
grp.add_argument("--cpuset",
help=_("Set which physical CPUs domain can use."))
grp.add_argument("--cpu", dest="cpu",
grp.add_argument("--cpu",
help=_("CPU model and features. Ex: --cpu coreduo,+x2apic"))
if backcompat:
grp.add_argument("--check-cpu", action="store_true",
dest="check_cpu", help=argparse.SUPPRESS)
help=argparse.SUPPRESS)
def graphics_option_group(parser):
@ -820,15 +820,15 @@ def graphics_option_group(parser):
vncg = parser.add_argument_group(_("Graphics Configuration"))
add_gfx_option(vncg)
vncg.add_argument("--vnc", action="store_true", dest="vnc",
vncg.add_argument("--vnc", action="store_true",
help=argparse.SUPPRESS)
vncg.add_argument("--vncport", type=int, dest="vncport",
vncg.add_argument("--vncport", type=int,
help=argparse.SUPPRESS)
vncg.add_argument("--vnclisten", dest="vnclisten",
vncg.add_argument("--vnclisten",
help=argparse.SUPPRESS)
vncg.add_argument("-k", "--keymap", dest="keymap",
vncg.add_argument("-k", "--keymap",
help=argparse.SUPPRESS)
vncg.add_argument("--sdl", action="store_true", dest="sdl",
vncg.add_argument("--sdl", action="store_true",
help=argparse.SUPPRESS)
vncg.add_argument("--nographics", action="store_true",
help=argparse.SUPPRESS)
@ -844,16 +844,16 @@ def network_option_group(parser):
add_net_option(netg)
# Deprecated net options
netg.add_argument("-b", "--bridge", dest="bridge", action="append",
netg.add_argument("-b", "--bridge", action="append",
help=argparse.SUPPRESS)
netg.add_argument("-m", "--mac", dest="mac", action="append",
netg.add_argument("-m", "--mac", action="append",
help=argparse.SUPPRESS)
return netg
def add_net_option(devg):
devg.add_argument("-w", "--network", dest="network", action="append",
devg.add_argument("-w", "--network", action="append",
help=_("Configure a guest network interface. Ex:\n"
"--network bridge=mybr0\n"
"--network network=my_libvirt_virtual_net\n"
@ -862,50 +862,50 @@ def add_net_option(devg):
def add_device_options(devg):
devg.add_argument("--controller", dest="controller", action="append",
devg.add_argument("--controller", action="append",
help=_("Configure a guest controller device. Ex:\n"
"--controller type=usb,model=ich9-ehci1"))
devg.add_argument("--serial", dest="serials", action="append",
devg.add_argument("--serial", action="append",
help=_("Configure a guest serial device"))
devg.add_argument("--parallel", dest="parallels", action="append",
devg.add_argument("--parallel", action="append",
help=_("Configure a guest parallel device"))
devg.add_argument("--channel", dest="channels", action="append",
devg.add_argument("--channel", action="append",
help=_("Configure a guest communication channel"))
devg.add_argument("--console", dest="consoles", action="append",
devg.add_argument("--console", action="append",
help=_("Configure a text console connection between "
"the guest and host"))
devg.add_argument("--host-device", dest="hostdevs", action="append",
devg.add_argument("--host-device", action="append",
help=_("Configure physical host devices attached to the "
"guest"))
devg.add_argument("--soundhw", dest="sound", action="append",
devg.add_argument("--soundhw", action="append",
help=_("Configure guest sound device emulation"))
devg.add_argument("--watchdog", dest="watchdog", action="append",
devg.add_argument("--watchdog", action="append",
help=_("Configure a guest watchdog device"))
devg.add_argument("--video", dest="video", action="append",
devg.add_argument("--video", action="append",
help=_("Configure guest video hardware."))
devg.add_argument("--smartcard", dest="smartcard", action="append",
devg.add_argument("--smartcard", action="append",
help=_("Configure a guest smartcard device. Ex:\n"
"--smartcard mode=passthrough"))
devg.add_argument("--redirdev", dest="redirdev", action="append",
devg.add_argument("--redirdev", action="append",
help=_("Configure a guest redirection device. Ex:\n"
"--redirdev usb,type=tcp,server=192.168.1.1:4000"))
devg.add_argument("--memballoon", dest="memballoon", action="append",
devg.add_argument("--memballoon", action="append",
help=_("Configure a guest memballoon device. Ex:\n"
"--memballoon model=virtio"))
devg.add_argument("--tpm", dest="tpm", action="append",
devg.add_argument("--tpm", action="append",
help=_("Configure a guest TPM device. Ex:\n"
"--tpm /dev/tpm"))
devg.add_argument("--rng", dest="rng", action="append",
devg.add_argument("--rng", action="append",
help=_("Configure a guest RNG device. Ex:\n"
"--rng /dev/random\n"
"--rng egd,backend_host=localhost,backend_service=708,backend_type=tcp"))
devg.add_argument("--panic", dest="panic", action="append",
devg.add_argument("--panic", action="append",
help=_("Configure a guest panic device. Ex:\n"
"--panic default"))
def add_gfx_option(devg):
devg.add_argument("--graphics", dest="graphics", action="append",
devg.add_argument("--graphics", action="append",
help=_("Configure guest display settings. Ex:\n"
"--graphics vnc\n"
"--graphics spice,port=5901,tlsport=5902\n"
@ -914,7 +914,7 @@ def add_gfx_option(devg):
def add_fs_option(devg):
devg.add_argument("--filesystem", dest="filesystems", action="append",
devg.add_argument("--filesystem", action="append",
help=_("Pass host directory to the guest. Ex: \n"
"--filesystem /my/source/dir,/dir/in/guest\n"
"--filesystem template_name,/,type=template"))
@ -932,9 +932,9 @@ def add_distro_options(g):
def add_old_feature_options(optg):
optg.add_argument("--noapic", action="store_true", dest="noapic",
optg.add_argument("--noapic", action="store_true",
default=False, help=argparse.SUPPRESS)
optg.add_argument("--noacpi", action="store_true", dest="noacpi",
optg.add_argument("--noacpi", action="store_true",
default=False, help=argparse.SUPPRESS)