17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
config.get("directories", "SharedVMs"),
config.get("directories", "AutostartVMs")]
for dirname in search_path:
if not os.access(dirname, os.X_OK):
continue
if (name in os.listdir(dirname) and
os.access(os.path.join(dirname, name, "start"), os.X_OK)):
return os.path.join(dirname, + name)
raise ValueError("Machine %s not found." % name)
def connect_vm(vm_dir):
""" Connects to monitor of VM in vm_dir and returns connected socket"""
sock = socket.socket(socket.AF_UNIX)
monitor_path = os.path.join(vm_dir, "monitor")
|
|
|
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
config.get("directories", "SharedVMs"),
config.get("directories", "AutostartVMs")]
for dirname in search_path:
if not os.access(dirname, os.X_OK):
continue
if (name in os.listdir(dirname) and
os.access(os.path.join(dirname, name, "start"), os.X_OK)):
return os.path.join(dirname, name)
raise ValueError("Machine %s not found." % name)
def connect_vm(vm_dir):
""" Connects to monitor of VM in vm_dir and returns connected socket"""
sock = socket.socket(socket.AF_UNIX)
monitor_path = os.path.join(vm_dir, "monitor")
|
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
result.append(match.group(1))
return result
def snapshot_mode(sock):
""" Returns True if VM is running in snapshot mode """
answer = send_command(sock, "info block")
return re.search(": /tmp", answer) is not None
#
# command implementation
#
def cmd_spiceuri(options):
""" vws spiceuri """
print spiceurl(options)
def cmd_start(options):
""" vws start """
if options.stopped:
arg = ""
if options.cdrom:
arg = " -cdrom " + options.cdrom[0]
if options.snapshot:
arg = arg+" -snapshot"
if options.args:
arg = arg + " " + "".join(options.args)
print arg
cwd = os.getcwd()
os.chdir(options.dir)
|
>
|
|
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
result.append(match.group(1))
return result
def snapshot_mode(sock):
""" Returns True if VM is running in snapshot mode """
answer = send_command(sock, "info block")
return re.search(": /tmp", answer) is not None
#
# command implementation
#
def cmd_spiceuri(options):
""" vws spiceuri """
print spiceurl(options)
def cmd_start(options):
""" vws start """
if options.stopped:
arg = ""
if options.cdrom:
arg = " -cdrom " + os.path.abspath(options.cdrom[0])
if options.snapshot:
arg = arg+" -snapshot"
if options.args:
arg = arg + " " + "".join(options.args)
print arg
cwd = os.getcwd()
os.chdir(options.dir)
|
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
|
if options.file == "":
print >>sys.stderr, "Please specify either --eject or iso image"
sys.exit(1)
if options.file is None:
answer = send_command(options.sock, "eject " + options.id)
else:
answer = send_command(options.sock, "change %s %s" %
(options.id, options.file))
print answer
def find_usb(options, devices):
""" Search for pattern or address given in options in the
given list of devices.
List should be produced by get_host_devices() or
get_vm_devices()
|
|
|
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
|
if options.file == "":
print >>sys.stderr, "Please specify either --eject or iso image"
sys.exit(1)
if options.file is None:
answer = send_command(options.sock, "eject " + options.id)
else:
answer = send_command(options.sock, "change %s %s" %
(options.id, os.path.abspath(options.file)))
print answer
def find_usb(options, devices):
""" Search for pattern or address given in options in the
given list of devices.
List should be produced by get_host_devices() or
get_vm_devices()
|