~ubuntu-branches/ubuntu/quantal/virtinst/quantal-updates

« back to all changes in this revision

Viewing changes to virtinst/cli.py

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2012-07-24 08:52:01 UTC
  • mfrom: (1.6.8 sid)
  • Revision ID: package-import@ubuntu.com-20120724085201-q3h0cbabg4t46gfm
Tags: 0.600.2-1ubuntu1
* Merge from debian unstable. Remaining changes:
  - debian/patches/9003-fix-path-to-hvmloader-in-testsuite.patch: adjust
    testsuite for 0001-fix-path-to-hvmloader.patch and
    0002-Fix-path-to-pygrub.patch.
  - debian/patches/9004_ubuntu_fix_tree_support.patch: Fix tree detection
    for all ISO/HTTP source, to not longer fail with cobbler/koan.
  - debian/patches/0004-Fix-path-to-qemu-dm.patch: fix the path to the
    qemu-dm binary.
  - debian/{control,rules,pyversions}: Build using dh_python2, use
    debhelper v8 instead of cdbs; for some reason the package build an
    empty binary package when using dh_python2.
  - debian/control: added acl package to depends.
  - debian/control: added libvirt-bin to recommends
* Dropped patches:
  - debian/patches/9005_ubuntu_releases.patch: Upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
255
255
 
256
256
    # Need tmpfile names to be deterministic
257
257
    if "predictable" in opts:
 
258
        setattr(conn, "_virtinst__fake_conn_predictable", True)
 
259
 
258
260
        def fakemkstemp(prefix, *args, **kwargs):
259
261
            ignore = args
260
262
            ignore = kwargs
262
264
            return os.open(filename, os.O_RDWR | os.O_CREAT), filename
263
265
        tempfile.mkstemp = fakemkstemp
264
266
 
265
 
        _util.randomMAC = lambda type_: "00:11:22:33:44:55"
266
 
        _util.uuidToString = lambda r: "00000000-1111-2222-3333-444444444444"
267
 
 
268
267
    # Fake remote status
269
268
    if "remote" in opts:
270
 
        _util.is_uri_remote = lambda uri_: True
 
269
        setattr(conn, "_virtinst__fake_conn_remote", True)
271
270
 
272
271
    # Fake capabilities
273
272
    if "caps" in opts:
437
436
    Convenience function when failing in cli app
438
437
    """
439
438
    logging.error(msg)
440
 
    logging.debug("", exc_info=True)
 
439
    import traceback
 
440
    if traceback.format_exc().strip() != "None":
 
441
        logging.debug("", exc_info=True)
441
442
    if do_exit:
442
443
        _fail_exit()
443
444
 
707
708
        # If we fail within the loop, reprompt for size and path
708
709
        if not retry_path:
709
710
            origpath = None
710
 
            origsize = None
 
711
            if not path_to_clone:
 
712
                origsize = None
711
713
        retry_path = False
712
714
 
713
715
        # Get disk path
1017
1019
        if dev:
1018
1020
            guest.add_device(dev)
1019
1021
 
 
1022
def get_memballoon(guest, sc_opts):
 
1023
    for sc in listify(sc_opts):
 
1024
        try:
 
1025
            dev = parse_memballoon(guest, sc)
 
1026
        except Exception, e:
 
1027
            fail(_("Error in memballoon device parameters: %s") % str(e))
 
1028
 
 
1029
        if dev:
 
1030
            guest.add_device(dev)
 
1031
 
1020
1032
#############################
1021
1033
# Common CLI option/group   #
1022
1034
#############################
1112
1124
    devg.add_option("", "--redirdev", dest="redirdev", action="append",
1113
1125
                    help=_("Configure a guest redirection device. Ex:\n"
1114
1126
                           "--redirdev usb,type=tcp,server=192.168.1.1:4000"))
 
1127
    devg.add_option("", "--memballoon", dest="memballoon", action="append",
 
1128
                    help=_("Configure a guest memballoon device. Ex:\n"
 
1129
                           "--memballoon medel=virtio"))
1115
1130
 
1116
1131
def add_gfx_option(devg):
1117
1132
    devg.add_option("", "--graphics", dest="graphics", action="append",
1355
1370
        if val == None:
1356
1371
            return
1357
1372
 
1358
 
        setattr(guest.installer.bootconfig, paramname, val)
 
1373
        if paramname == "loader":
 
1374
            guest.installer.loader = val
 
1375
        else:
 
1376
            setattr(guest.installer.bootconfig, paramname, val)
1359
1377
 
1360
1378
    # Convert menu= value
1361
1379
    if "menu" in opts:
1375
1393
    set_param("enable_bootmenu", "menu", menu)
1376
1394
    set_param("kernel", "kernel")
1377
1395
    set_param("initrd", "initrd")
 
1396
    set_param("loader", "loader")
1378
1397
    set_param("kernel_args", ["kernel_args", "extra_args"])
1379
1398
 
1380
1399
    # Build boot order
1830
1849
 
1831
1850
    return dev
1832
1851
 
 
1852
########################
 
1853
# --memballoon parsing #
 
1854
########################
 
1855
 
 
1856
def parse_memballoon(guest, optstring, dev=None):
 
1857
    if optstring is None:
 
1858
        return None
 
1859
 
 
1860
    # Peel the mode off the front
 
1861
    opts = parse_optstr(optstring, remove_first="model")
 
1862
    model = get_opt_param(opts, "model")
 
1863
 
 
1864
    if not dev:
 
1865
        dev = virtinst.VirtualMemballoon(model=model,
 
1866
                                         conn=guest.conn)
 
1867
 
 
1868
    if opts:
 
1869
        raise ValueError(_("Unknown options %s") % opts.keys())
 
1870
 
 
1871
    return dev
 
1872
 
1833
1873
 
1834
1874
######################################################
1835
1875
# --serial, --parallel, --channel, --console parsing #