Index: Makefile ================================================================== --- Makefile +++ Makefile @@ -8,16 +8,19 @@ %.1:%.mkd pandoc -s -t man -o $@ $+ clean: - rm *.1 + rm -f *.1 vws.service + +vws.service: vws.service.in + sed 's!@bindir@!$(bindir)!' $+ > $@ -install: vws vws.1 find_free_port.1 vws.conf +install: vws vws.1 find_free_port.1 vws.conf vws.service [ -d $(DESTDIR)$(bindir) ] || $(INSTALL) -d -m 755 -o root $(DESTDIR)$(bindir) [ -d $(DESTDIR)$(mandir) ] || $(INSTALL) -d -m 755 -o root $(DESTDIR)$(mandir) [ -d $(DESTDIR)$(mandir)/man1 ]||$(INSTALL) -d -m 755 -o root $(DESTDIR)$(mandir)/man1 $(INSTALL) -c -m 755 -o root find_free_port $(DESTDIR)$(bindir) $(INSTALL) -c -m 755 -o root vws $(DESTDIR)$(bindir) [ -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 Index: vws ================================================================== --- vws +++ vws @@ -355,10 +355,11 @@ answer = send_command(options.sock, "usb_del %s" % address) print answer def cmd_list(options): """ vws list """ + import fnmatch count = 0 search_path = [("private",os.path.join(pwd.getpwuid(os.getuid()).pw_dir, "VWs")), ("shared",config.get("directories", "SharedVMs")), ("autostart",config.get("directories", "AutostartVMs"))] @@ -368,10 +369,17 @@ for (vmtype,dirname) in search_path: if not os.access(dirname + "/.", os.X_OK): continue for vmname in os.listdir(dirname): if os.access(dirname + "/" + vmname + "/start", os.X_OK): + matches=False + for p in options.pattern: + if fnmatch.fnmatch(vmname,p): + matches=True + break + if not matches: + continue count += 1 f = {"name":vmname} if maxlen < len(vmname): maxlen = len(vmname) if options.state: @@ -839,10 +847,11 @@ description="List existing VWs") p.add_argument("--state", action='store_const', const=True, default=False, dest='state', help='Show state of the machine') p.add_argument("--usb", action='store_const', const=True, default=False, dest='usb', help='Show connected USB devices') +p.add_argument("pattern", nargs='*',default='*',help="Name patterns") p = cmds.add_parser("version", help="show vws version") p = cmds.add_parser("autostart",help="Autostart all VMs marked as autostartable") p = cmds.add_parser("shutdown",help="shut down all running VMs") p.add_argument("--wait",help="wait until all machines would be shoutdown", action="store_const", const=True, default=False, dest="wait") Index: vws.mkd ================================================================== --- vws.mkd +++ vws.mkd @@ -10,11 +10,11 @@ SYNOPSIS ======== **vws create** *name* [ **--install** *isoimage* ] -**vws list** \[**--state**\] \[**--usb**\] +**vws list** \[**--state**\] \[**--usb**\] \[ *pattern* ... \] **vws start** *name* [**--no-gui**] \[**--cdrom** *iso-image*\] **vws stop** *name* [**--hard**] @@ -358,15 +358,18 @@ **vws spiceuri** *machine* Prints out URI you should feed into your spice viewer to access this machine. -**vws list** [ **--state** ] +**vws list** [ **--state** ] \[ **--usb** \] \[ *pattern* .. \] Lists available virtual machines. If **--state** option is given, prints -out state (running or stoped) type (private or shared) and spice URI (if -machine is running). +out state (running or stopped) type (private or shared) spice URI (if +machine is running), mac and IP address. Pattern is shell-style wildcard +which limits machines to be shown. Don't forget to quote pattern from shell. It +should be expanded. **--usb** option lists USB devices connected to the +virtual machine using **vws usb** command. **vws sendkey** *machine* *keyspec* Allows to send some key combination to the virtual machine. For example if windows screen is locked spice client is sometimes unable to deliver DELETED vws.service Index: vws.service ================================================================== --- vws.service +++ vws.service @@ -1,12 +0,0 @@ -[Unit] -Description=Virtual Workstation Autostart -Documentation=man:vws(1) -After=network.target dnsmasq.service -[Service] -Type=forking -ExecStart=/usr/local/bin/vws autostart -ExecStop=/usr/local/bin/vws shutdown --wait -Restart=no -[Install] -WantedBy=muiti-user.target -Alias=vws.service ADDED vws.service.in Index: vws.service.in ================================================================== --- vws.service.in +++ vws.service.in @@ -0,0 +1,12 @@ +[Unit] +Description=Virtual Workstation Autostart +Documentation=man:vws(1) +After=network.target dnsmasq.service +[Service] +Type=forking +ExecStart=@bindir@/vws autostart +ExecStop=@bindir@/vws shutdown --wait +Restart=no +[Install] +WantedBy=muiti-user.target +Alias=vws.service