VirtualBox

Changeset 21907 in vbox for trunk


Ignore:
Timestamp:
Jul 31, 2009 8:39:40 AM (15 years ago)
Author:
vboxsync
Message:

Python shell: exportVM command

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxShell/vboxshell.py

    r21790 r21907  
    882882    return 0
    883883
     884def exportVMCmd(ctx, args):
     885    import sys
     886
     887    if len(args) < 3:
     888        print "usage: exportVm <machine> <path> <format> <license>"
     889        return 0
     890    mach = ctx['machById'](args[1])
     891    if mach is None:
     892        return 0
     893    path = args[2]
     894    if (len(args) > 3):
     895        format = args[3]
     896    else:
     897        format = "ovf-1.0"
     898    if (len(args) > 4):
     899        license = args[4]
     900    else:
     901        license = "GPL"
     902
     903    app = ctx['vb'].createAppliance()
     904    desc = mach.export(app)
     905    desc.addDescription(ctx['global'].constants.VirtualSystemDescriptionType_License, license, "")
     906    p = app.write(format, path)
     907    try:
     908        while not p.completed:
     909            print "%d %%\r" %(p.percent),
     910            sys.stdout.flush()
     911            p.waitForCompletion(1000)
     912    except KeyboardInterrupt:
     913        print "Interrupted."
     914    print "Exported to %s in format %s" %(path, format)
     915    return 0
     916
    884917aliases = {'s':'start',
    885918           'i':'info',
     
    916949            'runScript':['Run VBox script: runScript script.vbox', runScriptCmd, 0],
    917950            'sleep':['Sleep for specified number of seconds: sleep 3.14159', sleepCmd, 0],
    918             'shell':['Execute external shell comman: shell "ls /etc/rc*"', shellCmd, 0]
     951            'shell':['Execute external shell command: shell "ls /etc/rc*"', shellCmd, 0],
     952            'exportVm':['Export VM in OVF format: export Win /tmp/win.ovf', exportVMCmd, 0]
    919953            }
    920954
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette