Check-in [a1e43bbc27]
Not logged in
Overview
Comment:Fixed some problems recently introduced in create. Added passing of extra args to QEMU
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: a1e43bbc27137aee660b21904caa042cfd0db8d6
User & Date: vitus on 2017-03-10 15:08:35
Other Links: manifest | tags
Context
2017-08-30
11:45
Fixed typo in unit file. Incremented debian package version check-in: 648764b0ec user: vitus tags: trunk
2017-03-10
15:08
Fixed some problems recently introduced in create. Added passing of extra args to QEMU check-in: a1e43bbc27 user: vitus tags: trunk
2017-01-23
10:56
Fixed some problems found out by real deployment check-in: a094bdd8da user: vitus tags: trunk
Changes

Added .pylintrc version [97846308cc].



>
1
good-names: i,j,k,f,r,ex

Modified Makefile from [4507c55ffb] to [8f36d0b45d].

29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
	
	[ -f $(DESTDIR)$(sysconfdir)/vws.conf ]|| $(INSTALL) -c -m 644 -o root vws.conf $(DESTDIR)$(sysconfdir)
	$(INSTALL) -c -m 644 -o root vws.1 $(DESTDIR)$(mandir)/man1
	$(INSTALL) -c -m 644 -o root find_free_port.1 $(DESTDIR)$(mandir)/man1
	$(INSTALL) -c -m 644 -o root vws.service $(DESTDIR)$(systemddir)
	$(INSTALL) -c -m 644 -o root vws.init $(DESTDIR)$(initddir)/vws

origtarball: vws find_free_port vws.init vws.service.in  Makefile vws.conf vws.mkd find_free_port.mkd
	version=$$(sed -n 's/VERSION = //p' vws); \
	mkdir vws-$$version; cp $+ vws-$$version; \
	tar cjf ../vws_$$version.orig.tar.bz2 vws-$$version; \
	rm -rf vws-$$version

deb: origtarball
	debuild







|







29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
	
	[ -f $(DESTDIR)$(sysconfdir)/vws.conf ]|| $(INSTALL) -c -m 644 -o root vws.conf $(DESTDIR)$(sysconfdir)
	$(INSTALL) -c -m 644 -o root vws.1 $(DESTDIR)$(mandir)/man1
	$(INSTALL) -c -m 644 -o root find_free_port.1 $(DESTDIR)$(mandir)/man1
	$(INSTALL) -c -m 644 -o root vws.service $(DESTDIR)$(systemddir)
	$(INSTALL) -c -m 644 -o root vws.init $(DESTDIR)$(initddir)/vws

origtarball: vws find_free_port vws.init vws.service.in  Makefile vws.conf vws.mkd find_free_port.mkd .pylintrc
	version=$$(sed -n 's/VERSION = //p' vws); \
	mkdir vws-$$version; cp $+ vws-$$version; \
	tar cjf ../vws_$$version.orig.tar.bz2 vws-$$version; \
	rm -rf vws-$$version

deb: origtarball
	debuild

Modified vws from [bcbae58ab5] to [2dd169c463].

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,
                args = "",
                gui = False,
                cdrom = None)
        try:
            cmd_start(start_opts)
            print name," ",
        finally:







|







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,
                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
-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
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"







|







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 {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
               "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":""}

    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",







|
>







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":"",
               "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
        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,
                               command='start', cdrom=[install_image],
                               dir=machinedir, stopped=True, snapshot=False,
                               args="", gui=True)
        try:
            cmd_start(start_opts)
        finally:
            # pylint: disable=no-member

            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







|







>
|







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,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)

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