Check-in [1d444062a8]
Not logged in
Overview
Comment:Written autostart command
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 1d444062a8339409f7611747df21208d8624f337
User & Date: vitus on 2016-04-07 13:53:42
Other Links: manifest | tags
Context
2016-04-14
14:35
Set permissions on VM files. Fixes [067fea7873] check-in: 6c894d8ca6 user: vitus tags: trunk
2016-04-07
13:53
Written autostart command check-in: 1d444062a8 user: vitus tags: trunk
2016-04-05
13:37
Fixed some pylint warnings check-in: 0fda55579a user: vitus tags: trunk
Changes

Modified vws from [047d8f3ad1] to [b585fb76c1].

463
464
465
466
467
468
469



































470
471
472
473
474
475
476
            sys.exit(1)
    else:
        if snapshot_mode(options.sock):
            send_command(options.sock, "commit")
        else:
            print >>sys.stderr, "VM is not running in snapshot mode"
            sys.exit(1)




































TEMPLATE = """#!/bin/sh
# Get machine name from current directory name
NAME=$(basename $(pwd))
# if remote access is enabled, then there should be
# SPICE_PASSWORD=password
QEMU_AUDIO_DRV=spice







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
            sys.exit(1)
    else:
        if snapshot_mode(options.sock):
            send_command(options.sock, "commit")
        else:
            print >>sys.stderr, "VM is not running in snapshot mode"
            sys.exit(1)

def cmd_autostart(options):
    """
    Starts all VMs which are in the autostart directory
    """
    dirname =  config.get("directories", "AutostartVMs")
    if not os.access(dirname,os.R_OK):
        return 
    for name in os.listdir(dirname):
        if not os.access(os.path.join(dirname,name,"start"), os.X_OK):
            continue
        machine_dir = os.path.join(dirname,name)
        sock = connect_vm(machine_dir)
        if sock:
            # Machine already running
            sock.shutdown(socket.SHUT_RDWR)
            sock.close()
            continue
        start_opts = Namespace(machine = name,
                command = 'start',
                dir = machine_dir,
                snapshot = False,
                stopped = True,
                atrgs = "",
                gui = False,
                cdrom = None)
        try:
            cmd_start(start_opts)
            print name," ",
        finally:
            # pylint: disable=no-member
            start_opts.sock.shutdown(socket.SHUT_RDWR)
    print ""



TEMPLATE = """#!/bin/sh
# Get machine name from current directory name
NAME=$(basename $(pwd))
# if remote access is enabled, then there should be
# SPICE_PASSWORD=password
QEMU_AUDIO_DRV=spice
657
658
659
660
661
662
663

664
665
666
667
668
669
670
p.add_argument("--state", action='store_const', const=True, default=False,
               dest='state', help='Show state of the machine')
p.add_argument("--addr", action='store_const', const=True, default=False,
               dest='addr', help='Show mac address and spice port')
p.add_argument("--usb", action='store_const', const=True, default=False,
               dest='usb', help='Show connected USB devices')
p = cmds.add_parser("version", help="show vws version")

# Power management
p = new_command(cmds, 'start', help='Start VW and connect to console',
                description="Start VW if not running and connect " +
                "to the console")
p.add_argument('--no-gui', dest='gui', action='store_const', const=False,
               default=True, help='do not open console window')
p.add_argument('--cdrom', metavar='filename.iso', dest='cdrom', nargs=1,







>







692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
p.add_argument("--state", action='store_const', const=True, default=False,
               dest='state', help='Show state of the machine')
p.add_argument("--addr", action='store_const', const=True, default=False,
               dest='addr', help='Show mac address and spice port')
p.add_argument("--usb", action='store_const', const=True, default=False,
               dest='usb', help='Show connected USB devices')
p = cmds.add_parser("version", help="show vws version")
p = cmds.add_parser("autostart",help="Autostart all VMs marked as autostartable")
# Power management
p = new_command(cmds, 'start', help='Start VW and connect to console',
                description="Start VW if not running and connect " +
                "to the console")
p.add_argument('--no-gui', dest='gui', action='store_const', const=False,
               default=True, help='do not open console window')
p.add_argument('--cdrom', metavar='filename.iso', dest='cdrom', nargs=1,