Revision 71099804
b/api/actions.py | ||
---|---|---|
203 | 203 |
It uses a running instance of vncauthproxy to setup proper |
204 | 204 |
VNC forwarding with a random password, then returns the necessary |
205 | 205 |
VNC connection info to the caller. |
206 |
|
|
206 | 207 |
""" |
207 | 208 |
# Normal Response Code: 200 |
208 | 209 |
# Error Response Codes: computeFault (400, 500), |
... | ... | |
228 | 229 |
console_data = backend.get_instance_console(vm) |
229 | 230 |
|
230 | 231 |
if console_data['kind'] != 'vnc': |
231 |
message = 'Could not create a console of requested type.'
|
|
232 |
message = 'got console of kind %s, not "vnc"' % console_data['kind']
|
|
232 | 233 |
raise ServiceUnavailable(message) |
233 | 234 |
|
234 | 235 |
# Let vncauthproxy decide on the source port. |
... | ... | |
239 | 240 |
dport = console_data['port'] |
240 | 241 |
password = random_password() |
241 | 242 |
|
242 |
try: |
|
243 |
if settings.TEST: |
|
244 |
fwd = {'source_port': 1234, 'status': 'OK'} |
|
245 |
else: |
|
246 |
fwd = request_vnc_forwarding(sport, daddr, dport, password) |
|
247 |
except Exception: |
|
248 |
raise ServiceUnavailable('Could not allocate VNC console port.') |
|
243 |
if settings.TEST: |
|
244 |
fwd = {'source_port': 1234, 'status': 'OK'} |
|
245 |
else: |
|
246 |
fwd = request_vnc_forwarding(sport, daddr, dport, password) |
|
249 | 247 |
|
250 | 248 |
if fwd['status'] != "OK": |
251 |
raise ServiceUnavailable('Could not allocate VNC console.')
|
|
249 |
raise ServiceUnavailable('vncauthproxy returned error status')
|
|
252 | 250 |
|
253 | 251 |
console = { |
254 | 252 |
'type': 'vnc', |
b/logic/backend.py | ||
---|---|---|
214 | 214 |
|
215 | 215 |
|
216 | 216 |
def get_instance_console(vm): |
217 |
return rapi.GetInstanceConsole(vm.backend_id) |
|
218 |
|
|
217 |
# RAPI GetInstanceConsole() returns endpoints to the vnc_bind_address, |
|
218 |
# which is a cluster-wide setting, either 0.0.0.0 or 127.0.0.1, and pretty |
|
219 |
# useless (see #783). |
|
220 |
# |
|
221 |
# Until this is fixed on the Ganeti side, construct a console info reply |
|
222 |
# directly. |
|
223 |
# |
|
224 |
# WARNING: This assumes that VNC runs on port network_port on |
|
225 |
# the instance's primary node, and is probably |
|
226 |
# hypervisor-specific. |
|
227 |
# |
|
228 |
console = {} |
|
229 |
console['kind'] = 'vnc' |
|
230 |
i = rapi.GetInstance(vm.backend_id) |
|
231 |
if i['hvparams']['serial_console']: |
|
232 |
raise Exception("hv parameter serial_console cannot be true") |
|
233 |
console['host'] = i['pnode'] |
|
234 |
console['port'] = i['network_port'] |
|
235 |
|
|
236 |
return console |
|
237 |
# return rapi.GetInstanceConsole(vm.backend_id) |
|
219 | 238 |
|
220 | 239 |
def request_status_update(vm): |
221 | 240 |
return rapi.GetInstanceInfo(vm.backend_id) |
Also available in: Unified diff