1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
#!/usr/bin/python
from ConfigParser import ConfigParser
from argparse import ArgumentParser
import fcntl
import socket
import errno
import re
import os,sys
def find_vm(name):
search_path=[os.environ['HOME']+"/VWs",
config.get("directories","SharedVMs"),
config.get("directories","AutostartVMs")]
for dirname in search_path:
if name in os.listdir(dirname):
return dirname+"/"+name
|
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
#!/usr/bin/python
from ConfigParser import ConfigParser
from argparse import ArgumentParser
import fcntl
import socket
import errno
import re
import os,sys,time
def find_vm(name):
search_path=[os.environ['HOME']+"/VWs",
config.get("directories","SharedVMs"),
config.get("directories","AutostartVMs")]
for dirname in search_path:
if name in os.listdir(dirname):
return dirname+"/"+name
|
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
if url is not None:
continue
n=line.find("address:")
if n != -1:
url=line[n+9:]
if url.startswith('*:'):
url="localhost"+url[1:]
return "spice://"+url
#
# command implementation
#
def cmd_spiceuri(options):
print spiceurl(options)
def cmd_start(options):
if options.stopped:
arg=""
if options.cdrom:
arg=" -cdrom "+options.cdrom
cwd=os.getcwd()
os.chdir(options.dir)
os.system("./start%s" % arg)
os.chdir(cwd)
os.sleep(2)
options.sock = connect_vm(options.dir)
if options.gui:
uri = spiceurl(options)
os.system("remote-viewer %s &"%uri)
elif not options.stopped:
print >>sys.stderr,"VM already running"
def cmd_stop(options):
print send_command(options.sock,'system_powerdown')
def cmd_reset(options):
|
>
>
|
|
|
|
|
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
if url is not None:
continue
n=line.find("address:")
if n != -1:
url=line[n+9:]
if url.startswith('*:'):
url="localhost"+url[1:]
if url is None:
return None
return "spice://"+url.rstrip('\r')
#
# command implementation
#
def cmd_spiceuri(options):
print spiceurl(options)
def cmd_start(options):
if options.stopped:
arg=""
if options.cdrom:
arg=" -cdrom "+options.cdrom[0]
cwd=os.getcwd()
os.chdir(options.dir)
os.system("./start%s" % arg)
os.chdir(cwd)
time.sleep(2)
options.sock = connect_vm(options.dir)
if options.gui:
uri = spiceurl(options)
os.system("remote-viewer %s &" % uri)
elif not options.stopped:
print >>sys.stderr,"VM already running"
def cmd_stop(options):
print send_command(options.sock,'system_powerdown')
def cmd_reset(options):
|