Diff
Not logged in

Differences From Artifact [bcbae58ab5]:

To Artifact [2dd169c463]:


584
585
586
587
588
589
590
591

592
593
594
595
596
597
598
584
585
586
587
588
589
590

591
592
593
594
595
596
597
598







-
+







            sock.close()
            continue
        start_opts = Namespace(machine = name,
                command = 'start',
                dir = machine_dir,
                snapshot = False,
                stopped = True,
		password = None,
                password = None,
                args = "",
                gui = False,
                cdrom = None)
        try:
            cmd_start(start_opts)
            print name," ",
        finally:
678
679
680
681
682
683
684
685

686
687
688
689
690
691
692
678
679
680
681
682
683
684

685
686
687
688
689
690
691
692







-
+







-spice port=$SPICE_PORT,$SPICE_AUTH \\
-device virtio-serial -chardev spicevmc,id=vdagent,name=vdagent \\
-device virtserialport,chardev=vdagent,name=com.redhat.spice.0 \\
-device ich9-usb-ehci1,id=usb \\
-device ich9-usb-uhci1,masterbus=usb.0,firstport=0,multifunction=on \\
-chardev spicevmc,name=usbredir,id=usbredirchardev1 \\
-device usb-redir,chardev=usbredirchardev1,id=usbredirdev1 \\
-daemonize -pidfile pid
-daemonize -pidfile pid {extraargs}
chgrp {group} monitor pid
chmod 0660 monitor pid
"""

def cmd_create(parsed_args):
    """ vws create - create new VM """
    BADSIZE = "Invalid size of %s specifed %s. Should have K, M or G suffix"
701
702
703
704
705
706
707
708


709
710
711
712
713
714
715
701
702
703
704
705
706
707

708
709
710
711
712
713
714
715
716







-
+
+







               "memory":"1024M",
               "vga":'qxl',
               "drive":"-drive media=disk,index=0,if={interface},file={image}",
               "cdrom":"-drive media=cdrom,index=2,if=ide",
               "sound":"-soundhw hda",
               "group":config.get("permissions","vm_group"),
               "usb":"-usb",
               "rtc":""}
               "rtc":"",
               "extraargs":"${1:+\"$@\"}"}
    macaddr = ":".join(["%02x" % ord(x) for x in  chr(0x52) + os.urandom(5)])
    if parsed_args.shared:
        machinedir = os.path.join(config.get("directories", "SharedVMs"),
                                  parsed_args.machine)
        dirmode = 0775
    else:
        machinedir = os.path.join(pwd.getpwuid(os.getuid()).pw_dir, "VWs",
790
791
792
793
794
795
796
797

798
799
800
801
802
803
804

805

806
807
808
809
810
811
812
791
792
793
794
795
796
797

798
799
800
801
802
803
804
805
806

807
808
809
810
811
812
813
814







-
+







+
-
+







        print repr(driveopts), repr(options["drive"])
        print repr(options)
    with open("start", "w") as script:
        script.write(TEMPLATE.format(**options))
    os.chmod('start', dirmode)
    # If installation media is specified vws start for new vm
    if parsed_args.install:
        start_opts = Namespace(machine=parsed_args.machine,
        start_opts = Namespace(machine=parsed_args.machine,password=None,
                               command='start', cdrom=[install_image],
                               dir=machinedir, stopped=True, snapshot=False,
                               args="", gui=True)
        try:
            cmd_start(start_opts)
        finally:
            # pylint: disable=no-member
            if hasattr(start_opts,"sock"):
            start_opts.sock.shutdown(socket.SHUT_RDWR)
                start_opts.sock.shutdown(socket.SHUT_RDWR)

#
# Utility functions for arg parsing
#
def new_command(cmd_parser, name, **kwargs):
    """
    Adds a subparser and adds a machine name argument to it