Revision 71099804 api/actions.py
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', |
Also available in: Unified diff