VNC: Catch the error when the VM is off and there is no host
authorGeoffrey Thomas <geofft@mit.edu>
Thu, 31 Jul 2008 02:16:51 +0000 (22:16 -0400)
committerGeoffrey Thomas <geofft@mit.edu>
Thu, 31 Jul 2008 02:16:51 +0000 (22:16 -0400)
svn path=/trunk/packages/sipb-xen-www/; revision=797

code/main.py

index 4627c66..7af4ecc 100755 (executable)
@@ -257,8 +257,12 @@ def vnc(username, state, path, fields):
     token = {'data': pickled_data, 'digest': m.digest()}
     token = cPickle.dumps(token)
     token = base64.urlsafe_b64encode(token)
     token = {'data': pickled_data, 'digest': m.digest()}
     token = cPickle.dumps(token)
     token = base64.urlsafe_b64encode(token)
-    port = 10003 + [config_host["hostname"] for config_host in invirt_config["hosts"]
-        ].index(controls.listHost(machine))
+    host = controls.listHost(machine)
+    if host:
+        port = 10003 + [config_host["hostname"] for config_host in invirt_config["hosts"]
+            ].index(controls.listHost(machine))
+    else:
+        port = 5900 # dummy
 
     status = controls.statusInfo(machine)
     has_vnc = hasVnc(status)
 
     status = controls.statusInfo(machine)
     has_vnc = hasVnc(status)